Commit Graph

943 Commits

Author SHA1 Message Date
Dylan K. Taylor
d73ea8efe4 FlatGeneratorOptions: Do not hardcode biome ID 2021-10-11 21:32:20 +01:00
Dylan K. Taylor
8fd475f87b WorldManager: Check generator options of worlds before loading them, too 2021-10-11 17:44:38 +01:00
Dylan K. Taylor
34f54750c8 Added support for creation-time validation of generator options, closes #2717 2021-10-11 17:37:47 +01:00
Dylan K. Taylor
092aabeb97 fix CS 2021-10-11 17:21:19 +01:00
Dylan K. Taylor
70deea0ef9 Flat: Move preset handling to a FlatGeneratorOptions unit 2021-10-11 16:53:08 +01:00
Dylan K. Taylor
859cdfa5d2 GeneratorManager: removed unused parameter from getGenerator() 2021-10-11 16:18:38 +01:00
Dylan K. Taylor
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
Dylan K. Taylor
308d7c126a Fixed world data ::generate() functions putting level.dat in the wrong place if the world path didn't end with a / 2021-10-08 23:39:25 +01:00
Dylan K. Taylor
d63b9d1648 WorldManager: localize strings for world loading, generation and conversion 2021-10-02 20:33:32 +01:00
Dylan K. Taylor
f5266ec816 World: remove dead code leftover from 34f01a3ce3
fixes #4486
2021-10-02 12:33:46 +01:00
Dylan K. Taylor
c7e9138994 PopulationTask: reduce code duplication 2021-10-01 23:18:56 +01:00
Dylan K. Taylor
88f799da2c more AssumptionFailedError hacks for PHPStan :(
the code in this class is really horrible
2021-10-01 23:05:48 +01:00
Dylan K. Taylor
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
Dylan K. Taylor
e6f6a036ef LightPopulationTask: do not copy existing light arrays
this task wipes out the light arrays and recalculates them from scratch, so it's pointless to copy any preexisting light arrays anyway.
2021-10-01 22:34:11 +01:00
Dylan K. Taylor
5b818827db Chunk: stop exposing SplFixedArray<SubChunk> to the API
this fixes a large number of PHPStan errors, and also brings us a step closer to negative-build-height readiness.
2021-10-01 22:17:28 +01:00
Dylan K. Taylor
42bf9578ce Remove unused constants 2021-10-01 22:05:03 +01:00
Dylan K. Taylor
6cf181b579 LevelDB: Use arrow functions for better readability 2021-09-16 14:44:56 +01:00
Dylan K. Taylor
ace8841d5d Explosion: allow the normal blockupdate mechanism to deal with explosions
in PM4, all blockupdates are buffered, so the old 7x performance penalty that used to be incurred by doing this is no longer a problem.
Also, this actually reduces the overhead of explosions themselves by moving the onNearbyBlockChange() burden off explodeB() and into the main world ticking function.
2021-09-12 15:45:02 +01:00
Dylan K. Taylor
5ddd94b7e8 Remove redundant World->isChunkGenerated() calls
isChunkGenerated() merely checks if the chunk can be loaded from disk, if it's not in the runtime cache already.
This is pointless in all of these cases, because the check is prefaced by an isChunkLoaded() check, which already limits the possibility anyway. If the chunk is not generated, it'll also be considered not loaded.
2021-09-12 15:21:09 +01:00
Dylan K. Taylor
f0fa561c2f World: use arrow functions in useBreakOn() 2021-09-12 15:16:55 +01:00
Dylan T
4111d92b98 Stop hardcoding chunk dimensions everywhere (#4443) 2021-09-10 16:13:25 +01:00
Dylan K. Taylor
9d5a86fe53 Revert "World: make the second parameter for getCollidingEntities() mandatory and non-nullable"
This reverts commit e1b7bf31bb.

fixes #4447
2021-09-10 16:06:08 +01:00
Dylan K. Taylor
334bf1277d BlockTransaction: Return failure if no blocks were changed
fixes #2813
2021-09-10 00:32:46 +01:00
Dylan K. Taylor
e0e19c67ef World: do not warn about leaked Player entities during world unload
this raises false-positives during shutdown if players were online.
The fact that the player entity leans on the World to clean up after it is slightly problematic, but I'm not sure what else to do about it for now.
2021-09-09 15:55:37 +01:00
Dylan K. Taylor
34f01a3ce3 World: Track entities separately from chunks
this allows entities to exist outside of generated chunks, with one caveat: they won't be saved in such cases.
Obviously, for player entities, this doesn't matter.

fixes #3947
2021-09-09 01:17:41 +01:00
Dylan K. Taylor
ba2bfe0e11 World: depopulate neighbourBlockUpdateQueueIndex sooner
this fixes 2 problems:
1) Blocks which set themselves to something else during onNearbyBlockChange() would not receive any block update
2) A memory leak when blocks in unloaded chunks were scheduled for an update.

I'm a little uneasy about this change, because there must have been some reason why I put this at the end of the block and not at the start, but whatever it is, I can't reason about it, and there's reasons not to put it at the end too.
2021-09-08 22:11:17 +01:00
Dylan K. Taylor
bc6e73e81d SubChunk: fixed light array GC since native LightArray introduction
since this went native, there was no support for copy-on-write, so this was only lazy-inited, but never cleaned if the array remained empty.
2021-09-07 22:54:54 +01:00
Dylan K. Taylor
11d2e1ef08 Require ext-chunkutils ^0.3.0 2021-09-07 22:53:50 +01:00
Dylan K. Taylor
72fb49b356 World: add notifyNeighbourBlockUpdate() to allow triggering neighbour block updates on blocks manually
this can be useful if blocks were modified asynchronously.
2021-09-07 20:18:53 +01:00
Dylan K. Taylor
e1b7bf31bb World: make the second parameter for getCollidingEntities() mandatory and non-nullable
the only reason to use getCollidingEntities() instead of getNearbyEntities() is if you have an entity that may or may not be collidable depending on certain conditions.
Really, I don't think this logic belongs in World at all, but for now it has to stay, because some other stuff depends on it.
2021-09-05 15:22:12 +01:00
Dylan K. Taylor
2fc33d3bff World: remove unused variable 2021-09-05 15:15:48 +01:00
Dylan K. Taylor
19513c65f0 World: avoid code duplication between getCollidingEntities() and getNearbyEntities()
these two methods are very misleadingly named, but they do almost exactly the same thing - the only difference is that getCollidingEntities() does a couple of additional checks.
2021-09-05 15:13:22 +01:00
Dylan K. Taylor
2fe03757d5 PopulationTask: fixed PHPStan errors 2021-08-30 00:26:54 +01:00
Dylan K. Taylor
e0d6357eb7 OreType: use promoted constructo properties 2021-08-30 00:18:34 +01:00
Dylan K. Taylor
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
Dylan K. Taylor
994a2c9eb9 Clean up entity/tile data loading from world providers 2021-08-29 23:11:18 +01:00
Dylan K. Taylor
938e430b0f Convert Populator into an interface 2021-08-27 20:41:54 +01:00
Dylan K. Taylor
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
Dylan K. Taylor
beba0ffe15 Remove circular dependency between Tree and its children 2021-08-27 20:25:21 +01:00
Dylan K. Taylor
4778c1483a Tree: fixed formatting error 2021-08-27 20:14:31 +01:00
Colin
8f89c04c51 Refactor Tree classes (#4407) 2021-08-27 20:11:05 +01:00
marshall
ee16a00c57 World: do not attempt placement of itemblock if stack size is zero (#4410)
This doesn't make any sense, and also caused a crash.
2021-08-27 13:14:56 +01:00
Colin
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
Colin
224d71f272 World: renamed getChunks() to getLoadedChunks() (#4393) 2021-08-23 21:23:35 +01:00
SalmonDE
7fd712c1ff Refactor Block & Tile: getPos() to getPosition() (#4395)
this also changes the name of the class property 'pos' to 'position' as well as Block->getPosOffset() to Block->getPositionOffset()
2021-08-23 14:01:32 +01:00
Dylan K. Taylor
270ee5c085 Simplify registry method generation 2021-08-22 23:02:36 +01:00
Dylan K. Taylor
7d9f8ff4ed World: do not use static:: for private property access 2021-08-21 15:46:19 +01:00
Dylan K. Taylor
8b9d7d6390 Support for nested TranslationContainers 2021-08-14 20:57:13 +01:00
Dylan K. Taylor
2293bd948d Added KnownTranslationFactory and use it in as many places as possible
this makes translation usage much more statically analysable.
The only places this isn't used are:
- places that prefix translations with colours (those are still a problem)
- places where server/client translations don't match (e.g. gameMode.changed accepts different parameters in vanilla than in PM)
2021-08-10 14:50:40 +01:00
Dylan K. Taylor
91cb374220 LevelDB: fixed isPopulated state getting lost after chunk unload/reload 2021-08-08 16:01:45 +01:00