Fixed deserializer not handling walls properly

This commit is contained in:
Dylan K. Taylor 2022-02-01 04:01:56 +00:00
parent dbe99e5821
commit 7d70865db0
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
2 changed files with 22 additions and 1 deletions

View File

@ -194,7 +194,7 @@ final class BlockStateDeserializer{
$this->map(Ids::COAL_BLOCK, fn() => VanillaBlocks::COAL());
$this->map(Ids::COAL_ORE, fn() => VanillaBlocks::COAL_ORE());
$this->map(Ids::COBBLESTONE, fn() => VanillaBlocks::COBBLESTONE());
$this->map(Ids::COBBLESTONE_WALL, fn(BlockStateReader $in) => Helper::decodeWall(VanillaBlocks::COBBLESTONE_WALL(), $in));
$this->map(Ids::COBBLESTONE_WALL, fn(BlockStateReader $in) => Helper::mapLegacyWallType($in));
$this->map(Ids::COCOA, function(BlockStateReader $in) : Block{
return VanillaBlocks::COCOA_POD()
->setAge($in->readBoundedInt(BlockStateNames::AGE, 0, 2))

View File

@ -215,6 +215,27 @@ final class BlockStateDeserializerHelper{
->setOutputSignalStrength($in->readBoundedInt(BlockStateNames::REDSTONE_SIGNAL, 0, 15));
}
/** @throws BlockStateDeserializeException */
public static function mapLegacyWallType(BlockStateReader $in) : Wall{
return self::decodeWall(match($type = $in->readString(BlockStateNames::WALL_BLOCK_TYPE)){
StringValues::WALL_BLOCK_TYPE_ANDESITE => VanillaBlocks::ANDESITE_WALL(),
StringValues::WALL_BLOCK_TYPE_BRICK => VanillaBlocks::BRICK_WALL(),
StringValues::WALL_BLOCK_TYPE_COBBLESTONE => VanillaBlocks::COBBLESTONE_WALL(),
StringValues::WALL_BLOCK_TYPE_DIORITE => VanillaBlocks::DIORITE_WALL(),
StringValues::WALL_BLOCK_TYPE_END_BRICK => VanillaBlocks::END_STONE_BRICK_WALL(),
StringValues::WALL_BLOCK_TYPE_GRANITE => VanillaBlocks::GRANITE_WALL(),
StringValues::WALL_BLOCK_TYPE_MOSSY_COBBLESTONE => VanillaBlocks::MOSSY_COBBLESTONE_WALL(),
StringValues::WALL_BLOCK_TYPE_MOSSY_STONE_BRICK => VanillaBlocks::MOSSY_STONE_BRICK_WALL(),
StringValues::WALL_BLOCK_TYPE_NETHER_BRICK => VanillaBlocks::NETHER_BRICK_WALL(),
StringValues::WALL_BLOCK_TYPE_PRISMARINE => VanillaBlocks::PRISMARINE_WALL(),
StringValues::WALL_BLOCK_TYPE_RED_NETHER_BRICK => VanillaBlocks::RED_NETHER_BRICK_WALL(),
StringValues::WALL_BLOCK_TYPE_RED_SANDSTONE => VanillaBlocks::RED_SANDSTONE_WALL(),
StringValues::WALL_BLOCK_TYPE_SANDSTONE => VanillaBlocks::SANDSTONE_WALL(),
StringValues::WALL_BLOCK_TYPE_STONE_BRICK => VanillaBlocks::STONE_BRICK_WALL(),
default => throw $in->badValueException(BlockStateNames::WALL_BLOCK_TYPE, $type),
}, $in);
}
/** @throws BlockStateDeserializeException */
public static function mapStoneSlab1Type(BlockStateReader $in) : Slab{
//* stone_slab_type (StringTag) = brick, cobblestone, nether_brick, quartz, sandstone, smooth_stone, stone_brick, wood