177 Commits

Author SHA1 Message Date
Dylan K. Taylor
c13170a00b
Avoid implicit integer cast in Normal::pickBiome()
this throws deprecation warnings on PHP 8.1.
2022-08-20 17:16:38 +01:00
Dylan K. Taylor
38d6284671
Use PHP-CS-Fixer to enforce file header presence 2022-06-04 17:34:49 +01:00
Dylan K. Taylor
d4b7f66e15
Promote some constructors 2022-05-17 22:34:58 +01:00
Dylan K. Taylor
b88a47929f
Modernize property declarations in src/world/* 2022-04-28 15:06:17 +01:00
Dylan K. Taylor
159392e738
wtf is this shitbox code 2022-04-28 14:57:57 +01:00
Dylan K. Taylor
ed2a239334
Modernize property declarations in src/world/generator 2022-04-28 13:16:21 +01:00
Dylan K. Taylor
aae5962f6a
Replace disallowed operators in src/world/ 2022-01-20 19:05:23 +00:00
Dylan K. Taylor
6d249026cc
Merge branch 'legacy/pm3' into stable 2022-01-07 20:15:15 +00:00
Dylan K. Taylor
0a58fd5472
GeneratorManager: fixed addGenerator() being case-sensitive when overwrite=true
this was caused by 083a1e1ff6b6ff5c0c1ba14250d2b026af103b90.

This was discovered by a new PHPStan rule I'm working on, which disallows overwriting the values of parameter variables. During the refactor of this function to correct the error, another error appeared: Variable might not be defined.

This is yet another excellent example of why mutability is bad.
2021-12-12 21:58:07 +00:00
Dylan K. Taylor
269231c228
Ban foreach(arrayWithStringKeys as k => v)
this is not as good as phpstan/phpstan-src#769 (e.g. array_key_first()/array_key_last() aren't covered by this, nor is array_rand()) but it does eliminate the most infuriating cases where this usually crops up.
2021-11-15 22:52:05 +00:00
Dylan K. Taylor
0356716e8e
PopulationTask: do not expose internal fields as public
this code dates back to pthreads v2, when visibility on Threaded object fields meant different things (wtf, krakjoe??)
2021-11-03 15:23:43 +00:00
Dylan K. Taylor
5c81b04813
PopulationTask: use typed properties 2021-11-03 15:22:49 +00:00
Dylan K. Taylor
8b3565b75d
PopulationTask no longer depends on a World object
this means it's now possible to test generation offline without too much hassle.
World::generateChunkCallback() has been removed from public API.
2021-11-02 15:40:51 +00:00
Dylan K. Taylor
65ef9f786a
Use standard chunkHash() to index population chunks 2021-11-02 15:25:03 +00:00
Dylan T
0f78a2b5ef
Advisory chunk locking for chunk population (#4513)
this allows chunks locked for population to be modified. If the PopulationTask detects that the chunk was modified during the onCompletion(), the result of the population will be discarded and rescheduled, so that it includes user modifications.
2021-10-31 21:11:20 +00:00
Dylan K. Taylor
faad2365e2
World: Register a temporary chunk loader on chunks used by PopulationTask
fixes #3839
2021-10-30 22:17:06 +01:00
Dylan K. Taylor
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
Dylan K. Taylor
a62ce64fdd
Revert "Chunk: added modification counter"
This reverts commit a5418a019dc2a83210084632130db8ce06f529ea.

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
Dylan K. Taylor
51fbff204b
World: make PhpStorm understand return type of getAdjacentChunks() 2021-10-26 20:32:09 +01:00
Dylan K. Taylor
1873457840
PopulationTask: stop using dynamic properties 2021-10-26 20:21:58 +01:00
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
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
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
401e8d117b
Flat: use a less dumb way to build biome array 2021-10-25 20:15:33 +01:00
Dylan K. Taylor
d73ea8efe4
FlatGeneratorOptions: Do not hardcode biome ID 2021-10-11 21:32:20 +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
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 T
4111d92b98
Stop hardcoding chunk dimensions everywhere (#4443) 2021-09-10 16:13:25 +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
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
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
Dylan K. Taylor
772935cd7e
Updated biome ID constants 2021-07-23 22:39:54 +01:00
Dylan K. Taylor
654fc9a2a6
LegacyStringToItemParser: Throw more specific exceptions 2021-07-10 21:03:12 +01:00
Dylan K. Taylor
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
Dylan K. Taylor
dc5b1efa66
Merge remote-tracking branch 'origin/stable' 2021-04-15 14:04:27 +01:00
Dylan K. Taylor
6ce15854af
Clean up generator preset handling 2021-04-13 20:19:53 +01:00