diff --git a/src/data/bedrock/block/BlockStateData.php b/src/data/bedrock/block/BlockStateData.php index 00240832d..ec62fa67e 100644 --- a/src/data/bedrock/block/BlockStateData.php +++ b/src/data/bedrock/block/BlockStateData.php @@ -111,7 +111,10 @@ final class BlockStateData{ return new self($name, $states->getValue(), $version); } - public function toNbt() : CompoundTag{ + /** + * Encodes the blockstate as a TAG_Compound, exactly as it would be in vanilla Bedrock. + */ + public function toVanillaNbt() : CompoundTag{ $statesTag = CompoundTag::create(); foreach(Utils::stringifyKeys($this->states) as $key => $value){ $statesTag->setTag($key, $value); @@ -119,7 +122,15 @@ final class BlockStateData{ return CompoundTag::create() ->setString(self::TAG_NAME, $this->name) ->setInt(self::TAG_VERSION, $this->version) - ->setTag(self::TAG_STATES, $statesTag) + ->setTag(self::TAG_STATES, $statesTag); + } + + /** + * Encodes the blockstate as a TAG_Compound, but with extra PM-specific metadata, used for fixing bugs in old saved + * data. This should be used for anything saved to disk. + */ + public function toNbt() : CompoundTag{ + return $this->toVanillaNbt() ->setLong(VersionInfo::TAG_WORLD_DATA_VERSION, VersionInfo::WORLD_DATA_VERSION); }