Commit Graph

25 Commits

Author SHA1 Message Date
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
7abfc46567 First look at 3D biome support 2023-01-17 21:41:30 +00:00
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
1ff69136a3 Merge branch 'next-major' into modern-world-support 2022-06-07 20:01:40 +01:00
38d6284671 Use PHP-CS-Fixer to enforce file header presence 2022-06-04 17:34:49 +01:00
e58b3ba46c First look at loading 1.13+ worlds 2022-02-07 03:06:59 +00:00
d8f0fd0a7e McRegion: skip chunks with TerrainGenerated=false
legacy PM used to save even ungenerated chunks, and omitted some tags when doing so which we expect to always be present.
2021-11-23 01:49:48 +00: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
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
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
994a2c9eb9 Clean up entity/tile data loading from world providers 2021-08-29 23:11:18 +01:00
61c59be299 Replace hardcoded block metadata shifts and masks with constants
we might want to make these bigger than 4 bits in the future.
2021-06-16 12:48:09 +01:00
08f0c9a244 Separate writable parts of RegionWorldProvider into WritableRegionWorldProvider 2021-04-15 15:20:57 +01:00
eb9a68edee Further refactors to prepare for y=-64 lower limit 2021-03-18 00:08:16 +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
c808095978 Chunks no longer contain their own coordinates 2020-12-03 21:59:30 +00:00
0cbc5c9a4a region: harden handling of ByteArrayTag
previously this would just explode if the wrong length of data was given.
2020-10-31 15:37:06 +00:00
279abb871d Remove all usages of CompoundTag->hasTag()
in pretty much every case, these usages really wanted to read the tag's contents anyway, which can be combined with a getTag() and instanceof call for more concise and static analysis friendly code.
In the few cases where the tag contents wasn't needed, it still wanted to check the type, which, again, can be done in a more static analysis friendly way by just using getTag() and instanceof.
2020-07-10 21:01:43 +01:00
0188323d74 fixed a bunch of NBT-related phpstan level 8 errors 2020-07-05 21:01:13 +01:00
506f98efc4 Eliminate usages of BaseNbtSerializer->readCompressed() and BaseNbtSerializer->writeCompressed() 2020-06-17 14:31:56 +01:00
82d361d75f extract a BiomeArray unit from Chunk
this now also properly validates data read from disk.
2020-05-16 17:36:22 +01:00
67bcc1c0fb phpdoc armageddon for master, pass 1 2020-01-22 11:55:03 +00:00
c36377ea5a Merge branch 'next-minor' 2019-12-12 19:47:12 +00:00
3fa628f259 updated NBT dependency 2019-12-09 11:26:43 +00:00
5499ac620c Removed pocketmine subdirectory, map PSR-4 style 2019-07-30 19:14:57 +01:00