mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-20 07:39:42 +00:00
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.
This commit is contained in:
@@ -25,7 +25,6 @@ namespace pocketmine\world\format\io;
|
||||
|
||||
use pocketmine\data\bedrock\block\BlockStateData;
|
||||
use pocketmine\data\bedrock\block\BlockTypeNames;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\world\format\io\exception\CorruptedWorldException;
|
||||
use pocketmine\world\format\io\exception\UnsupportedWorldFormatException;
|
||||
use pocketmine\world\format\PalettedBlockArray;
|
||||
@@ -63,7 +62,7 @@ abstract class BaseWorldProvider implements WorldProvider{
|
||||
$newStateData = $blockDataUpgrader->upgradeIntIdMeta($legacyIdMeta >> 4, $legacyIdMeta & 0xf);
|
||||
if($newStateData === null){
|
||||
//TODO: remember data for unknown states so we can implement them later
|
||||
$newStateData = new BlockStateData(BlockTypeNames::INFO_UPDATE, CompoundTag::create(), BlockStateData::CURRENT_VERSION);
|
||||
$newStateData = new BlockStateData(BlockTypeNames::INFO_UPDATE, [], BlockStateData::CURRENT_VERSION);
|
||||
}
|
||||
|
||||
$newPalette[$k] = $blockStateDeserializer->deserialize($newStateData);
|
||||
|
@@ -180,7 +180,7 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{
|
||||
//TODO: remember data for unknown states so we can implement them later
|
||||
//TODO: this is slow; we need to cache this
|
||||
//TODO: log this
|
||||
$palette[] = $blockStateDeserializer->deserialize(new BlockStateData(BlockTypeNames::INFO_UPDATE, CompoundTag::create(), BlockStateData::CURRENT_VERSION));
|
||||
$palette[] = $blockStateDeserializer->deserialize(new BlockStateData(BlockTypeNames::INFO_UPDATE, [], BlockStateData::CURRENT_VERSION));
|
||||
}
|
||||
}catch(NbtException | BlockStateDeserializeException $e){
|
||||
throw new CorruptedChunkException("Invalid blockstate NBT at offset $i in paletted storage: " . $e->getMessage(), 0, $e);
|
||||
|
Reference in New Issue
Block a user