908 Commits

Author SHA1 Message Date
Dylan K. Taylor
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
Dylan K. Taylor
94f4ef5862
PopulationTask: Throw AssumptionFailedError if center chunk is null for some reason 2021-10-25 21:07:03 +01:00
Dylan K. Taylor
2e2515354c
PopulationTask: fixed undefined method call
fuck you PhpStorm! fuck you PhpStorm! fuck you PhpStorm!
2021-10-25 20:57:43 +01:00
Dylan K. Taylor
359d0835f3
CS 2021-10-25 20:54:39 +01:00
Dylan K. Taylor
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
Dylan K. Taylor
a5418a019d
Chunk: added modification counter
this is independent from the terrain dirty flags (which are specifically used to track state of chunks needing to be saved).
2021-10-25 20:53:11 +01:00
Dylan K. Taylor
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
Dylan K. Taylor
d53347454b
Chunk: use HeightArray::fill() 2021-10-25 20:17:30 +01:00
Dylan K. Taylor
401e8d117b
Flat: use a less dumb way to build biome array 2021-10-25 20:15:33 +01:00
Dylan K. Taylor
9835d75f65
Chunk: removed heighArray parameter from constructor
we don't pass this anywhere, and really it should be dynamically initialized anyway, just like light.
2021-10-25 20:13:50 +01:00
Dylan K. Taylor
b8519d1af4
World: fixed every chunk having terrain saved at least once, even if unmodified
setPopulated() sets dirty flags on the chunk, causing the autosave sweep
to think they've been changed when they haven't. We now pass
terrainPopulated to the constructor to avoid this ambiguity recurring in
the future.
2021-10-25 19:53:47 +01:00
Dylan K. Taylor
04aedc6494
Updated BedrockProtocol 2021-10-23 23:54:49 +01:00
Dylan K. Taylor
701a71a4ee
Sound::encode() position is no longer nullable
making this nullable was based on the invalid assumption that global sounds have no position, but it turns out they _do_ still use the position to make the sound come from the correct direction.
2021-10-23 02:01:26 +01:00
Dylan K. Taylor
c77829f4ad
Migrate packet creation to use ::create() methods in all but one case
MovePlayerPacket doesn't yet have a ::create() due to a complication with fields that aren't always present.
2021-10-23 01:46:01 +01:00
Dylan K. Taylor
c773e43eda
Updated BedrockProtocol to pmmp/BedrockProtocol@97fa88e9ef 2021-10-23 01:16:45 +01:00
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 34f01a3ce3c02f41cfebfc81d34b755cfed62811
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 e1b7bf31bbbf8a0c679bdf238cf7594881d0842b.

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