63 Commits

Author SHA1 Message Date
Dylan K. Taylor
b407eba1a3 Apply typehints to level\format\io namespace 2018-10-04 19:59:26 +01:00
Dylan K. Taylor
49e47edcf5 Separate level data handling from the main LevelProvider 2018-10-04 18:45:02 +01:00
Dylan K. Taylor
4d9d4d7c60 More cleanups to level provider hierarchy, move more garbage out of BaseLevelProvider 2018-10-04 16:02:55 +01:00
Dylan K. Taylor
4f421d561c BaseLevelProvider: clean up not-exists error handling disaster
It checks for the existence of (and creates) the world directory if it doesn't exist. But what sense does this make when the world obviously doesn't exist in this case and must be generated first?
2018-10-04 15:41:18 +01:00
Dylan K. Taylor
f787552e97 Remove LevelProvider::getProviderName()
This is problematic because child level providers can forget to override the provider name of their parents, and then override them by error. Instead, they should be used in a mapping fashion to make sure they are unique and not inherited.
Also, the old method did not permit registering multiple aliases for the same provider. This now makes that possible.
2018-10-04 14:56:42 +01:00
Dylan K. Taylor
23132b899c Added LevelProvider->getAllChunks() method
this returns a generator which yields known chunks. This will be used in the future for world format conversions.
2018-10-03 19:43:16 +01:00
Dylan K. Taylor
9b49d09714 LevelProvider: Added methods to get and set rain/lightning level and times 2018-08-28 15:02:45 +01:00
Dylan K. Taylor
4fb1f8dd76 Merge branch 'release/3.2' 2018-08-25 17:49:28 +01:00
Dylan K. Taylor
7dd53f2397 Replace unnecessary strlen > 0 calls with !== "" checks 2018-08-25 16:07:49 +01:00
Dylan K. Taylor
0273e2484e
Kill entity runtime NBT (#2361) 2018-08-14 13:33:02 +01:00
Dylan K. Taylor
f77a829a52 LevelDB: remove redundant check
Assume that entities on a chunk are not closed... none of the other providers check this
2018-06-16 18:00:26 +01:00
Dylan K. Taylor
f315aca4c3 Tile: make saveNBT() return a CompoundTag
I don't know why I made it take a parameter for this...
2018-06-16 17:59:41 +01:00
Dylan K. Taylor
0c70b83d81 LevelProvider: workaround bug fixed in b54197904d6c23c5babe2857d0107d9d0fc8bd68 for previously-affected worlds 2018-06-07 15:18:42 +01:00
Dylan K. Taylor
5eec683110 Generator: Moved generator registering things to a separate GeneratorManager class
this isolates the concerns of the Generator class, and also removes cyclic dependencies between the Generator class and its descendents.
2018-06-07 13:48:01 +01:00
Dylan K. Taylor
b54197904d Fixed imported worlds getting PM classpaths written into their level.dat for generator
This will not fix existing worlds affected by this bug.
2018-06-07 13:20:50 +01:00
Dylan K. Taylor
fa21cd96c5 Tiles no longer store their NBT at runtime
This is a significant breaking change for anything utilizing Tiles as they now do not store their NBT at runtime anymore.
This is another step in the process of ridding PocketMine-MP of runtime NBT.

It can be noticed that all tiles are now using class fields to store properties instead of NBT, which is much faster, uses less memory and is also more concise when written in code.

Highlights:
- Tile->namedtag has been removed.
- Tile->saveNBT() now accepts a CompoundTag() parameter. Typically it's expected that this will be fed a newly-created CompoundTag (this part may be improved in the future).
- New internal methods Tile->readSaveData() and Tile->writeSaveData() have been added. Instead of overriding __construct() and saveNBT() to load and save properties from NBT, you should now implement these methods instead.

This is not final and will see further changes before it's done.
2018-06-03 18:29:08 +01:00
Dylan K. Taylor
c493d0e6ac Level: Stop unnecessarily initializing the generator on the main thread
this is just slowing down startup times for no good reason.
2018-05-31 10:22:44 +01:00
Dylan K. Taylor
9bc860f7a8 LevelDB: fixup extra-data handling, don't delete it - just don't read it
we'll need this once multi-layer block storages are implemented.
2018-05-19 11:35:54 +01:00
Dylan K. Taylor
66963fbf9a Nuke block extradata
this has been superseded by multi-layer blockstorages in 1.2.14+
2018-05-19 11:03:28 +01:00
Dylan K. Taylor
d478661961 Minor cleanup to LevelDB constructor 2018-03-11 18:15:20 +00:00
Dylan K. Taylor
b8064aa45c LevelDB: fixed more usages of CompoundTag ArrayAccess API 2018-03-11 17:55:35 +00:00
Dylan K. Taylor
9d018e8d9e Level: cleaned up chunk loading error handling, close #2056
This now removes logging from the level providers (for the most part) and replaces it with exception throws and catches. The implementation using the providers should catch these exceptions if they are thrown.
2018-03-01 12:30:12 +00:00
Dylan K. Taylor
093cb5b39e Updated PocketMine-NBT dependency 2018-02-17 14:29:20 +00:00
Dylan K. Taylor
8222b16d9a LevelDB: fixed leftover usage of the old CompoundTag API 2018-02-06 11:16:14 +00:00
Dylan K. Taylor
a46029c0f6 LevelProvider: Nuked the complicated mess out of level providers
Level providers are now cut back to just an interface to a world's data. They don't keep their own chunk registries or any stupid shit like that because the Level already does that.

This furthers the goal of being able to move level I/O off the main thread, and also drastically decreases the complication of implementing level providers.
2018-01-01 11:21:46 +00:00
Dylan K. Taylor
1a615591e2 LevelProvider: Remove cyclic dependency between Level and LevelProvider
This will now allow LevelProviders to be constructed on threads.
2018-01-01 10:50:13 +00:00
Dylan K. Taylor
d19683b7dd LevelProvider: Remove some dead methods 2017-12-31 18:35:23 +00:00
Dylan K. Taylor
f17b3b2a3b LevelProvider: Refactor providers to drop lots of duplicated code 2017-12-31 18:35:23 +00:00
Dylan K. Taylor
a0a2ea01bc LevelDB: Check for LEVELDB_ZLIB_RAW_COMPRESSION when checking for the extension's presence
We always want to validate that the leveldb provided supports the world format.
2017-12-31 17:49:02 +00:00
Dylan K. Taylor
5132ab6cd9 LevelDB: Remove redundant folder creation in generate()
This is pointless because the call below - which is _also_ recursively creating directories - will create this directory anyway.
2017-12-31 17:46:07 +00:00
Dylan K. Taylor
965c19375f NBT: Split up concerns of endianness and varint NBT into their own classes, separate stream handling from NBT class
The remaining methods, constants and fields in the NBT class now pertain to generic NBT functionality (except for the matchList()/matchTree() methods, but that's a job for another time). All NBT I/O specific logic has now been moved to NBTStream and its descendents.
2017-12-30 14:55:45 +00:00
Dylan K. Taylor
4f8e4f0522
Add EOF newlines where missing (bulk) (#1836)
This should solve issues with people making GitHub PRs and having the web editor messing things up. GitHub Web Editor sucks :(
2017-12-20 11:56:36 +00:00
Dylan K. Taylor
8bc733514b LevelDB: Fixed nonsensical array access in iterator loop 2017-11-27 17:21:26 +00:00
Dylan K. Taylor
74b074753f Bulk addition of constant visibilities
thanks PhpStorm inspections plugin for annoying the shit out of me until
I did this.
2017-11-21 14:44:10 +00:00
Dylan K. Taylor
a9df383346 generalized conditions for saving entities with chunks 2017-11-19 18:06:38 +00:00
Dylan K. Taylor
2fd61163bf cleanup some chunks leftovers from 1.0 2017-11-19 17:52:36 +00:00
Dylan K. Taylor
5640bcb0b8 add some new leveldb keys 2017-11-19 17:43:54 +00:00
Dylan K. Taylor
ea3c7383fb Added support for handling MCPE 1.2 leveldb worlds
requires php-leveldb version >=0.2.1 and the latest version of
pmmp/leveldb-mcpe
2017-11-19 17:31:09 +00:00
Dylan K. Taylor
7e496afdd1 Fixed issues with LevelDB worlds silently getting overwritten with the default format when LevelDB extension is not loaded
Always register the level provider (to allow detecting the world format) but throw exceptions if anything tries to use it without the extension being loaded.
2017-11-19 17:28:16 +00:00
Dylan K. Taylor
aa399a1109
migrate to new CompoundTag API (#1515) 2017-11-10 15:38:21 +00:00
Dylan K. Taylor
5a353012de Clean up some unused imports 2017-10-19 16:39:34 +01:00
Dylan K. Taylor
be2d134994 Added API to allow flagging an entity not to be saved to disk when its chunk is saved (#1452) 2017-10-11 16:09:08 +01:00
Dylan K. Taylor
38fad4b963 Implement difficulty per-world (#878)
* Moved Server::getDifficultyFromString() to Level
* Added ability to set difficulty in worlds section of pocketmine.yml for generation
2017-09-26 11:16:51 +01:00
Dylan K. Taylor
b9c4a65307 Don't save players with chunks!
I can't believe I didn't notice this
2017-08-30 16:55:17 +01:00
Dylan K. Taylor
23752548fe Address several LevelDB related crashdumps in the crash archive 2017-08-30 15:42:31 +01:00
Dylan K. Taylor
b4c4005009 Some condition simplifications suggested by static analysis 2017-08-16 20:06:48 +01:00
Dylan K. Taylor
c3b8be3f60 and more typehints 2017-07-14 10:56:51 +01:00
Dylan K. Taylor
2a7b736f18 Heap of bugfixes, cleanup and PHP 7 upgrades 2017-07-13 19:18:56 +01:00
Dylan K. Taylor
b4a149cce8 Fix some issues with entities in leveldb worlds 2017-07-02 13:37:30 +01:00
Dylan K. Taylor
70bd9afd37 Updated leveldb implementation to support MCPE 1.1 worlds 2017-06-30 09:11:26 +01:00