Commit Graph

161 Commits

Author SHA1 Message Date
d410db4302 Chunk: rename DIRTY_FLAG_TERRAIN to DIRTY_FLAG_BLOCKS
we use the word 'terrain' elsewhere to refer to the combination of blocks and biomes, so using TERRAIN here is misleading.
2021-10-28 22:11:07 +01:00
a62ce64fdd Revert "Chunk: added modification counter"
This reverts commit a5418a019d.

The more I assessed this, the more I realized that this implementation
doesn't actually offer any value. Since modcounters don't persist after
chunk unload + reload, they can't be reliably used to detect changes in
chunks without additional event subscriptions.
For the purpose I actually intended to use them for (population task
cancellation) there's a) another solution, and b) modcounts are
unreliable for that too, because of the aforementioned potential for
chunks to get unloaded and reloaded.
For the case of detecting dirty chunks within PopulationTask itself,
they are also unnecessary, since the dirty flags are sufficient within
there, since FastChunkSerializer doesn't copy dirty flags.

In conclusion, this was a misbegotten addition with little real value,
but does impact performance in hot paths.
2021-10-28 21:02:04 +01:00
51fbff204b World: make PhpStorm understand return type of getAdjacentChunks() 2021-10-26 20:32:09 +01:00
1873457840 PopulationTask: stop using dynamic properties 2021-10-26 20:21:58 +01:00
8f88393184 World: Specialize generateChunkCallback() for PopulationTask
this allows us to also set the adjacent chunks before calling ChunkPopulateEvent, to give a more accurate picture of what changed.
2021-10-26 15:28:00 +01:00
94f4ef5862 PopulationTask: Throw AssumptionFailedError if center chunk is null for some reason 2021-10-25 21:07:03 +01:00
2e2515354c PopulationTask: fixed undefined method call
fuck you PhpStorm! fuck you PhpStorm! fuck you PhpStorm!
2021-10-25 20:57:43 +01:00
d4cbde6f10 PopulationTask: use modification counters to detect changed chunks
instead of using terrain dirty flags, which aren't suitable for this purpose
2021-10-25 20:53:50 +01:00
baba25953f Chunk: make all parameters of __construct() mandatory and non-nullable
having the constructor fill in defaults for these invariably causes bugs.
2021-10-25 20:22:50 +01:00
401e8d117b Flat: use a less dumb way to build biome array 2021-10-25 20:15:33 +01:00
d73ea8efe4 FlatGeneratorOptions: Do not hardcode biome ID 2021-10-11 21:32:20 +01:00
34f54750c8 Added support for creation-time validation of generator options, closes #2717 2021-10-11 17:37:47 +01:00
092aabeb97 fix CS 2021-10-11 17:21:19 +01:00
70deea0ef9 Flat: Move preset handling to a FlatGeneratorOptions unit 2021-10-11 16:53:08 +01:00
859cdfa5d2 GeneratorManager: removed unused parameter from getGenerator() 2021-10-11 16:18:38 +01:00
7b6632941d GeneratorManager::getGenerator() now returns null for unknown generator aliases
instead of returning Normal::class (indistinguishable from successful match) or throwing an exception (pain in the ass to handle).
2021-10-11 16:04:36 +01:00
c7e9138994 PopulationTask: reduce code duplication 2021-10-01 23:18:56 +01:00
88f799da2c more AssumptionFailedError hacks for PHPStan :(
the code in this class is really horrible
2021-10-01 23:05:48 +01:00
8de30e8162 FastChunkSerializer no longer serializes light by default
the core doesn't use this anywhere.
serializeWithoutLight() has been renamed to serializeTerrain() to more accurately describe what it does.
2021-10-01 22:57:22 +01:00
4111d92b98 Stop hardcoding chunk dimensions everywhere (#4443) 2021-09-10 16:13:25 +01:00
2fe03757d5 PopulationTask: fixed PHPStan errors 2021-08-30 00:26:54 +01:00
e0d6357eb7 OreType: use promoted constructo properties 2021-08-30 00:18:34 +01:00
0289b45202 Chunk: Drop dirty flags for tiles and entities
instead, just ungate this and allow the provider to decide what to do.
Any chunk that contains entities or tiles is already always considered dirty, so the only thing the flags are good for is flagging chunks that previously had tiles and/or entities but no longer do.
In those cases, it's just removing keys from LevelDB anyway, so it's already very cheap.
Avoiding these redundant deletions is not worth the extra complexity and fragility of relying on flags to track this stuff.
2021-08-30 00:09:36 +01:00
938e430b0f Convert Populator into an interface 2021-08-27 20:41:54 +01:00
6c1fec8a29 Tree: renamed generateChunkHeight to generateTrunkHeight
I guess it must have been late at night when I originally wrote this code.
2021-08-27 20:32:07 +01:00
beba0ffe15 Remove circular dependency between Tree and its children 2021-08-27 20:25:21 +01:00
4778c1483a Tree: fixed formatting error 2021-08-27 20:14:31 +01:00
8f89c04c51 Refactor Tree classes (#4407) 2021-08-27 20:11:05 +01:00
4189fbdaef Added StructureGrowEvent (#4354)
This event is currently fired for tree and bamboo growth. Its intended use is for any plant growth that affects multiple blocks at once.

TODO: We could explore using this for cacti and sugarcane?
2021-08-25 14:05:30 +01:00
772935cd7e Updated biome ID constants 2021-07-23 22:39:54 +01:00
654fc9a2a6 LegacyStringToItemParser: Throw more specific exceptions 2021-07-10 21:03:12 +01:00
02fab77e55 World: change 'closed' to 'unloaded'
this makes more sense overall from a reader's perspective.
and also provide a rug-jerk for any idiots using World->close() when they aren't supposed to? ....
2021-06-26 21:54:18 +01:00
dc5b1efa66 Merge remote-tracking branch 'origin/stable' 2021-04-15 14:04:27 +01:00
6ce15854af Clean up generator preset handling 2021-04-13 20:19:53 +01:00
eb9a68edee Further refactors to prepare for y=-64 lower limit 2021-03-18 00:08:16 +00:00
5a1131d72d Populator: require dependencies explicitly, don't make bad assumptions about fields
this also leaks ChunkManagers on the worker threads because the generator context is long-lived.
2021-01-27 21:08:46 +00:00
1de5fc86c4 PopulationTask: assume that generator has been initialized 2020-12-13 20:00:57 +00:00
5ba09b6a25 fix PopulationTask crash 2020-12-03 23:48:40 +00:00
b9cd633cee Chunks no longer exist in un-generated state
a non-generated chunk is now always represented by NULL. This forces the case of ungenerated chunks to be handled by all code, which is necessary because ungenerated chunks cannot be interacted with or modified in any meaningful way.
2020-12-03 22:28:43 +00:00
05ab44f768 PopulationTask no longer creates chunks if they don't exist
creating a throwaway empty chunk on the main thread is pointless.
2020-12-03 22:12:42 +00:00
c808095978 Chunks no longer contain their own coordinates 2020-12-03 21:59:30 +00:00
1f5998d24c FastChunkSerializer no longer encodes chunk coordinates
in cases like PopulationTask it makes more sense to store the coordinates separately where they can be stored more efficiently (once instead of 9 times)
In addition, PopulationTask shouldn't need to serialize an empty chunk just to copy coordinates.

I've made changes like this in other areas already in preparation for the day when chunks no longer contain their coordinates, so this brings us one step closer to that goal.
2020-12-03 20:52:33 +00:00
7edfa3713b Do not persist SimpleChunkManager between async tasks
this is just asking for memory leaks.
2020-12-03 19:46:23 +00:00
dde2e7e66f generation: drop AsyncWorker thread-local storage in favour of a more specialized storage 2020-12-03 19:28:22 +00:00
b7690fed04 BiomeSelector: replace phpdoc with typehints 2020-11-01 17:09:10 +00:00
4231bfdc7e Relocate biome ID constants to pocketmine\data\bedrock package 2020-11-01 16:53:06 +00:00
b176f4c12f Switch to BiomeRegistry
I accidentally committed this in c869a7f099 and didn't notice. I intended to use it and never noticed.
2020-11-01 16:47:13 +00:00
f991961d9a Generator no longer requires a ChunkManager to construct
this allows injection of arbitrary ChunkManagers into a single Generator instance.
The objective here was to remove the requirement to cache a SimpleChunkManager instance in worker-local storage, because that requires that the chunks it stores be manually removed to avoid memory leaks. However, there are some other obstacles, primarily the worldHeight which is not retained anywhere else.
2020-11-01 16:34:56 +00:00
1d551af54a Merge remote-tracking branch 'origin/stable'
# Conflicts:
#	resources/vanilla
#	src/pocketmine/level/Level.php
#	src/pocketmine/level/format/Chunk.php
#	tests/phpstan/configs/l7-baseline.neon
2020-11-01 15:58:16 +00:00
4549522289 Rename Chunk::getSubChunkChecked() -> getSubChunk() 2020-10-31 23:12:03 +00:00