79 Commits

Author SHA1 Message Date
Dylan K. Taylor
1b9c282194
LevelDB: tolerate incorrect number of biome palettes, as long as there are enough for each real subchunk
modern versions save 24 exactly, but previous versions saved more. We don't use the excess, so it's not a problem if they are missing, but this is nonetheless non-compliant with vanilla.
2023-07-19 16:29:14 +01:00
Dylan K. Taylor
82b75e0ccb
LevelDB: Remove happy debug message 2023-07-19 15:21:47 +01:00
Dylan K. Taylor
6c59912ed5
LevelDB: workaround 0 bpb palettes with a length prefix
this was caused by a plugin overriding the world provider.

related:
-  https://github.com/pmmp/PocketMine-MP/issues/5911
-  https://github.com/Refaltor77/CustomItemAPI/issues/68

fixes #5911
2023-07-19 15:19:33 +01:00
Dylan K. Taylor
8744032ab6
Fixed empty block handling after blockstate ID XOR change 2023-05-29 18:26:23 +01:00
Dylan K. Taylor
a49842278a
WorldProvider subsystem no longer depends on Chunk
Instead, it provides the data needed to construct the chunk, which doesn't require the provider to be aware of anywhere near as much logic.
2023-05-29 17:44:00 +01:00
Dylan K. Taylor
ce5e663a73
Assume chunks are dirty by default
having them be clean by default makes no sense. It only makes sense for them to be clean if they were loaded directly from disk without any alterations.

Default clean is a footgun.
2023-05-29 17:22:39 +01:00
Dylan K. Taylor
c10be0f346
WorldProvider: allow loadChunk() to return additional information about the loaded chunk data
this will be needed for dealing with #5733. I don't plan to fix that before 5.0, but we need to make the appropriate BC breaks now, before release.
2023-05-29 17:03:39 +01:00
Dylan K. Taylor
f5a1a0c9cb
ÂInsert PM data version into blockstates, chunks, entities, tiles and level.dat
this information will allow us to correct for any bugs introduced by past versions.

however, we still need to propagate this information to permit actually using it when loading data.
2023-05-29 16:32:24 +01:00
Dylan K. Taylor
5fcf5e0c40
LevelDB: log more stuff, stop bailing on recoverable errors 2023-05-02 16:46:45 +01:00
Dylan K. Taylor
f29e2f7110
WorldProviders now accept Loggers 2023-05-02 15:41:11 +01:00
Dylan K. Taylor
6cace51a21
Remove unused variable 2023-04-13 12:47:17 +01:00
Dylan K. Taylor
6703f46a08
Remove random dead TODOs 2023-04-13 12:47:08 +01:00
Dylan K. Taylor
c3a2199f0e
Reduce global usage in world providers 2023-04-13 12:05:37 +01:00
Dylan K. Taylor
7314151c47
LevelDB: code cleanup 2023-01-17 22:47:43 +00:00
Dylan K. Taylor
7abfc46567
First look at 3D biome support 2023-01-17 21:41:30 +00:00
Dylan K. Taylor
4d79aced07
Merge branch 'next-minor' into next-major 2022-12-15 19:50:27 +00:00
Dylan K. Taylor
99996b62d6
Align PhpDoc @param tags according to PHP-CS-Fixer 2022-12-06 13:21:20 +00:00
Dylan K. Taylor
01bad344a0
Merge branch 'next-minor' into next-major 2022-11-04 20:47:26 +00:00
Dylan K. Taylor
cdbdcb5d67
Merge branch 'stable' into next-minor 2022-11-04 20:44:28 +00:00
Dylan K. Taylor
2fdc46c165
PHPStan 1.9 features 2022-11-04 20:23:34 +00:00
Dylan K. Taylor
7bcc663b60
Migrate core code to using symfony/filesystem
webmozart/path-util is retained for plugin compatibility, but is dropped in 5.0
2022-10-14 21:51:29 +01:00
Dylan K. Taylor
f88ae93897
BC break: Replaced webmozart/path-util with symfony/filesystem, closes #5332 2022-10-13 16:43:36 +01:00
Dylan K. Taylor
bedf79e2cd
BaseWorldProvider: don't crash the server when encountering an unknown block 2022-07-21 16:12:27 +01:00
Dylan K. Taylor
ccb3c3cb05
BlockStateData: use array<Tag> instead of CompoundTag to store state properties
this reduces the footprint of RuntimeBlockMapping by a further 1 MB, as well as simplifying various parts of the code, and solidifying the immutability guarantee of BlockStateData.
2022-07-09 16:03:51 +01:00
Dylan K. Taylor
f24f2d9ca9
Hit block legacy metadata with the biggest nuke you've ever seen
This commit completely revamps the way that blocks are represented in memory at runtime.

Instead of being represented by legacy Mojang block IDs and metadata, which are dated, limited and unchangeable, we now use custom PM block IDs, which are generated from VanillaBlocks.
This means we have full control of how they are assigned, which opens the doors to finally addressing inconsistencies like glazed terracotta, stripped logs handling, etc.

To represent state, BlockDataReader and BlockDataWriter have been introduced, and are used by blocks with state information to pack said information into a binary form that can be stored on a chunk at runtime.
Conceptually it's pretty similar to legacy metadata, but the actual format shares no resemblance whatsoever to legacy metadata, and is fully controlled by PM.
This means that the 'state data' may change in serialization format at any time, so it should **NOT** be stored on disk or in a config.

In the future, this will be improved using more auto-generated code and attributes, instead of hand-baked decodeState() and encodeState(). For now, this opens the gateway to a significant expansion of features.
It's not ideal, but it's a big step forwards.
2022-06-24 23:19:37 +01:00
Dylan K. Taylor
1533fcf8f6
Separate block legacy data upgrading from block deserialization
this commit provides a central place where all block data can go to be upgraded to the latest version (currently 1.19), irrespective of how old it is.

Previously I had issues during debugging, because it wasn't possible to just upgrade a block without deserializing it into a Block object, which isn't currently supported for many blocks.
This commit solves that problem by separating the upgrading from the deserialization.
2022-06-23 16:45:02 +01:00
Dylan K. Taylor
680615eed8
Namespace rename 2022-06-08 15:54:45 +01:00
Dylan K. Taylor
1ff69136a3
Merge branch 'next-major' into modern-world-support 2022-06-07 20:01:40 +01:00
Dylan K. Taylor
aa9f8781ff
Merge branch 'next-minor' into next-major 2022-06-07 19:56:26 +01:00
Dylan K. Taylor
5c85aa6e58
Eliminate remaining usages of legacy block ID+meta on disk
flower pots loaded from vanilla worlds should now correctly display the plant inside
2022-06-05 21:49:51 +01:00
Dylan K. Taylor
5a43db1c6d
LevelDB: remove stale TODO comment
this has been addressed by folding to state 0 in the legacy blockstate mapper.
2022-06-04 18:47:29 +01:00
Dylan K. Taylor
dab7686656
Merge branch 'next-major' into modern-world-support 2022-06-04 18:43:11 +01:00
Dylan K. Taylor
083a35f970
Modernize property type declarations 2022-06-04 18:16:32 +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
43e61336cf
Support 1.18.30 worlds 2022-04-20 14:58:32 +01:00
Dylan K. Taylor
eafbc3a468
Expand height range to include -64 to 320 2022-04-15 19:10:24 +01:00
Dylan K. Taylor
993adc8c82
LevelDB: remove deprecated constants
there's no point pretending we can maintain BC on this now
2022-03-24 12:59:45 +00:00
Dylan K. Taylor
e58b3ba46c
First look at loading 1.13+ worlds 2022-02-07 03:06:59 +00:00
Dylan K. Taylor
c19a038d47
LevelDB: Added a whole bunch of constants 2022-02-07 00:54:00 +00:00
Dylan K. Taylor
7ddd547190
Merge remote-tracking branch 'origin/stable' into staging/4.1 2022-02-06 23:55:52 +00:00
Dylan K. Taylor
7846ea8acc
LevelDB: do not barf on chunk version 8
this covers a wide range from 1.2.13 to 1.8.
2022-02-05 04:18:37 +00:00
Dylan K. Taylor
aae5962f6a
Replace disallowed operators in src/world/ 2022-01-20 19:05:23 +00:00
Dylan K. Taylor
1a046c6cd5
LevelDB: fixed server crash when corrupted / invalid blockstate NBT is encountered 2021-12-04 18:17:17 +00:00
Dylan K. Taylor
e61aaaccca
LevelDB: removed hack for problem fixed by 1f9400f9011546ab914090853069aaa76192a722 2021-12-04 16:20:57 +00:00
Dylan K. Taylor
c6c992a1f0
Preparations for negative Y support 2021-11-08 17:28:22 +00: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
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
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
6cf181b579
LevelDB: Use arrow functions for better readability 2021-09-16 14:44:56 +01:00