diff --git a/src/data/bedrock/block/convert/BlockObjectToBlockStateSerializer.php b/src/data/bedrock/block/convert/BlockObjectToBlockStateSerializer.php index 71487e461..553f84ff0 100644 --- a/src/data/bedrock/block/convert/BlockObjectToBlockStateSerializer.php +++ b/src/data/bedrock/block/convert/BlockObjectToBlockStateSerializer.php @@ -176,6 +176,7 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ public function __construct(){ $this->registerCandleSerializers(); + $this->registerSimpleSerializers(); $this->registerSerializers(); } @@ -291,355 +292,41 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ })->writeBool(StateNames::LIT, $block->isLit())); } - private function registerSerializers() : void{ - $this->map(Blocks::ACACIA_BUTTON(), fn(WoodenButton $block) => Helper::encodeButton($block, new Writer(Ids::ACACIA_BUTTON))); - $this->map(Blocks::ACACIA_DOOR(), fn(WoodenDoor $block) => Helper::encodeDoor($block, new Writer(Ids::ACACIA_DOOR))); - $this->map(Blocks::ACACIA_FENCE(), fn() => Writer::create(Ids::FENCE) - ->writeString(StateNames::WOOD_TYPE, StringValues::WOOD_TYPE_ACACIA)); - $this->map(Blocks::ACACIA_FENCE_GATE(), fn(FenceGate $block) => Helper::encodeFenceGate($block, new Writer(Ids::ACACIA_FENCE_GATE))); - $this->map(Blocks::ACACIA_LEAVES(), fn(Leaves $block) => Helper::encodeLeaves2($block, StringValues::NEW_LEAF_TYPE_ACACIA)); - $this->map(Blocks::ACACIA_LOG(), fn(Wood $block) => Helper::encodeLog2($block, StringValues::NEW_LOG_TYPE_ACACIA, Ids::STRIPPED_ACACIA_LOG)); - $this->map(Blocks::ACACIA_PLANKS(), fn() => Writer::create(Ids::PLANKS) - ->writeString(StateNames::WOOD_TYPE, StringValues::WOOD_TYPE_ACACIA)); - $this->map(Blocks::ACACIA_PRESSURE_PLATE(), fn(WoodenPressurePlate $block) => Helper::encodeSimplePressurePlate($block, new Writer(Ids::ACACIA_PRESSURE_PLATE))); - $this->map(Blocks::ACACIA_SAPLING(), fn(Sapling $block) => Helper::encodeSapling($block, StringValues::SAPLING_TYPE_ACACIA)); - $this->map(Blocks::ACACIA_SIGN(), fn(FloorSign $block) => Helper::encodeFloorSign($block, new Writer(Ids::ACACIA_STANDING_SIGN))); - $this->map(Blocks::ACACIA_SLAB(), fn(Slab $block) => Helper::encodeWoodenSlab($block, StringValues::WOOD_TYPE_ACACIA)); - $this->map(Blocks::ACACIA_STAIRS(), fn(WoodenStairs $block) => Helper::encodeStairs($block, new Writer(Ids::ACACIA_STAIRS))); - $this->map(Blocks::ACACIA_TRAPDOOR(), fn(WoodenTrapdoor $block) => Helper::encodeTrapdoor($block, new Writer(Ids::ACACIA_TRAPDOOR))); - $this->map(Blocks::ACACIA_WALL_SIGN(), fn(WallSign $block) => Helper::encodeWallSign($block, new Writer(Ids::ACACIA_WALL_SIGN))); - $this->map(Blocks::ACACIA_WOOD(), fn(Wood $block) => Helper::encodeAllSidedLog($block)); - $this->map(Blocks::ACTIVATOR_RAIL(), function(ActivatorRail $block) : Writer{ - return Writer::create(Ids::ACTIVATOR_RAIL) - ->writeBool(StateNames::RAIL_DATA_BIT, $block->isPowered()) - ->writeInt(StateNames::RAIL_DIRECTION, $block->getShape()); - }); + private function registerSimpleSerializers() : void{ $this->mapSimple(Blocks::AIR(), Ids::AIR); - $this->map(Blocks::ALLIUM(), fn() => Helper::encodeRedFlower(StringValues::FLOWER_TYPE_ALLIUM)); - $this->map(Blocks::ALL_SIDED_MUSHROOM_STEM(), fn() => Writer::create(Ids::BROWN_MUSHROOM_BLOCK) - ->writeInt(StateNames::HUGE_MUSHROOM_BITS, BlockLegacyMetadata::MUSHROOM_BLOCK_ALL_STEM)); $this->mapSimple(Blocks::AMETHYST(), Ids::AMETHYST_BLOCK); $this->mapSimple(Blocks::ANCIENT_DEBRIS(), Ids::ANCIENT_DEBRIS); - $this->map(Blocks::ANDESITE(), fn() => Helper::encodeStone(StringValues::STONE_TYPE_ANDESITE)); - $this->map(Blocks::ANDESITE_SLAB(), fn(Slab $block) => Helper::encodeStoneSlab3($block, StringValues::STONE_SLAB_TYPE_3_ANDESITE)); - $this->map(Blocks::ANDESITE_STAIRS(), fn(Stair $block) => Helper::encodeStairs($block, new Writer(Ids::ANDESITE_STAIRS))); - $this->map(Blocks::ANDESITE_WALL(), fn(Wall $block) => Helper::encodeLegacyWall($block, StringValues::WALL_BLOCK_TYPE_ANDESITE)); - $this->map(Blocks::ANVIL(), function(Anvil $block) : Writer{ - return Writer::create(Ids::ANVIL) - ->writeLegacyHorizontalFacing($block->getFacing()) - ->writeString(StateNames::DAMAGE, match($damage = $block->getDamage()){ - 0 => StringValues::DAMAGE_UNDAMAGED, - 1 => StringValues::DAMAGE_SLIGHTLY_DAMAGED, - 2 => StringValues::DAMAGE_VERY_DAMAGED, - default => throw new BlockStateSerializeException("Invalid Anvil damage {$damage}"), - }); - }); - $this->map(Blocks::AZURE_BLUET(), fn() => Helper::encodeRedFlower(StringValues::FLOWER_TYPE_HOUSTONIA)); - $this->map(Blocks::BAMBOO(), function(Bamboo $block) : Writer{ - return Writer::create(Ids::BAMBOO) - ->writeBool(StateNames::AGE_BIT, $block->isReady()) - ->writeString(StateNames::BAMBOO_LEAF_SIZE, match($block->getLeafSize()){ - Bamboo::NO_LEAVES => StringValues::BAMBOO_LEAF_SIZE_NO_LEAVES, - Bamboo::SMALL_LEAVES => StringValues::BAMBOO_LEAF_SIZE_SMALL_LEAVES, - Bamboo::LARGE_LEAVES => StringValues::BAMBOO_LEAF_SIZE_LARGE_LEAVES, - default => throw new BlockStateSerializeException("Invalid Bamboo leaf thickness " . $block->getLeafSize()), - }) - ->writeString(StateNames::BAMBOO_STALK_THICKNESS, $block->isThick() ? StringValues::BAMBOO_STALK_THICKNESS_THICK : StringValues::BAMBOO_STALK_THICKNESS_THIN); - }); - $this->map(Blocks::BAMBOO_SAPLING(), function(BambooSapling $block) : Writer{ - return Writer::create(Ids::BAMBOO_SAPLING) - ->writeBool(StateNames::AGE_BIT, $block->isReady()) - - //TODO: bug in MCPE - ->writeString(StateNames::SAPLING_TYPE, StringValues::SAPLING_TYPE_OAK); - }); - $this->map(Blocks::BANNER(), function(FloorBanner $block) : Writer{ - return Writer::create(Ids::STANDING_BANNER) - ->writeInt(StateNames::GROUND_SIGN_DIRECTION, $block->getRotation()); - }); - $this->map(Blocks::BARREL(), function(Barrel $block) : Writer{ - return Writer::create(Ids::BARREL) - ->writeBool(StateNames::OPEN_BIT, $block->isOpen()) - ->writeFacingDirection($block->getFacing()); - }); $this->mapSimple(Blocks::BARRIER(), Ids::BARRIER); - $this->map(Blocks::BASALT(), function(SimplePillar $block) : Writer{ - return Writer::create(Ids::BASALT) - ->writePillarAxis($block->getAxis()); - }); $this->mapSimple(Blocks::BEACON(), Ids::BEACON); - $this->map(Blocks::BED(), function(Bed $block) : Writer{ - return Writer::create(Ids::BED) - ->writeBool(StateNames::HEAD_PIECE_BIT, $block->isHeadPart()) - ->writeBool(StateNames::OCCUPIED_BIT, $block->isOccupied()) - ->writeLegacyHorizontalFacing($block->getFacing()); - }); - $this->map(Blocks::BEDROCK(), function(Block $block) : Writer{ - return Writer::create(Ids::BEDROCK) - ->writeBool(StateNames::INFINIBURN_BIT, $block->burnsForever()); - }); - $this->map(Blocks::BEETROOTS(), fn(Beetroot $block) => Helper::encodeCrops($block, new Writer(Ids::BEETROOT))); - $this->map(Blocks::BELL(), function(Bell $block) : Writer{ - return Writer::create(Ids::BELL) - ->writeBellAttachmentType($block->getAttachmentType()) - ->writeBool(StateNames::TOGGLE_BIT, false) //we don't care about this; it's just to keep MCPE happy - ->writeLegacyHorizontalFacing($block->getFacing()); - - }); - $this->map(Blocks::BIRCH_BUTTON(), fn(WoodenButton $block) => Helper::encodeButton($block, new Writer(Ids::BIRCH_BUTTON))); - $this->map(Blocks::BIRCH_DOOR(), fn(WoodenDoor $block) => Helper::encodeDoor($block, new Writer(Ids::BIRCH_DOOR))); - $this->map(Blocks::BIRCH_FENCE(), fn() => Writer::create(Ids::FENCE) - ->writeString(StateNames::WOOD_TYPE, StringValues::WOOD_TYPE_BIRCH)); - $this->map(Blocks::BIRCH_FENCE_GATE(), fn(FenceGate $block) => Helper::encodeFenceGate($block, new Writer(Ids::BIRCH_FENCE_GATE))); - $this->map(Blocks::BIRCH_LEAVES(), fn(Leaves $block) => Helper::encodeLeaves1($block, StringValues::OLD_LEAF_TYPE_BIRCH)); - $this->map(Blocks::BIRCH_LOG(), fn(Wood $block) => Helper::encodeLog1($block, StringValues::OLD_LOG_TYPE_BIRCH, Ids::STRIPPED_BIRCH_LOG)); - $this->map(Blocks::BIRCH_PLANKS(), fn() => Writer::create(Ids::PLANKS) - ->writeString(StateNames::WOOD_TYPE, StringValues::WOOD_TYPE_BIRCH)); - $this->map(Blocks::BIRCH_PRESSURE_PLATE(), fn(WoodenPressurePlate $block) => Helper::encodeSimplePressurePlate($block, new Writer(Ids::BIRCH_PRESSURE_PLATE))); - $this->map(Blocks::BIRCH_SAPLING(), fn(Sapling $block) => Helper::encodeSapling($block, StringValues::SAPLING_TYPE_BIRCH)); - $this->map(Blocks::BIRCH_SIGN(), fn(FloorSign $block) => Helper::encodeFloorSign($block, new Writer(Ids::BIRCH_STANDING_SIGN))); - $this->map(Blocks::BIRCH_SLAB(), fn(Slab $block) => Helper::encodeWoodenSlab($block, StringValues::WOOD_TYPE_BIRCH)); - $this->mapStairs(Blocks::BIRCH_STAIRS(), Ids::BIRCH_STAIRS); - $this->map(Blocks::BIRCH_TRAPDOOR(), fn(WoodenTrapdoor $block) => Helper::encodeTrapdoor($block, new Writer(Ids::BIRCH_TRAPDOOR))); - $this->map(Blocks::BIRCH_WALL_SIGN(), fn(WallSign $block) => Helper::encodeWallSign($block, new Writer(Ids::BIRCH_WALL_SIGN))); - $this->map(Blocks::BIRCH_WOOD(), fn(Wood $block) => Helper::encodeAllSidedLog($block)); $this->mapSimple(Blocks::BLACKSTONE(), Ids::BLACKSTONE); - $this->mapSlab(Blocks::BLACKSTONE_SLAB(), Ids::BLACKSTONE_SLAB, Ids::BLACKSTONE_DOUBLE_SLAB); - $this->mapStairs(Blocks::BLACKSTONE_STAIRS(), Ids::BLACKSTONE_STAIRS); - $this->map(Blocks::BLACKSTONE_WALL(), fn(Wall $block) => Helper::encodeWall($block, new Writer(Ids::BLACKSTONE_WALL))); - $this->map(Blocks::BLAST_FURNACE(), fn(Furnace $block) => Helper::encodeFurnace($block, Ids::BLAST_FURNACE, Ids::LIT_BLAST_FURNACE)); $this->mapSimple(Blocks::BLUE_ICE(), Ids::BLUE_ICE); - $this->map(Blocks::BLUE_ORCHID(), fn() => Helper::encodeRedFlower(StringValues::FLOWER_TYPE_ORCHID)); - $this->map(Blocks::BLUE_TORCH(), fn(Torch $block) => Helper::encodeColoredTorch($block, false, Writer::create(Ids::COLORED_TORCH_BP))); - $this->map(Blocks::BONE_BLOCK(), function(BoneBlock $block) : Writer{ - return Writer::create(Ids::BONE_BLOCK) - ->writeInt(StateNames::DEPRECATED, 0) - ->writePillarAxis($block->getAxis()); - }); $this->mapSimple(Blocks::BOOKSHELF(), Ids::BOOKSHELF); - $this->map(Blocks::BREWING_STAND(), function(BrewingStand $block) : Writer{ - return Writer::create(Ids::BREWING_STAND) - ->writeBool(StateNames::BREWING_STAND_SLOT_A_BIT, $block->hasSlot(BrewingStandSlot::EAST())) - ->writeBool(StateNames::BREWING_STAND_SLOT_B_BIT, $block->hasSlot(BrewingStandSlot::SOUTHWEST())) - ->writeBool(StateNames::BREWING_STAND_SLOT_C_BIT, $block->hasSlot(BrewingStandSlot::NORTHWEST())); - }); $this->mapSimple(Blocks::BRICKS(), Ids::BRICK_BLOCK); - $this->map(Blocks::BRICK_SLAB(), fn(Slab $block) => Helper::encodeStoneSlab1($block, StringValues::STONE_SLAB_TYPE_BRICK)); - $this->mapStairs(Blocks::BRICK_STAIRS(), Ids::BRICK_STAIRS); - $this->map(Blocks::BRICK_WALL(), fn(Wall $block) => Helper::encodeLegacyWall($block, StringValues::WALL_BLOCK_TYPE_BRICK)); $this->mapSimple(Blocks::BROWN_MUSHROOM(), Ids::BROWN_MUSHROOM); - $this->map(Blocks::BROWN_MUSHROOM_BLOCK(), fn(BrownMushroomBlock $block) => Helper::encodeMushroomBlock($block, new Writer(Ids::BROWN_MUSHROOM_BLOCK))); - $this->map(Blocks::CACTUS(), function(Cactus $block) : Writer{ - return Writer::create(Ids::CACTUS) - ->writeInt(StateNames::AGE, $block->getAge()); - }); - $this->map(Blocks::CAKE(), function(Cake $block) : Writer{ - return Writer::create(Ids::CAKE) - ->writeInt(StateNames::BITE_COUNTER, $block->getBites()); - }); $this->mapSimple(Blocks::CALCITE(), Ids::CALCITE); - $this->map(Blocks::CARPET(), function(Carpet $block) : Writer{ - return Writer::create(Ids::CARPET) - ->writeColor($block->getColor()); - }); - $this->map(Blocks::CARROTS(), fn(Carrot $block) => Helper::encodeCrops($block, new Writer(Ids::CARROTS))); $this->mapSimple(Blocks::CARTOGRAPHY_TABLE(), Ids::CARTOGRAPHY_TABLE); - $this->map(Blocks::CARVED_PUMPKIN(), function(CarvedPumpkin $block) : Writer{ - return Writer::create(Ids::CARVED_PUMPKIN) - ->writeLegacyHorizontalFacing($block->getFacing()); - }); $this->mapSimple(Blocks::CHEMICAL_HEAT(), Ids::CHEMICAL_HEAT); - $this->map(Blocks::CHEST(), function(Chest $block) : Writer{ - return Writer::create(Ids::CHEST) - ->writeHorizontalFacing($block->getFacing()); - }); $this->mapSimple(Blocks::CHISELED_DEEPSLATE(), Ids::CHISELED_DEEPSLATE); $this->mapSimple(Blocks::CHISELED_NETHER_BRICKS(), Ids::CHISELED_NETHER_BRICKS); $this->mapSimple(Blocks::CHISELED_POLISHED_BLACKSTONE(), Ids::CHISELED_POLISHED_BLACKSTONE); - $this->map(Blocks::CHISELED_QUARTZ(), fn(SimplePillar $block) => Helper::encodeQuartz(StringValues::CHISEL_TYPE_CHISELED, $block->getAxis())); - $this->map(Blocks::CHISELED_RED_SANDSTONE(), fn() => Helper::encodeSandstone(Ids::RED_SANDSTONE, StringValues::SAND_STONE_TYPE_HEIROGLYPHS)); - $this->map(Blocks::CHISELED_SANDSTONE(), fn() => Helper::encodeSandstone(Ids::SANDSTONE, StringValues::SAND_STONE_TYPE_HEIROGLYPHS)); - $this->map(Blocks::CHISELED_STONE_BRICKS(), fn() => Helper::encodeStoneBricks(StringValues::STONE_BRICK_TYPE_CHISELED)); $this->mapSimple(Blocks::CLAY(), Ids::CLAY); $this->mapSimple(Blocks::COAL(), Ids::COAL_BLOCK); $this->mapSimple(Blocks::COAL_ORE(), Ids::COAL_ORE); $this->mapSimple(Blocks::COBBLED_DEEPSLATE(), Ids::COBBLED_DEEPSLATE); - $this->mapSlab(Blocks::COBBLED_DEEPSLATE_SLAB(), Ids::COBBLED_DEEPSLATE_SLAB, Ids::COBBLED_DEEPSLATE_DOUBLE_SLAB); - $this->mapStairs(Blocks::COBBLED_DEEPSLATE_STAIRS(), Ids::COBBLED_DEEPSLATE_STAIRS); - $this->map(Blocks::COBBLED_DEEPSLATE_WALL(), fn(Wall $block) => Helper::encodeWall($block, new Writer(Ids::COBBLED_DEEPSLATE_WALL))); $this->mapSimple(Blocks::COBBLESTONE(), Ids::COBBLESTONE); - $this->map(Blocks::COBBLESTONE_SLAB(), fn(Slab $block) => Helper::encodeStoneSlab1($block, StringValues::STONE_SLAB_TYPE_COBBLESTONE)); - $this->mapStairs(Blocks::COBBLESTONE_STAIRS(), Ids::STONE_STAIRS); - $this->map(Blocks::COBBLESTONE_WALL(), fn(Wall $block) => Helper::encodeLegacyWall($block, StringValues::WALL_BLOCK_TYPE_COBBLESTONE)); $this->mapSimple(Blocks::COBWEB(), Ids::WEB); - $this->map(Blocks::COPPER(), function(Copper $block) : Writer{ - $oxidation = $block->getOxidation(); - return new Writer($block->isWaxed() ? - Helper::selectCopperId($oxidation, Ids::WAXED_COPPER, Ids::WAXED_EXPOSED_COPPER, Ids::WAXED_WEATHERED_COPPER, Ids::WAXED_OXIDIZED_COPPER) : - Helper::selectCopperId($oxidation, Ids::COPPER_BLOCK, Ids::EXPOSED_COPPER, Ids::WEATHERED_COPPER, Ids::OXIDIZED_COPPER) - ); - }); - $this->map(Blocks::CUT_COPPER(), function(Copper $block) : Writer{ - $oxidation = $block->getOxidation(); - return new Writer($block->isWaxed() ? - Helper::selectCopperId($oxidation, Ids::WAXED_CUT_COPPER, Ids::WAXED_EXPOSED_CUT_COPPER, Ids::WAXED_WEATHERED_CUT_COPPER, Ids::WAXED_OXIDIZED_CUT_COPPER) : - Helper::selectCopperId($oxidation, Ids::CUT_COPPER, Ids::EXPOSED_CUT_COPPER, Ids::WEATHERED_CUT_COPPER, Ids::OXIDIZED_CUT_COPPER) - ); - }); - $this->map(Blocks::CUT_COPPER_SLAB(), function(CopperSlab $block) : Writer{ - $oxidation = $block->getOxidation(); - return Helper::encodeSlab( - $block, - ($block->isWaxed() ? - Helper::selectCopperId( - $oxidation, - Ids::WAXED_CUT_COPPER_SLAB, - Ids::WAXED_EXPOSED_CUT_COPPER_SLAB, - Ids::WAXED_WEATHERED_CUT_COPPER_SLAB, - Ids::WAXED_OXIDIZED_CUT_COPPER_SLAB - ) : - Helper::selectCopperId( - $oxidation, - Ids::CUT_COPPER_SLAB, - Ids::EXPOSED_CUT_COPPER_SLAB, - Ids::WEATHERED_CUT_COPPER_SLAB, - Ids::OXIDIZED_CUT_COPPER_SLAB - ) - ), - ($block->isWaxed() ? - Helper::selectCopperId( - $oxidation, - Ids::WAXED_DOUBLE_CUT_COPPER_SLAB, - Ids::WAXED_EXPOSED_DOUBLE_CUT_COPPER_SLAB, - Ids::WAXED_WEATHERED_DOUBLE_CUT_COPPER_SLAB, - Ids::WAXED_OXIDIZED_DOUBLE_CUT_COPPER_SLAB - ) : - Helper::selectCopperId( - $oxidation, - Ids::DOUBLE_CUT_COPPER_SLAB, - Ids::EXPOSED_DOUBLE_CUT_COPPER_SLAB, - Ids::WEATHERED_DOUBLE_CUT_COPPER_SLAB, - Ids::OXIDIZED_DOUBLE_CUT_COPPER_SLAB - ) - ) - ); - }); - $this->map(Blocks::CUT_COPPER_STAIRS(), function(CopperStairs $block) : Writer{ - $oxidation = $block->getOxidation(); - return Helper::encodeStairs( - $block, - new Writer($block->isWaxed() ? - Helper::selectCopperId( - $oxidation, - Ids::WAXED_CUT_COPPER_STAIRS, - Ids::WAXED_EXPOSED_CUT_COPPER_STAIRS, - Ids::WAXED_WEATHERED_CUT_COPPER_STAIRS, - Ids::WAXED_OXIDIZED_CUT_COPPER_STAIRS - ) : - Helper::selectCopperId( - $oxidation, - Ids::CUT_COPPER_STAIRS, - Ids::EXPOSED_CUT_COPPER_STAIRS, - Ids::WEATHERED_CUT_COPPER_STAIRS, - Ids::OXIDIZED_CUT_COPPER_STAIRS - ) - ) - ); - }); - $this->map(Blocks::COCOA_POD(), function(CocoaBlock $block) : Writer{ - return Writer::create(Ids::COCOA) - ->writeInt(StateNames::AGE, $block->getAge()) - ->writeLegacyHorizontalFacing(Facing::opposite($block->getFacing())); - }); - $this->map(Blocks::COMPOUND_CREATOR(), fn(ChemistryTable $block) => Helper::encodeChemistryTable($block, StringValues::CHEMISTRY_TABLE_TYPE_COMPOUND_CREATOR, new Writer(Ids::CHEMISTRY_TABLE))); - $this->map(Blocks::CONCRETE(), function(Concrete $block) : Writer{ - return Writer::create(Ids::CONCRETE) - ->writeColor($block->getColor()); - }); - $this->map(Blocks::CONCRETE_POWDER(), function(ConcretePowder $block) : Writer{ - return Writer::create(Ids::CONCRETE_POWDER) - ->writeColor($block->getColor()); - }); $this->mapSimple(Blocks::COPPER_ORE(), Ids::COPPER_ORE); - $this->map(Blocks::CORAL(), function(Coral $block) : Writer{ - return Writer::create(Ids::CORAL) - ->writeBool(StateNames::DEAD_BIT, $block->isDead()) - ->writeCoralType($block->getCoralType()); - }); - $this->map(Blocks::CORAL_BLOCK(), function(CoralBlock $block) : Writer{ - return Writer::create(Ids::CORAL_BLOCK) - ->writeBool(StateNames::DEAD_BIT, $block->isDead()) - ->writeCoralType($block->getCoralType()); - }); - $this->map(Blocks::CORAL_FAN(), function(FloorCoralFan $block) : Writer{ - return Writer::create($block->isDead() ? Ids::CORAL_FAN_DEAD : Ids::CORAL_FAN) - ->writeCoralType($block->getCoralType()) - ->writeInt(StateNames::CORAL_FAN_DIRECTION, match($axis = $block->getAxis()){ - Axis::X => 0, - Axis::Z => 1, - default => throw new BlockStateSerializeException("Invalid axis {$axis}"), - }); - }); - $this->map(Blocks::CORNFLOWER(), fn() => Helper::encodeRedFlower(StringValues::FLOWER_TYPE_CORNFLOWER)); $this->mapSimple(Blocks::CRACKED_DEEPSLATE_BRICKS(), Ids::CRACKED_DEEPSLATE_BRICKS); $this->mapSimple(Blocks::CRACKED_DEEPSLATE_TILES(), Ids::CRACKED_DEEPSLATE_TILES); $this->mapSimple(Blocks::CRACKED_NETHER_BRICKS(), Ids::CRACKED_NETHER_BRICKS); $this->mapSimple(Blocks::CRACKED_POLISHED_BLACKSTONE_BRICKS(), Ids::CRACKED_POLISHED_BLACKSTONE_BRICKS); - $this->map(Blocks::CRACKED_STONE_BRICKS(), fn() => Helper::encodeStoneBricks(StringValues::STONE_BRICK_TYPE_CRACKED)); $this->mapSimple(Blocks::CRAFTING_TABLE(), Ids::CRAFTING_TABLE); - $this->map(Blocks::CRIMSON_BUTTON(), fn(Button $block) => Helper::encodeButton($block, new Writer(Ids::CRIMSON_BUTTON))); - $this->map(Blocks::CRIMSON_DOOR(), fn(Door $block) => Helper::encodeDoor($block, new Writer(Ids::CRIMSON_DOOR))); $this->mapSimple(Blocks::CRIMSON_FENCE(), Ids::CRIMSON_FENCE); - $this->map(Blocks::CRIMSON_FENCE_GATE(), fn(FenceGate $block) => Helper::encodeFenceGate($block, new Writer(Ids::CRIMSON_FENCE_GATE))); - $this->map(Blocks::CRIMSON_HYPHAE(), fn(Wood $block) => Helper::encodeNewLog($block, Ids::CRIMSON_HYPHAE, Ids::STRIPPED_CRIMSON_HYPHAE)); $this->mapSimple(Blocks::CRIMSON_PLANKS(), Ids::CRIMSON_PLANKS); - $this->map(Blocks::CRIMSON_PRESSURE_PLATE(), fn(SimplePressurePlate $block) => Helper::encodeSimplePressurePlate($block, new Writer(Ids::CRIMSON_PRESSURE_PLATE))); - $this->map(Blocks::CRIMSON_SIGN(), fn(FloorSign $block) => Helper::encodeFloorSign($block, new Writer(Ids::CRIMSON_STANDING_SIGN))); - $this->mapSlab(Blocks::CRIMSON_SLAB(), Ids::CRIMSON_SLAB, Ids::CRIMSON_DOUBLE_SLAB); - $this->mapStairs(Blocks::CRIMSON_STAIRS(), Ids::CRIMSON_STAIRS); - $this->map(Blocks::CRIMSON_STEM(), fn(Wood $block) => Helper::encodeNewLog($block, Ids::CRIMSON_STEM, Ids::STRIPPED_CRIMSON_STEM)); - $this->map(Blocks::CRIMSON_TRAPDOOR(), fn(Trapdoor $block) => Helper::encodeTrapdoor($block, new Writer(Ids::CRIMSON_TRAPDOOR))); - $this->map(Blocks::CRIMSON_WALL_SIGN(), fn(WallSign $block) => Helper::encodeWallSign($block, new Writer(Ids::CRIMSON_WALL_SIGN))); $this->mapSimple(Blocks::CRYING_OBSIDIAN(), Ids::CRYING_OBSIDIAN); - $this->map(Blocks::CUT_RED_SANDSTONE(), fn() => Helper::encodeSandstone(Ids::RED_SANDSTONE, StringValues::SAND_STONE_TYPE_CUT)); - $this->map(Blocks::CUT_RED_SANDSTONE_SLAB(), fn(Slab $block) => Helper::encodeStoneSlab4($block, StringValues::STONE_SLAB_TYPE_4_CUT_RED_SANDSTONE)); - $this->map(Blocks::CUT_SANDSTONE(), fn() => Helper::encodeSandstone(Ids::SANDSTONE, StringValues::SAND_STONE_TYPE_CUT)); - $this->map(Blocks::CUT_SANDSTONE_SLAB(), fn(Slab $block) => Helper::encodeStoneSlab4($block, StringValues::STONE_SLAB_TYPE_4_CUT_SANDSTONE)); $this->mapSimple(Blocks::DANDELION(), Ids::YELLOW_FLOWER); - $this->map(Blocks::DARK_OAK_BUTTON(), fn(WoodenButton $block) => Helper::encodeButton($block, new Writer(Ids::DARK_OAK_BUTTON))); - $this->map(Blocks::DARK_OAK_DOOR(), fn(WoodenDoor $block) => Helper::encodeDoor($block, new Writer(Ids::DARK_OAK_DOOR))); - $this->map(Blocks::DARK_OAK_FENCE(), fn() => Writer::create(Ids::FENCE) - ->writeString(StateNames::WOOD_TYPE, StringValues::WOOD_TYPE_DARK_OAK)); - $this->map(Blocks::DARK_OAK_FENCE_GATE(), fn(FenceGate $block) => Helper::encodeFenceGate($block, new Writer(Ids::DARK_OAK_FENCE_GATE))); - $this->map(Blocks::DARK_OAK_LEAVES(), fn(Leaves $block) => Helper::encodeLeaves2($block, StringValues::NEW_LEAF_TYPE_DARK_OAK)); - $this->map(Blocks::DARK_OAK_LOG(), fn(Wood $block) => Helper::encodeLog2($block, StringValues::NEW_LOG_TYPE_DARK_OAK, Ids::STRIPPED_DARK_OAK_LOG)); - $this->map(Blocks::DARK_OAK_PLANKS(), fn() => Writer::create(Ids::PLANKS) - ->writeString(StateNames::WOOD_TYPE, StringValues::WOOD_TYPE_DARK_OAK)); - $this->map(Blocks::DARK_OAK_PRESSURE_PLATE(), fn(WoodenPressurePlate $block) => Helper::encodeSimplePressurePlate($block, new Writer(Ids::DARK_OAK_PRESSURE_PLATE))); - $this->map(Blocks::DARK_OAK_SAPLING(), fn(Sapling $block) => Helper::encodeSapling($block, StringValues::SAPLING_TYPE_DARK_OAK)); - $this->map(Blocks::DARK_OAK_SIGN(), fn(FloorSign $block) => Helper::encodeFloorSign($block, new Writer(Ids::DARKOAK_STANDING_SIGN))); - $this->map(Blocks::DARK_OAK_SLAB(), fn(Slab $block) => Helper::encodeWoodenSlab($block, StringValues::WOOD_TYPE_DARK_OAK)); - $this->mapStairs(Blocks::DARK_OAK_STAIRS(), Ids::DARK_OAK_STAIRS); - $this->map(Blocks::DARK_OAK_TRAPDOOR(), fn(WoodenTrapdoor $block) => Helper::encodeTrapdoor($block, new Writer(Ids::DARK_OAK_TRAPDOOR))); - $this->map(Blocks::DARK_OAK_WALL_SIGN(), fn(WallSign $block) => Helper::encodeWallSign($block, new Writer(Ids::DARKOAK_WALL_SIGN))); - $this->map(Blocks::DARK_OAK_WOOD(), fn(Wood $block) => Helper::encodeAllSidedLog($block)); - $this->map(Blocks::DARK_PRISMARINE(), fn() => Writer::create(Ids::PRISMARINE) - ->writeString(StateNames::PRISMARINE_BLOCK_TYPE, StringValues::PRISMARINE_BLOCK_TYPE_DARK)); - $this->map(Blocks::DARK_PRISMARINE_SLAB(), fn(Slab $block) => Helper::encodeStoneSlab2($block, StringValues::STONE_SLAB_TYPE_2_PRISMARINE_DARK)); - $this->mapStairs(Blocks::DARK_PRISMARINE_STAIRS(), Ids::DARK_PRISMARINE_STAIRS); - $this->map(Blocks::DAYLIGHT_SENSOR(), function(DaylightSensor $block) : Writer{ - return Writer::create($block->isInverted() ? Ids::DAYLIGHT_DETECTOR_INVERTED : Ids::DAYLIGHT_DETECTOR) - ->writeInt(StateNames::REDSTONE_SIGNAL, $block->getOutputSignalStrength()); - }); $this->mapSimple(Blocks::DEAD_BUSH(), Ids::DEADBUSH); - $this->map(Blocks::DEEPSLATE(), function(SimplePillar $block) : Writer{ - return Writer::create(Ids::DEEPSLATE) - ->writePillarAxis($block->getAxis()); - }); $this->mapSimple(Blocks::DEEPSLATE_BRICKS(), Ids::DEEPSLATE_BRICKS); - $this->mapSlab(Blocks::DEEPSLATE_BRICK_SLAB(), Ids::DEEPSLATE_BRICK_SLAB, Ids::DEEPSLATE_BRICK_DOUBLE_SLAB); - $this->mapStairs(Blocks::DEEPSLATE_BRICK_STAIRS(), Ids::DEEPSLATE_BRICK_STAIRS); - $this->map(Blocks::DEEPSLATE_BRICK_WALL(), fn(Wall $block) => Helper::encodeWall($block, new Writer(Ids::DEEPSLATE_BRICK_WALL))); $this->mapSimple(Blocks::DEEPSLATE_COAL_ORE(), Ids::DEEPSLATE_COAL_ORE); $this->mapSimple(Blocks::DEEPSLATE_COPPER_ORE(), Ids::DEEPSLATE_COPPER_ORE); $this->mapSimple(Blocks::DEEPSLATE_DIAMOND_ORE(), Ids::DEEPSLATE_DIAMOND_ORE); @@ -647,33 +334,11 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ $this->mapSimple(Blocks::DEEPSLATE_GOLD_ORE(), Ids::DEEPSLATE_GOLD_ORE); $this->mapSimple(Blocks::DEEPSLATE_IRON_ORE(), Ids::DEEPSLATE_IRON_ORE); $this->mapSimple(Blocks::DEEPSLATE_LAPIS_LAZULI_ORE(), Ids::DEEPSLATE_LAPIS_ORE); - $this->map(Blocks::DEEPSLATE_REDSTONE_ORE(), fn(RedstoneOre $block) => new Writer($block->isLit() ? Ids::LIT_DEEPSLATE_REDSTONE_ORE : Ids::DEEPSLATE_REDSTONE_ORE)); $this->mapSimple(Blocks::DEEPSLATE_TILES(), Ids::DEEPSLATE_TILES); - $this->mapSlab(Blocks::DEEPSLATE_TILE_SLAB(), Ids::DEEPSLATE_TILE_SLAB, Ids::DEEPSLATE_TILE_DOUBLE_SLAB); - $this->mapStairs(Blocks::DEEPSLATE_TILE_STAIRS(), Ids::DEEPSLATE_TILE_STAIRS); - $this->map(Blocks::DEEPSLATE_TILE_WALL(), fn(Wall $block) => Helper::encodeWall($block, new Writer(Ids::DEEPSLATE_TILE_WALL))); - $this->map(Blocks::DETECTOR_RAIL(), function(DetectorRail $block) : Writer{ - return Writer::create(Ids::DETECTOR_RAIL) - ->writeBool(StateNames::RAIL_DATA_BIT, $block->isActivated()) - ->writeInt(StateNames::RAIL_DIRECTION, $block->getShape()); - }); $this->mapSimple(Blocks::DIAMOND(), Ids::DIAMOND_BLOCK); $this->mapSimple(Blocks::DIAMOND_ORE(), Ids::DIAMOND_ORE); - $this->map(Blocks::DIORITE(), fn() => Helper::encodeStone(StringValues::STONE_TYPE_DIORITE)); - $this->map(Blocks::DIORITE_SLAB(), fn(Slab $block) => Helper::encodeStoneSlab3($block, StringValues::STONE_SLAB_TYPE_3_DIORITE)); - $this->mapStairs(Blocks::DIORITE_STAIRS(), Ids::DIORITE_STAIRS); - $this->map(Blocks::DIORITE_WALL(), fn(Wall $block) => Helper::encodeLegacyWall($block, StringValues::WALL_BLOCK_TYPE_DIORITE)); - $this->map(Blocks::DIRT(), function(Dirt $block) : Writer{ - return Writer::create(Ids::DIRT) - ->writeString(StateNames::DIRT_TYPE, $block->isCoarse() ? StringValues::DIRT_TYPE_COARSE : StringValues::DIRT_TYPE_NORMAL); - }); - $this->map(Blocks::DOUBLE_TALLGRASS(), fn(DoubleTallGrass $block) => Helper::encodeDoublePlant($block, StringValues::DOUBLE_PLANT_TYPE_GRASS, Writer::create(Ids::DOUBLE_PLANT))); $this->mapSimple(Blocks::DRAGON_EGG(), Ids::DRAGON_EGG); $this->mapSimple(Blocks::DRIED_KELP(), Ids::DRIED_KELP_BLOCK); - $this->map(Blocks::DYED_SHULKER_BOX(), function(DyedShulkerBox $block) : Writer{ - return Writer::create(Ids::SHULKER_BOX) - ->writeColor($block->getColor()); - }); $this->mapSimple(Blocks::ELEMENT_ACTINIUM(), Ids::ELEMENT_89); $this->mapSimple(Blocks::ELEMENT_ALUMINUM(), Ids::ELEMENT_13); $this->mapSimple(Blocks::ELEMENT_AMERICIUM(), Ids::ELEMENT_95); @@ -697,7 +362,6 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ $this->mapSimple(Blocks::ELEMENT_CHLORINE(), Ids::ELEMENT_17); $this->mapSimple(Blocks::ELEMENT_CHROMIUM(), Ids::ELEMENT_24); $this->mapSimple(Blocks::ELEMENT_COBALT(), Ids::ELEMENT_27); - $this->map(Blocks::ELEMENT_CONSTRUCTOR(), fn(ChemistryTable $block) => Helper::encodeChemistryTable($block, StringValues::CHEMISTRY_TABLE_TYPE_ELEMENT_CONSTRUCTOR, new Writer(Ids::CHEMISTRY_TABLE))); $this->mapSimple(Blocks::ELEMENT_COPERNICIUM(), Ids::ELEMENT_112); $this->mapSimple(Blocks::ELEMENT_COPPER(), Ids::ELEMENT_29); $this->mapSimple(Blocks::ELEMENT_CURIUM(), Ids::ELEMENT_96); @@ -797,6 +461,423 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ $this->mapSimple(Blocks::EMERALD(), Ids::EMERALD_BLOCK); $this->mapSimple(Blocks::EMERALD_ORE(), Ids::EMERALD_ORE); $this->mapSimple(Blocks::ENCHANTING_TABLE(), Ids::ENCHANTING_TABLE); + $this->mapSimple(Blocks::END_STONE(), Ids::END_STONE); + $this->mapSimple(Blocks::END_STONE_BRICKS(), Ids::END_BRICKS); + $this->mapSimple(Blocks::FLETCHING_TABLE(), Ids::FLETCHING_TABLE); + $this->mapSimple(Blocks::GILDED_BLACKSTONE(), Ids::GILDED_BLACKSTONE); + $this->mapSimple(Blocks::GLASS(), Ids::GLASS); + $this->mapSimple(Blocks::GLASS_PANE(), Ids::GLASS_PANE); + $this->mapSimple(Blocks::GLOWING_OBSIDIAN(), Ids::GLOWINGOBSIDIAN); + $this->mapSimple(Blocks::GLOWSTONE(), Ids::GLOWSTONE); + $this->mapSimple(Blocks::GOLD(), Ids::GOLD_BLOCK); + $this->mapSimple(Blocks::GOLD_ORE(), Ids::GOLD_ORE); + $this->mapSimple(Blocks::GRASS(), Ids::GRASS); + $this->mapSimple(Blocks::GRASS_PATH(), Ids::GRASS_PATH); + $this->mapSimple(Blocks::GRAVEL(), Ids::GRAVEL); + $this->mapSimple(Blocks::HANGING_ROOTS(), Ids::HANGING_ROOTS); + $this->mapSimple(Blocks::HARDENED_CLAY(), Ids::HARDENED_CLAY); + $this->mapSimple(Blocks::HARDENED_GLASS(), Ids::HARD_GLASS); + $this->mapSimple(Blocks::HARDENED_GLASS_PANE(), Ids::HARD_GLASS_PANE); + $this->mapSimple(Blocks::HONEYCOMB(), Ids::HONEYCOMB_BLOCK); + $this->mapSimple(Blocks::ICE(), Ids::ICE); + $this->mapSimple(Blocks::INFO_UPDATE(), Ids::INFO_UPDATE); + $this->mapSimple(Blocks::INFO_UPDATE2(), Ids::INFO_UPDATE2); + $this->mapSimple(Blocks::INVISIBLE_BEDROCK(), Ids::INVISIBLE_BEDROCK); + $this->mapSimple(Blocks::IRON(), Ids::IRON_BLOCK); + $this->mapSimple(Blocks::IRON_BARS(), Ids::IRON_BARS); + $this->mapSimple(Blocks::IRON_ORE(), Ids::IRON_ORE); + $this->mapSimple(Blocks::JUKEBOX(), Ids::JUKEBOX); + $this->mapSimple(Blocks::LAPIS_LAZULI(), Ids::LAPIS_BLOCK); + $this->mapSimple(Blocks::LAPIS_LAZULI_ORE(), Ids::LAPIS_ORE); + $this->mapSimple(Blocks::LEGACY_STONECUTTER(), Ids::STONECUTTER); + $this->mapSimple(Blocks::LILY_PAD(), Ids::WATERLILY); + $this->mapSimple(Blocks::MAGMA(), Ids::MAGMA); + $this->mapSimple(Blocks::MANGROVE_FENCE(), Ids::MANGROVE_FENCE); + $this->mapSimple(Blocks::MANGROVE_PLANKS(), Ids::MANGROVE_PLANKS); + $this->mapSimple(Blocks::MELON(), Ids::MELON_BLOCK); + $this->mapSimple(Blocks::MONSTER_SPAWNER(), Ids::MOB_SPAWNER); + $this->mapSimple(Blocks::MOSSY_COBBLESTONE(), Ids::MOSSY_COBBLESTONE); + $this->mapSimple(Blocks::MUD_BRICKS(), Ids::MUD_BRICKS); + $this->mapSimple(Blocks::MYCELIUM(), Ids::MYCELIUM); + $this->mapSimple(Blocks::NETHERITE(), Ids::NETHERITE_BLOCK); + $this->mapSimple(Blocks::NETHERRACK(), Ids::NETHERRACK); + $this->mapSimple(Blocks::NETHER_BRICKS(), Ids::NETHER_BRICK); + $this->mapSimple(Blocks::NETHER_BRICK_FENCE(), Ids::NETHER_BRICK_FENCE); + $this->mapSimple(Blocks::NETHER_GOLD_ORE(), Ids::NETHER_GOLD_ORE); + $this->mapSimple(Blocks::NETHER_QUARTZ_ORE(), Ids::QUARTZ_ORE); + $this->mapSimple(Blocks::NETHER_REACTOR_CORE(), Ids::NETHERREACTOR); + $this->mapSimple(Blocks::NETHER_WART_BLOCK(), Ids::NETHER_WART_BLOCK); + $this->mapSimple(Blocks::NOTE_BLOCK(), Ids::NOTEBLOCK); + $this->mapSimple(Blocks::OBSIDIAN(), Ids::OBSIDIAN); + $this->mapSimple(Blocks::PACKED_ICE(), Ids::PACKED_ICE); + $this->mapSimple(Blocks::PODZOL(), Ids::PODZOL); + $this->mapSimple(Blocks::POLISHED_BLACKSTONE(), Ids::POLISHED_BLACKSTONE); + $this->mapSimple(Blocks::POLISHED_BLACKSTONE_BRICKS(), Ids::POLISHED_BLACKSTONE_BRICKS); + $this->mapSimple(Blocks::POLISHED_DEEPSLATE(), Ids::POLISHED_DEEPSLATE); + $this->mapSimple(Blocks::QUARTZ_BRICKS(), Ids::QUARTZ_BRICKS); + $this->mapSimple(Blocks::RAW_COPPER(), Ids::RAW_COPPER_BLOCK); + $this->mapSimple(Blocks::RAW_GOLD(), Ids::RAW_GOLD_BLOCK); + $this->mapSimple(Blocks::RAW_IRON(), Ids::RAW_IRON_BLOCK); + $this->mapSimple(Blocks::REDSTONE(), Ids::REDSTONE_BLOCK); + $this->mapSimple(Blocks::RED_MUSHROOM(), Ids::RED_MUSHROOM); + $this->mapSimple(Blocks::RED_NETHER_BRICKS(), Ids::RED_NETHER_BRICK); + $this->mapSimple(Blocks::RESERVED6(), Ids::RESERVED6); + $this->mapSimple(Blocks::SEA_LANTERN(), Ids::SEA_LANTERN); + $this->mapSimple(Blocks::SHROOMLIGHT(), Ids::SHROOMLIGHT); + $this->mapSimple(Blocks::SHULKER_BOX(), Ids::UNDYED_SHULKER_BOX); + $this->mapSimple(Blocks::SLIME(), Ids::SLIME); + $this->mapSimple(Blocks::SMITHING_TABLE(), Ids::SMITHING_TABLE); + $this->mapSimple(Blocks::SMOOTH_BASALT(), Ids::SMOOTH_BASALT); + $this->mapSimple(Blocks::SMOOTH_STONE(), Ids::SMOOTH_STONE); + $this->mapSimple(Blocks::SNOW(), Ids::SNOW); + $this->mapSimple(Blocks::SOUL_SAND(), Ids::SOUL_SAND); + $this->mapSimple(Blocks::SOUL_SOIL(), Ids::SOUL_SOIL); + $this->mapSimple(Blocks::TINTED_GLASS(), Ids::TINTED_GLASS); + $this->mapSimple(Blocks::TUFF(), Ids::TUFF); + $this->mapSimple(Blocks::WARPED_FENCE(), Ids::WARPED_FENCE); + $this->mapSimple(Blocks::WARPED_PLANKS(), Ids::WARPED_PLANKS); + $this->mapSimple(Blocks::WARPED_WART_BLOCK(), Ids::WARPED_WART_BLOCK); + $this->mapSimple(Blocks::WITHER_ROSE(), Ids::WITHER_ROSE); + } + + private function registerSerializers() : void{ + $this->map(Blocks::ACACIA_BUTTON(), fn(WoodenButton $block) => Helper::encodeButton($block, new Writer(Ids::ACACIA_BUTTON))); + $this->map(Blocks::ACACIA_DOOR(), fn(WoodenDoor $block) => Helper::encodeDoor($block, new Writer(Ids::ACACIA_DOOR))); + $this->map(Blocks::ACACIA_FENCE(), fn() => Writer::create(Ids::FENCE) + ->writeString(StateNames::WOOD_TYPE, StringValues::WOOD_TYPE_ACACIA)); + $this->map(Blocks::ACACIA_FENCE_GATE(), fn(FenceGate $block) => Helper::encodeFenceGate($block, new Writer(Ids::ACACIA_FENCE_GATE))); + $this->map(Blocks::ACACIA_LEAVES(), fn(Leaves $block) => Helper::encodeLeaves2($block, StringValues::NEW_LEAF_TYPE_ACACIA)); + $this->map(Blocks::ACACIA_LOG(), fn(Wood $block) => Helper::encodeLog2($block, StringValues::NEW_LOG_TYPE_ACACIA, Ids::STRIPPED_ACACIA_LOG)); + $this->map(Blocks::ACACIA_PLANKS(), fn() => Writer::create(Ids::PLANKS) + ->writeString(StateNames::WOOD_TYPE, StringValues::WOOD_TYPE_ACACIA)); + $this->map(Blocks::ACACIA_PRESSURE_PLATE(), fn(WoodenPressurePlate $block) => Helper::encodeSimplePressurePlate($block, new Writer(Ids::ACACIA_PRESSURE_PLATE))); + $this->map(Blocks::ACACIA_SAPLING(), fn(Sapling $block) => Helper::encodeSapling($block, StringValues::SAPLING_TYPE_ACACIA)); + $this->map(Blocks::ACACIA_SIGN(), fn(FloorSign $block) => Helper::encodeFloorSign($block, new Writer(Ids::ACACIA_STANDING_SIGN))); + $this->map(Blocks::ACACIA_SLAB(), fn(Slab $block) => Helper::encodeWoodenSlab($block, StringValues::WOOD_TYPE_ACACIA)); + $this->map(Blocks::ACACIA_STAIRS(), fn(WoodenStairs $block) => Helper::encodeStairs($block, new Writer(Ids::ACACIA_STAIRS))); + $this->map(Blocks::ACACIA_TRAPDOOR(), fn(WoodenTrapdoor $block) => Helper::encodeTrapdoor($block, new Writer(Ids::ACACIA_TRAPDOOR))); + $this->map(Blocks::ACACIA_WALL_SIGN(), fn(WallSign $block) => Helper::encodeWallSign($block, new Writer(Ids::ACACIA_WALL_SIGN))); + $this->map(Blocks::ACACIA_WOOD(), fn(Wood $block) => Helper::encodeAllSidedLog($block)); + $this->map(Blocks::ACTIVATOR_RAIL(), function(ActivatorRail $block) : Writer{ + return Writer::create(Ids::ACTIVATOR_RAIL) + ->writeBool(StateNames::RAIL_DATA_BIT, $block->isPowered()) + ->writeInt(StateNames::RAIL_DIRECTION, $block->getShape()); + }); + $this->map(Blocks::ALLIUM(), fn() => Helper::encodeRedFlower(StringValues::FLOWER_TYPE_ALLIUM)); + $this->map(Blocks::ALL_SIDED_MUSHROOM_STEM(), fn() => Writer::create(Ids::BROWN_MUSHROOM_BLOCK) + ->writeInt(StateNames::HUGE_MUSHROOM_BITS, BlockLegacyMetadata::MUSHROOM_BLOCK_ALL_STEM)); + $this->map(Blocks::ANDESITE(), fn() => Helper::encodeStone(StringValues::STONE_TYPE_ANDESITE)); + $this->map(Blocks::ANDESITE_SLAB(), fn(Slab $block) => Helper::encodeStoneSlab3($block, StringValues::STONE_SLAB_TYPE_3_ANDESITE)); + $this->map(Blocks::ANDESITE_STAIRS(), fn(Stair $block) => Helper::encodeStairs($block, new Writer(Ids::ANDESITE_STAIRS))); + $this->map(Blocks::ANDESITE_WALL(), fn(Wall $block) => Helper::encodeLegacyWall($block, StringValues::WALL_BLOCK_TYPE_ANDESITE)); + $this->map(Blocks::ANVIL(), function(Anvil $block) : Writer{ + return Writer::create(Ids::ANVIL) + ->writeLegacyHorizontalFacing($block->getFacing()) + ->writeString(StateNames::DAMAGE, match($damage = $block->getDamage()){ + 0 => StringValues::DAMAGE_UNDAMAGED, + 1 => StringValues::DAMAGE_SLIGHTLY_DAMAGED, + 2 => StringValues::DAMAGE_VERY_DAMAGED, + default => throw new BlockStateSerializeException("Invalid Anvil damage {$damage}"), + }); + }); + $this->map(Blocks::AZURE_BLUET(), fn() => Helper::encodeRedFlower(StringValues::FLOWER_TYPE_HOUSTONIA)); + $this->map(Blocks::BAMBOO(), function(Bamboo $block) : Writer{ + return Writer::create(Ids::BAMBOO) + ->writeBool(StateNames::AGE_BIT, $block->isReady()) + ->writeString(StateNames::BAMBOO_LEAF_SIZE, match($block->getLeafSize()){ + Bamboo::NO_LEAVES => StringValues::BAMBOO_LEAF_SIZE_NO_LEAVES, + Bamboo::SMALL_LEAVES => StringValues::BAMBOO_LEAF_SIZE_SMALL_LEAVES, + Bamboo::LARGE_LEAVES => StringValues::BAMBOO_LEAF_SIZE_LARGE_LEAVES, + default => throw new BlockStateSerializeException("Invalid Bamboo leaf thickness " . $block->getLeafSize()), + }) + ->writeString(StateNames::BAMBOO_STALK_THICKNESS, $block->isThick() ? StringValues::BAMBOO_STALK_THICKNESS_THICK : StringValues::BAMBOO_STALK_THICKNESS_THIN); + }); + $this->map(Blocks::BAMBOO_SAPLING(), function(BambooSapling $block) : Writer{ + return Writer::create(Ids::BAMBOO_SAPLING) + ->writeBool(StateNames::AGE_BIT, $block->isReady()) + + //TODO: bug in MCPE + ->writeString(StateNames::SAPLING_TYPE, StringValues::SAPLING_TYPE_OAK); + }); + $this->map(Blocks::BANNER(), function(FloorBanner $block) : Writer{ + return Writer::create(Ids::STANDING_BANNER) + ->writeInt(StateNames::GROUND_SIGN_DIRECTION, $block->getRotation()); + }); + $this->map(Blocks::BARREL(), function(Barrel $block) : Writer{ + return Writer::create(Ids::BARREL) + ->writeBool(StateNames::OPEN_BIT, $block->isOpen()) + ->writeFacingDirection($block->getFacing()); + }); + $this->map(Blocks::BASALT(), function(SimplePillar $block) : Writer{ + return Writer::create(Ids::BASALT) + ->writePillarAxis($block->getAxis()); + }); + $this->map(Blocks::BED(), function(Bed $block) : Writer{ + return Writer::create(Ids::BED) + ->writeBool(StateNames::HEAD_PIECE_BIT, $block->isHeadPart()) + ->writeBool(StateNames::OCCUPIED_BIT, $block->isOccupied()) + ->writeLegacyHorizontalFacing($block->getFacing()); + }); + $this->map(Blocks::BEDROCK(), function(Block $block) : Writer{ + return Writer::create(Ids::BEDROCK) + ->writeBool(StateNames::INFINIBURN_BIT, $block->burnsForever()); + }); + $this->map(Blocks::BEETROOTS(), fn(Beetroot $block) => Helper::encodeCrops($block, new Writer(Ids::BEETROOT))); + $this->map(Blocks::BELL(), function(Bell $block) : Writer{ + return Writer::create(Ids::BELL) + ->writeBellAttachmentType($block->getAttachmentType()) + ->writeBool(StateNames::TOGGLE_BIT, false) //we don't care about this; it's just to keep MCPE happy + ->writeLegacyHorizontalFacing($block->getFacing()); + + }); + $this->map(Blocks::BIRCH_BUTTON(), fn(WoodenButton $block) => Helper::encodeButton($block, new Writer(Ids::BIRCH_BUTTON))); + $this->map(Blocks::BIRCH_DOOR(), fn(WoodenDoor $block) => Helper::encodeDoor($block, new Writer(Ids::BIRCH_DOOR))); + $this->map(Blocks::BIRCH_FENCE(), fn() => Writer::create(Ids::FENCE) + ->writeString(StateNames::WOOD_TYPE, StringValues::WOOD_TYPE_BIRCH)); + $this->map(Blocks::BIRCH_FENCE_GATE(), fn(FenceGate $block) => Helper::encodeFenceGate($block, new Writer(Ids::BIRCH_FENCE_GATE))); + $this->map(Blocks::BIRCH_LEAVES(), fn(Leaves $block) => Helper::encodeLeaves1($block, StringValues::OLD_LEAF_TYPE_BIRCH)); + $this->map(Blocks::BIRCH_LOG(), fn(Wood $block) => Helper::encodeLog1($block, StringValues::OLD_LOG_TYPE_BIRCH, Ids::STRIPPED_BIRCH_LOG)); + $this->map(Blocks::BIRCH_PLANKS(), fn() => Writer::create(Ids::PLANKS) + ->writeString(StateNames::WOOD_TYPE, StringValues::WOOD_TYPE_BIRCH)); + $this->map(Blocks::BIRCH_PRESSURE_PLATE(), fn(WoodenPressurePlate $block) => Helper::encodeSimplePressurePlate($block, new Writer(Ids::BIRCH_PRESSURE_PLATE))); + $this->map(Blocks::BIRCH_SAPLING(), fn(Sapling $block) => Helper::encodeSapling($block, StringValues::SAPLING_TYPE_BIRCH)); + $this->map(Blocks::BIRCH_SIGN(), fn(FloorSign $block) => Helper::encodeFloorSign($block, new Writer(Ids::BIRCH_STANDING_SIGN))); + $this->map(Blocks::BIRCH_SLAB(), fn(Slab $block) => Helper::encodeWoodenSlab($block, StringValues::WOOD_TYPE_BIRCH)); + $this->mapStairs(Blocks::BIRCH_STAIRS(), Ids::BIRCH_STAIRS); + $this->map(Blocks::BIRCH_TRAPDOOR(), fn(WoodenTrapdoor $block) => Helper::encodeTrapdoor($block, new Writer(Ids::BIRCH_TRAPDOOR))); + $this->map(Blocks::BIRCH_WALL_SIGN(), fn(WallSign $block) => Helper::encodeWallSign($block, new Writer(Ids::BIRCH_WALL_SIGN))); + $this->map(Blocks::BIRCH_WOOD(), fn(Wood $block) => Helper::encodeAllSidedLog($block)); + $this->mapSlab(Blocks::BLACKSTONE_SLAB(), Ids::BLACKSTONE_SLAB, Ids::BLACKSTONE_DOUBLE_SLAB); + $this->mapStairs(Blocks::BLACKSTONE_STAIRS(), Ids::BLACKSTONE_STAIRS); + $this->map(Blocks::BLACKSTONE_WALL(), fn(Wall $block) => Helper::encodeWall($block, new Writer(Ids::BLACKSTONE_WALL))); + $this->map(Blocks::BLAST_FURNACE(), fn(Furnace $block) => Helper::encodeFurnace($block, Ids::BLAST_FURNACE, Ids::LIT_BLAST_FURNACE)); + $this->map(Blocks::BLUE_ORCHID(), fn() => Helper::encodeRedFlower(StringValues::FLOWER_TYPE_ORCHID)); + $this->map(Blocks::BLUE_TORCH(), fn(Torch $block) => Helper::encodeColoredTorch($block, false, Writer::create(Ids::COLORED_TORCH_BP))); + $this->map(Blocks::BONE_BLOCK(), function(BoneBlock $block) : Writer{ + return Writer::create(Ids::BONE_BLOCK) + ->writeInt(StateNames::DEPRECATED, 0) + ->writePillarAxis($block->getAxis()); + }); + $this->map(Blocks::BREWING_STAND(), function(BrewingStand $block) : Writer{ + return Writer::create(Ids::BREWING_STAND) + ->writeBool(StateNames::BREWING_STAND_SLOT_A_BIT, $block->hasSlot(BrewingStandSlot::EAST())) + ->writeBool(StateNames::BREWING_STAND_SLOT_B_BIT, $block->hasSlot(BrewingStandSlot::SOUTHWEST())) + ->writeBool(StateNames::BREWING_STAND_SLOT_C_BIT, $block->hasSlot(BrewingStandSlot::NORTHWEST())); + }); + $this->map(Blocks::BRICK_SLAB(), fn(Slab $block) => Helper::encodeStoneSlab1($block, StringValues::STONE_SLAB_TYPE_BRICK)); + $this->mapStairs(Blocks::BRICK_STAIRS(), Ids::BRICK_STAIRS); + $this->map(Blocks::BRICK_WALL(), fn(Wall $block) => Helper::encodeLegacyWall($block, StringValues::WALL_BLOCK_TYPE_BRICK)); + $this->map(Blocks::BROWN_MUSHROOM_BLOCK(), fn(BrownMushroomBlock $block) => Helper::encodeMushroomBlock($block, new Writer(Ids::BROWN_MUSHROOM_BLOCK))); + $this->map(Blocks::CACTUS(), function(Cactus $block) : Writer{ + return Writer::create(Ids::CACTUS) + ->writeInt(StateNames::AGE, $block->getAge()); + }); + $this->map(Blocks::CAKE(), function(Cake $block) : Writer{ + return Writer::create(Ids::CAKE) + ->writeInt(StateNames::BITE_COUNTER, $block->getBites()); + }); + $this->map(Blocks::CARPET(), function(Carpet $block) : Writer{ + return Writer::create(Ids::CARPET) + ->writeColor($block->getColor()); + }); + $this->map(Blocks::CARROTS(), fn(Carrot $block) => Helper::encodeCrops($block, new Writer(Ids::CARROTS))); + $this->map(Blocks::CARVED_PUMPKIN(), function(CarvedPumpkin $block) : Writer{ + return Writer::create(Ids::CARVED_PUMPKIN) + ->writeLegacyHorizontalFacing($block->getFacing()); + }); + $this->map(Blocks::CHEST(), function(Chest $block) : Writer{ + return Writer::create(Ids::CHEST) + ->writeHorizontalFacing($block->getFacing()); + }); + $this->map(Blocks::CHISELED_QUARTZ(), fn(SimplePillar $block) => Helper::encodeQuartz(StringValues::CHISEL_TYPE_CHISELED, $block->getAxis())); + $this->map(Blocks::CHISELED_RED_SANDSTONE(), fn() => Helper::encodeSandstone(Ids::RED_SANDSTONE, StringValues::SAND_STONE_TYPE_HEIROGLYPHS)); + $this->map(Blocks::CHISELED_SANDSTONE(), fn() => Helper::encodeSandstone(Ids::SANDSTONE, StringValues::SAND_STONE_TYPE_HEIROGLYPHS)); + $this->map(Blocks::CHISELED_STONE_BRICKS(), fn() => Helper::encodeStoneBricks(StringValues::STONE_BRICK_TYPE_CHISELED)); + $this->mapSlab(Blocks::COBBLED_DEEPSLATE_SLAB(), Ids::COBBLED_DEEPSLATE_SLAB, Ids::COBBLED_DEEPSLATE_DOUBLE_SLAB); + $this->mapStairs(Blocks::COBBLED_DEEPSLATE_STAIRS(), Ids::COBBLED_DEEPSLATE_STAIRS); + $this->map(Blocks::COBBLED_DEEPSLATE_WALL(), fn(Wall $block) => Helper::encodeWall($block, new Writer(Ids::COBBLED_DEEPSLATE_WALL))); + $this->map(Blocks::COBBLESTONE_SLAB(), fn(Slab $block) => Helper::encodeStoneSlab1($block, StringValues::STONE_SLAB_TYPE_COBBLESTONE)); + $this->mapStairs(Blocks::COBBLESTONE_STAIRS(), Ids::STONE_STAIRS); + $this->map(Blocks::COBBLESTONE_WALL(), fn(Wall $block) => Helper::encodeLegacyWall($block, StringValues::WALL_BLOCK_TYPE_COBBLESTONE)); + $this->map(Blocks::COPPER(), function(Copper $block) : Writer{ + $oxidation = $block->getOxidation(); + return new Writer($block->isWaxed() ? + Helper::selectCopperId($oxidation, Ids::WAXED_COPPER, Ids::WAXED_EXPOSED_COPPER, Ids::WAXED_WEATHERED_COPPER, Ids::WAXED_OXIDIZED_COPPER) : + Helper::selectCopperId($oxidation, Ids::COPPER_BLOCK, Ids::EXPOSED_COPPER, Ids::WEATHERED_COPPER, Ids::OXIDIZED_COPPER) + ); + }); + $this->map(Blocks::CUT_COPPER(), function(Copper $block) : Writer{ + $oxidation = $block->getOxidation(); + return new Writer($block->isWaxed() ? + Helper::selectCopperId($oxidation, Ids::WAXED_CUT_COPPER, Ids::WAXED_EXPOSED_CUT_COPPER, Ids::WAXED_WEATHERED_CUT_COPPER, Ids::WAXED_OXIDIZED_CUT_COPPER) : + Helper::selectCopperId($oxidation, Ids::CUT_COPPER, Ids::EXPOSED_CUT_COPPER, Ids::WEATHERED_CUT_COPPER, Ids::OXIDIZED_CUT_COPPER) + ); + }); + $this->map(Blocks::CUT_COPPER_SLAB(), function(CopperSlab $block) : Writer{ + $oxidation = $block->getOxidation(); + return Helper::encodeSlab( + $block, + ($block->isWaxed() ? + Helper::selectCopperId( + $oxidation, + Ids::WAXED_CUT_COPPER_SLAB, + Ids::WAXED_EXPOSED_CUT_COPPER_SLAB, + Ids::WAXED_WEATHERED_CUT_COPPER_SLAB, + Ids::WAXED_OXIDIZED_CUT_COPPER_SLAB + ) : + Helper::selectCopperId( + $oxidation, + Ids::CUT_COPPER_SLAB, + Ids::EXPOSED_CUT_COPPER_SLAB, + Ids::WEATHERED_CUT_COPPER_SLAB, + Ids::OXIDIZED_CUT_COPPER_SLAB + ) + ), + ($block->isWaxed() ? + Helper::selectCopperId( + $oxidation, + Ids::WAXED_DOUBLE_CUT_COPPER_SLAB, + Ids::WAXED_EXPOSED_DOUBLE_CUT_COPPER_SLAB, + Ids::WAXED_WEATHERED_DOUBLE_CUT_COPPER_SLAB, + Ids::WAXED_OXIDIZED_DOUBLE_CUT_COPPER_SLAB + ) : + Helper::selectCopperId( + $oxidation, + Ids::DOUBLE_CUT_COPPER_SLAB, + Ids::EXPOSED_DOUBLE_CUT_COPPER_SLAB, + Ids::WEATHERED_DOUBLE_CUT_COPPER_SLAB, + Ids::OXIDIZED_DOUBLE_CUT_COPPER_SLAB + ) + ) + ); + }); + $this->map(Blocks::CUT_COPPER_STAIRS(), function(CopperStairs $block) : Writer{ + $oxidation = $block->getOxidation(); + return Helper::encodeStairs( + $block, + new Writer($block->isWaxed() ? + Helper::selectCopperId( + $oxidation, + Ids::WAXED_CUT_COPPER_STAIRS, + Ids::WAXED_EXPOSED_CUT_COPPER_STAIRS, + Ids::WAXED_WEATHERED_CUT_COPPER_STAIRS, + Ids::WAXED_OXIDIZED_CUT_COPPER_STAIRS + ) : + Helper::selectCopperId( + $oxidation, + Ids::CUT_COPPER_STAIRS, + Ids::EXPOSED_CUT_COPPER_STAIRS, + Ids::WEATHERED_CUT_COPPER_STAIRS, + Ids::OXIDIZED_CUT_COPPER_STAIRS + ) + ) + ); + }); + $this->map(Blocks::COCOA_POD(), function(CocoaBlock $block) : Writer{ + return Writer::create(Ids::COCOA) + ->writeInt(StateNames::AGE, $block->getAge()) + ->writeLegacyHorizontalFacing(Facing::opposite($block->getFacing())); + }); + $this->map(Blocks::COMPOUND_CREATOR(), fn(ChemistryTable $block) => Helper::encodeChemistryTable($block, StringValues::CHEMISTRY_TABLE_TYPE_COMPOUND_CREATOR, new Writer(Ids::CHEMISTRY_TABLE))); + $this->map(Blocks::CONCRETE(), function(Concrete $block) : Writer{ + return Writer::create(Ids::CONCRETE) + ->writeColor($block->getColor()); + }); + $this->map(Blocks::CONCRETE_POWDER(), function(ConcretePowder $block) : Writer{ + return Writer::create(Ids::CONCRETE_POWDER) + ->writeColor($block->getColor()); + }); + $this->map(Blocks::CORAL(), function(Coral $block) : Writer{ + return Writer::create(Ids::CORAL) + ->writeBool(StateNames::DEAD_BIT, $block->isDead()) + ->writeCoralType($block->getCoralType()); + }); + $this->map(Blocks::CORAL_BLOCK(), function(CoralBlock $block) : Writer{ + return Writer::create(Ids::CORAL_BLOCK) + ->writeBool(StateNames::DEAD_BIT, $block->isDead()) + ->writeCoralType($block->getCoralType()); + }); + $this->map(Blocks::CORAL_FAN(), function(FloorCoralFan $block) : Writer{ + return Writer::create($block->isDead() ? Ids::CORAL_FAN_DEAD : Ids::CORAL_FAN) + ->writeCoralType($block->getCoralType()) + ->writeInt(StateNames::CORAL_FAN_DIRECTION, match($axis = $block->getAxis()){ + Axis::X => 0, + Axis::Z => 1, + default => throw new BlockStateSerializeException("Invalid axis {$axis}"), + }); + }); + $this->map(Blocks::CORNFLOWER(), fn() => Helper::encodeRedFlower(StringValues::FLOWER_TYPE_CORNFLOWER)); + $this->map(Blocks::CRACKED_STONE_BRICKS(), fn() => Helper::encodeStoneBricks(StringValues::STONE_BRICK_TYPE_CRACKED)); + $this->map(Blocks::CRIMSON_BUTTON(), fn(Button $block) => Helper::encodeButton($block, new Writer(Ids::CRIMSON_BUTTON))); + $this->map(Blocks::CRIMSON_DOOR(), fn(Door $block) => Helper::encodeDoor($block, new Writer(Ids::CRIMSON_DOOR))); + $this->map(Blocks::CRIMSON_FENCE_GATE(), fn(FenceGate $block) => Helper::encodeFenceGate($block, new Writer(Ids::CRIMSON_FENCE_GATE))); + $this->map(Blocks::CRIMSON_HYPHAE(), fn(Wood $block) => Helper::encodeNewLog($block, Ids::CRIMSON_HYPHAE, Ids::STRIPPED_CRIMSON_HYPHAE)); + $this->map(Blocks::CRIMSON_PRESSURE_PLATE(), fn(SimplePressurePlate $block) => Helper::encodeSimplePressurePlate($block, new Writer(Ids::CRIMSON_PRESSURE_PLATE))); + $this->map(Blocks::CRIMSON_SIGN(), fn(FloorSign $block) => Helper::encodeFloorSign($block, new Writer(Ids::CRIMSON_STANDING_SIGN))); + $this->mapSlab(Blocks::CRIMSON_SLAB(), Ids::CRIMSON_SLAB, Ids::CRIMSON_DOUBLE_SLAB); + $this->mapStairs(Blocks::CRIMSON_STAIRS(), Ids::CRIMSON_STAIRS); + $this->map(Blocks::CRIMSON_STEM(), fn(Wood $block) => Helper::encodeNewLog($block, Ids::CRIMSON_STEM, Ids::STRIPPED_CRIMSON_STEM)); + $this->map(Blocks::CRIMSON_TRAPDOOR(), fn(Trapdoor $block) => Helper::encodeTrapdoor($block, new Writer(Ids::CRIMSON_TRAPDOOR))); + $this->map(Blocks::CRIMSON_WALL_SIGN(), fn(WallSign $block) => Helper::encodeWallSign($block, new Writer(Ids::CRIMSON_WALL_SIGN))); + $this->map(Blocks::CUT_RED_SANDSTONE(), fn() => Helper::encodeSandstone(Ids::RED_SANDSTONE, StringValues::SAND_STONE_TYPE_CUT)); + $this->map(Blocks::CUT_RED_SANDSTONE_SLAB(), fn(Slab $block) => Helper::encodeStoneSlab4($block, StringValues::STONE_SLAB_TYPE_4_CUT_RED_SANDSTONE)); + $this->map(Blocks::CUT_SANDSTONE(), fn() => Helper::encodeSandstone(Ids::SANDSTONE, StringValues::SAND_STONE_TYPE_CUT)); + $this->map(Blocks::CUT_SANDSTONE_SLAB(), fn(Slab $block) => Helper::encodeStoneSlab4($block, StringValues::STONE_SLAB_TYPE_4_CUT_SANDSTONE)); + $this->map(Blocks::DARK_OAK_BUTTON(), fn(WoodenButton $block) => Helper::encodeButton($block, new Writer(Ids::DARK_OAK_BUTTON))); + $this->map(Blocks::DARK_OAK_DOOR(), fn(WoodenDoor $block) => Helper::encodeDoor($block, new Writer(Ids::DARK_OAK_DOOR))); + $this->map(Blocks::DARK_OAK_FENCE(), fn() => Writer::create(Ids::FENCE) + ->writeString(StateNames::WOOD_TYPE, StringValues::WOOD_TYPE_DARK_OAK)); + $this->map(Blocks::DARK_OAK_FENCE_GATE(), fn(FenceGate $block) => Helper::encodeFenceGate($block, new Writer(Ids::DARK_OAK_FENCE_GATE))); + $this->map(Blocks::DARK_OAK_LEAVES(), fn(Leaves $block) => Helper::encodeLeaves2($block, StringValues::NEW_LEAF_TYPE_DARK_OAK)); + $this->map(Blocks::DARK_OAK_LOG(), fn(Wood $block) => Helper::encodeLog2($block, StringValues::NEW_LOG_TYPE_DARK_OAK, Ids::STRIPPED_DARK_OAK_LOG)); + $this->map(Blocks::DARK_OAK_PLANKS(), fn() => Writer::create(Ids::PLANKS) + ->writeString(StateNames::WOOD_TYPE, StringValues::WOOD_TYPE_DARK_OAK)); + $this->map(Blocks::DARK_OAK_PRESSURE_PLATE(), fn(WoodenPressurePlate $block) => Helper::encodeSimplePressurePlate($block, new Writer(Ids::DARK_OAK_PRESSURE_PLATE))); + $this->map(Blocks::DARK_OAK_SAPLING(), fn(Sapling $block) => Helper::encodeSapling($block, StringValues::SAPLING_TYPE_DARK_OAK)); + $this->map(Blocks::DARK_OAK_SIGN(), fn(FloorSign $block) => Helper::encodeFloorSign($block, new Writer(Ids::DARKOAK_STANDING_SIGN))); + $this->map(Blocks::DARK_OAK_SLAB(), fn(Slab $block) => Helper::encodeWoodenSlab($block, StringValues::WOOD_TYPE_DARK_OAK)); + $this->mapStairs(Blocks::DARK_OAK_STAIRS(), Ids::DARK_OAK_STAIRS); + $this->map(Blocks::DARK_OAK_TRAPDOOR(), fn(WoodenTrapdoor $block) => Helper::encodeTrapdoor($block, new Writer(Ids::DARK_OAK_TRAPDOOR))); + $this->map(Blocks::DARK_OAK_WALL_SIGN(), fn(WallSign $block) => Helper::encodeWallSign($block, new Writer(Ids::DARKOAK_WALL_SIGN))); + $this->map(Blocks::DARK_OAK_WOOD(), fn(Wood $block) => Helper::encodeAllSidedLog($block)); + $this->map(Blocks::DARK_PRISMARINE(), fn() => Writer::create(Ids::PRISMARINE) + ->writeString(StateNames::PRISMARINE_BLOCK_TYPE, StringValues::PRISMARINE_BLOCK_TYPE_DARK)); + $this->map(Blocks::DARK_PRISMARINE_SLAB(), fn(Slab $block) => Helper::encodeStoneSlab2($block, StringValues::STONE_SLAB_TYPE_2_PRISMARINE_DARK)); + $this->mapStairs(Blocks::DARK_PRISMARINE_STAIRS(), Ids::DARK_PRISMARINE_STAIRS); + $this->map(Blocks::DAYLIGHT_SENSOR(), function(DaylightSensor $block) : Writer{ + return Writer::create($block->isInverted() ? Ids::DAYLIGHT_DETECTOR_INVERTED : Ids::DAYLIGHT_DETECTOR) + ->writeInt(StateNames::REDSTONE_SIGNAL, $block->getOutputSignalStrength()); + }); + $this->map(Blocks::DEEPSLATE(), function(SimplePillar $block) : Writer{ + return Writer::create(Ids::DEEPSLATE) + ->writePillarAxis($block->getAxis()); + }); + $this->mapSlab(Blocks::DEEPSLATE_BRICK_SLAB(), Ids::DEEPSLATE_BRICK_SLAB, Ids::DEEPSLATE_BRICK_DOUBLE_SLAB); + $this->mapStairs(Blocks::DEEPSLATE_BRICK_STAIRS(), Ids::DEEPSLATE_BRICK_STAIRS); + $this->map(Blocks::DEEPSLATE_BRICK_WALL(), fn(Wall $block) => Helper::encodeWall($block, new Writer(Ids::DEEPSLATE_BRICK_WALL))); + $this->map(Blocks::DEEPSLATE_REDSTONE_ORE(), fn(RedstoneOre $block) => new Writer($block->isLit() ? Ids::LIT_DEEPSLATE_REDSTONE_ORE : Ids::DEEPSLATE_REDSTONE_ORE)); + $this->mapSlab(Blocks::DEEPSLATE_TILE_SLAB(), Ids::DEEPSLATE_TILE_SLAB, Ids::DEEPSLATE_TILE_DOUBLE_SLAB); + $this->mapStairs(Blocks::DEEPSLATE_TILE_STAIRS(), Ids::DEEPSLATE_TILE_STAIRS); + $this->map(Blocks::DEEPSLATE_TILE_WALL(), fn(Wall $block) => Helper::encodeWall($block, new Writer(Ids::DEEPSLATE_TILE_WALL))); + $this->map(Blocks::DETECTOR_RAIL(), function(DetectorRail $block) : Writer{ + return Writer::create(Ids::DETECTOR_RAIL) + ->writeBool(StateNames::RAIL_DATA_BIT, $block->isActivated()) + ->writeInt(StateNames::RAIL_DIRECTION, $block->getShape()); + }); + $this->map(Blocks::DIORITE(), fn() => Helper::encodeStone(StringValues::STONE_TYPE_DIORITE)); + $this->map(Blocks::DIORITE_SLAB(), fn(Slab $block) => Helper::encodeStoneSlab3($block, StringValues::STONE_SLAB_TYPE_3_DIORITE)); + $this->mapStairs(Blocks::DIORITE_STAIRS(), Ids::DIORITE_STAIRS); + $this->map(Blocks::DIORITE_WALL(), fn(Wall $block) => Helper::encodeLegacyWall($block, StringValues::WALL_BLOCK_TYPE_DIORITE)); + $this->map(Blocks::DIRT(), function(Dirt $block) : Writer{ + return Writer::create(Ids::DIRT) + ->writeString(StateNames::DIRT_TYPE, $block->isCoarse() ? StringValues::DIRT_TYPE_COARSE : StringValues::DIRT_TYPE_NORMAL); + }); + $this->map(Blocks::DOUBLE_TALLGRASS(), fn(DoubleTallGrass $block) => Helper::encodeDoublePlant($block, StringValues::DOUBLE_PLANT_TYPE_GRASS, Writer::create(Ids::DOUBLE_PLANT))); + $this->map(Blocks::DYED_SHULKER_BOX(), function(DyedShulkerBox $block) : Writer{ + return Writer::create(Ids::SHULKER_BOX) + ->writeColor($block->getColor()); + }); + $this->map(Blocks::ELEMENT_CONSTRUCTOR(), fn(ChemistryTable $block) => Helper::encodeChemistryTable($block, StringValues::CHEMISTRY_TABLE_TYPE_ELEMENT_CONSTRUCTOR, new Writer(Ids::CHEMISTRY_TABLE))); $this->map(Blocks::ENDER_CHEST(), function(EnderChest $block) : Writer{ return Writer::create(Ids::ENDER_CHEST) ->writeHorizontalFacing($block->getFacing()); @@ -810,8 +891,6 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ return Writer::create(Ids::END_ROD) ->writeEndRodFacingDirection($block->getFacing()); }); - $this->mapSimple(Blocks::END_STONE(), Ids::END_STONE); - $this->mapSimple(Blocks::END_STONE_BRICKS(), Ids::END_BRICKS); $this->map(Blocks::END_STONE_BRICK_SLAB(), fn(Slab $block) => Helper::encodeStoneSlab3($block, StringValues::STONE_SLAB_TYPE_3_END_STONE_BRICK)); $this->mapStairs(Blocks::END_STONE_BRICK_STAIRS(), Ids::END_BRICK_STAIRS); $this->map(Blocks::END_STONE_BRICK_WALL(), fn(Wall $block) => Helper::encodeLegacyWall($block, StringValues::WALL_BLOCK_TYPE_END_BRICK)); @@ -826,7 +905,6 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ return Writer::create(Ids::FIRE) ->writeInt(StateNames::AGE, $block->getAge()); }); - $this->mapSimple(Blocks::FLETCHING_TABLE(), Ids::FLETCHING_TABLE); $this->map(Blocks::FLOWER_POT(), function() : Writer{ return Writer::create(Ids::FLOWER_POT) ->writeBool(StateNames::UPDATE_BIT, true); //to keep MCPE happy @@ -836,9 +914,6 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ ->writeInt(StateNames::AGE, $block->getAge()); }); $this->map(Blocks::FURNACE(), fn(Furnace $block) => Helper::encodeFurnace($block, Ids::FURNACE, Ids::LIT_FURNACE)); - $this->mapSimple(Blocks::GILDED_BLACKSTONE(), Ids::GILDED_BLACKSTONE); - $this->mapSimple(Blocks::GLASS(), Ids::GLASS); - $this->mapSimple(Blocks::GLASS_PANE(), Ids::GLASS_PANE); $this->map(Blocks::GLAZED_TERRACOTTA(), function(GlazedTerracotta $block) : Writer{ return Writer::create(match ($color = $block->getColor()) { DyeColor::BLACK() => Ids::BLACK_GLAZED_TERRACOTTA, @@ -861,34 +936,21 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ }) ->writeHorizontalFacing($block->getFacing()); }); - $this->mapSimple(Blocks::GLOWING_OBSIDIAN(), Ids::GLOWINGOBSIDIAN); - $this->mapSimple(Blocks::GLOWSTONE(), Ids::GLOWSTONE); - $this->mapSimple(Blocks::GOLD(), Ids::GOLD_BLOCK); - $this->mapSimple(Blocks::GOLD_ORE(), Ids::GOLD_ORE); $this->map(Blocks::GRANITE(), fn() => Helper::encodeStone(StringValues::STONE_TYPE_GRANITE)); $this->map(Blocks::GRANITE_SLAB(), fn(Slab $block) => Helper::encodeStoneSlab3($block, StringValues::STONE_SLAB_TYPE_3_GRANITE)); $this->mapStairs(Blocks::GRANITE_STAIRS(), Ids::GRANITE_STAIRS); $this->map(Blocks::GRANITE_WALL(), fn(Wall $block) => Helper::encodeLegacyWall($block, StringValues::WALL_BLOCK_TYPE_GRANITE)); - $this->mapSimple(Blocks::GRASS(), Ids::GRASS); - $this->mapSimple(Blocks::GRASS_PATH(), Ids::GRASS_PATH); - $this->mapSimple(Blocks::GRAVEL(), Ids::GRAVEL); $this->map(Blocks::GREEN_TORCH(), fn(Torch $block) => Helper::encodeColoredTorch($block, true, Writer::create(Ids::COLORED_TORCH_RG))); - $this->mapSimple(Blocks::HANGING_ROOTS(), Ids::HANGING_ROOTS); - $this->mapSimple(Blocks::HARDENED_CLAY(), Ids::HARDENED_CLAY); - $this->mapSimple(Blocks::HARDENED_GLASS(), Ids::HARD_GLASS); - $this->mapSimple(Blocks::HARDENED_GLASS_PANE(), Ids::HARD_GLASS_PANE); $this->map(Blocks::HAY_BALE(), function(HayBale $block) : Writer{ return Writer::create(Ids::HAY_BLOCK) ->writeInt(StateNames::DEPRECATED, 0) ->writePillarAxis($block->getAxis()); }); - $this->mapSimple(Blocks::HONEYCOMB(), Ids::HONEYCOMB_BLOCK); $this->map(Blocks::HOPPER(), function(Hopper $block) : Writer{ return Writer::create(Ids::HOPPER) ->writeBool(StateNames::TOGGLE_BIT, $block->isPowered()) ->writeFacingWithoutUp($block->getFacing()); }); - $this->mapSimple(Blocks::ICE(), Ids::ICE); $this->map(Blocks::INFESTED_CHISELED_STONE_BRICK(), fn() => Writer::create(Ids::MONSTER_EGG) ->writeString(StateNames::MONSTER_EGG_STONE_TYPE, StringValues::MONSTER_EGG_STONE_TYPE_CHISELED_STONE_BRICK)); $this->map(Blocks::INFESTED_COBBLESTONE(), fn() => Writer::create(Ids::MONSTER_EGG) @@ -901,13 +963,7 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ ->writeString(StateNames::MONSTER_EGG_STONE_TYPE, StringValues::MONSTER_EGG_STONE_TYPE_STONE)); $this->map(Blocks::INFESTED_STONE_BRICK(), fn() => Writer::create(Ids::MONSTER_EGG) ->writeString(StateNames::MONSTER_EGG_STONE_TYPE, StringValues::MONSTER_EGG_STONE_TYPE_STONE_BRICK)); - $this->mapSimple(Blocks::INFO_UPDATE(), Ids::INFO_UPDATE); - $this->mapSimple(Blocks::INFO_UPDATE2(), Ids::INFO_UPDATE2); - $this->mapSimple(Blocks::INVISIBLE_BEDROCK(), Ids::INVISIBLE_BEDROCK); - $this->mapSimple(Blocks::IRON(), Ids::IRON_BLOCK); - $this->mapSimple(Blocks::IRON_BARS(), Ids::IRON_BARS); $this->map(Blocks::IRON_DOOR(), fn(Door $block) => Helper::encodeDoor($block, new Writer(Ids::IRON_DOOR))); - $this->mapSimple(Blocks::IRON_ORE(), Ids::IRON_ORE); $this->map(Blocks::IRON_TRAPDOOR(), fn(Trapdoor $block) => Helper::encodeTrapdoor($block, new Writer(Ids::IRON_TRAPDOOR))); $this->map(Blocks::ITEM_FRAME(), function(ItemFrame $block) : Writer{ return Writer::create($block->isGlowing() ? Ids::GLOW_FRAME : Ids::FRAME) @@ -915,7 +971,6 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ ->writeBool(StateNames::ITEM_FRAME_PHOTO_BIT, false) ->writeFacingDirection($block->getFacing()); }); - $this->mapSimple(Blocks::JUKEBOX(), Ids::JUKEBOX); $this->map(Blocks::JUNGLE_BUTTON(), fn(WoodenButton $block) => Helper::encodeButton($block, new Writer(Ids::JUNGLE_BUTTON))); $this->map(Blocks::JUNGLE_DOOR(), fn(WoodenDoor $block) => Helper::encodeDoor($block, new Writer(Ids::JUNGLE_DOOR))); $this->map(Blocks::JUNGLE_FENCE(), fn() => Writer::create(Ids::FENCE) @@ -942,8 +997,6 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ return Writer::create(Ids::LANTERN) ->writeBool(StateNames::HANGING, $block->isHanging()); }); - $this->mapSimple(Blocks::LAPIS_LAZULI(), Ids::LAPIS_BLOCK); - $this->mapSimple(Blocks::LAPIS_LAZULI_ORE(), Ids::LAPIS_ORE); $this->map(Blocks::LARGE_FERN(), fn(DoubleTallGrass $block) => Helper::encodeDoublePlant($block, StringValues::DOUBLE_PLANT_TYPE_FERN, Writer::create(Ids::DOUBLE_PLANT))); $this->map(Blocks::LAVA(), fn(Lava $block) => Helper::encodeLiquid($block, Ids::LAVA, Ids::FLOWING_LAVA)); $this->map(Blocks::LECTERN(), function(Lectern $block) : Writer{ @@ -951,7 +1004,6 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ ->writeBool(StateNames::POWERED_BIT, $block->isProducingSignal()) ->writeLegacyHorizontalFacing($block->getFacing()); }); - $this->mapSimple(Blocks::LEGACY_STONECUTTER(), Ids::STONECUTTER); $this->map(Blocks::LEVER(), function(Lever $block) : Writer{ return Writer::create(Ids::LEVER) ->writeBool(StateNames::OPEN_BIT, $block->isActivated()) @@ -977,7 +1029,6 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ }); $this->map(Blocks::LILAC(), fn(DoublePlant $block) => Helper::encodeDoublePlant($block, StringValues::DOUBLE_PLANT_TYPE_SYRINGA, Writer::create(Ids::DOUBLE_PLANT))); $this->map(Blocks::LILY_OF_THE_VALLEY(), fn() => Helper::encodeRedFlower(StringValues::FLOWER_TYPE_LILY_OF_THE_VALLEY)); - $this->mapSimple(Blocks::LILY_PAD(), Ids::WATERLILY); $this->map(Blocks::LIT_PUMPKIN(), function(LitPumpkin $block) : Writer{ return Writer::create(Ids::LIT_PUMPKIN) ->writeLegacyHorizontalFacing($block->getFacing()); @@ -986,13 +1037,10 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ return Writer::create(Ids::LOOM) ->writeLegacyHorizontalFacing($block->getFacing()); }); - $this->mapSimple(Blocks::MAGMA(), Ids::MAGMA); $this->map(Blocks::MANGROVE_BUTTON(), fn(Button $block) => Helper::encodeButton($block, new Writer(Ids::MANGROVE_BUTTON))); $this->map(Blocks::MANGROVE_DOOR(), fn(Door $block) => Helper::encodeDoor($block, new Writer(Ids::MANGROVE_DOOR))); - $this->mapSimple(Blocks::MANGROVE_FENCE(), Ids::MANGROVE_FENCE); $this->map(Blocks::MANGROVE_FENCE_GATE(), fn(FenceGate $block) => Helper::encodeFenceGate($block, new Writer(Ids::MANGROVE_FENCE_GATE))); $this->map(Blocks::MANGROVE_LOG(), fn(Wood $block) => Helper::encodeNewLog($block, Ids::MANGROVE_LOG, Ids::STRIPPED_MANGROVE_LOG)); - $this->mapSimple(Blocks::MANGROVE_PLANKS(), Ids::MANGROVE_PLANKS); $this->map(Blocks::MANGROVE_PRESSURE_PLATE(), fn(SimplePressurePlate $block) => Helper::encodeSimplePressurePlate($block, new Writer(Ids::MANGROVE_PRESSURE_PLATE))); $this->map(Blocks::MANGROVE_SIGN(), fn(FloorSign $block) => Helper::encodeFloorSign($block, new Writer(Ids::MANGROVE_STANDING_SIGN))); $this->mapSlab(Blocks::MANGROVE_SLAB(), Ids::MANGROVE_SLAB, Ids::MANGROVE_DOUBLE_SLAB); @@ -1011,14 +1059,11 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ } }); $this->map(Blocks::MATERIAL_REDUCER(), fn(ChemistryTable $block) => Helper::encodeChemistryTable($block, StringValues::CHEMISTRY_TABLE_TYPE_MATERIAL_REDUCER, new Writer(Ids::CHEMISTRY_TABLE))); - $this->mapSimple(Blocks::MELON(), Ids::MELON_BLOCK); $this->map(Blocks::MELON_STEM(), fn(MelonStem $block) => Helper::encodeStem($block, new Writer(Ids::MELON_STEM))); $this->map(Blocks::MOB_HEAD(), function(Skull $block) : Writer{ return Writer::create(Ids::SKULL) ->writeFacingWithoutDown($block->getFacing()); }); - $this->mapSimple(Blocks::MONSTER_SPAWNER(), Ids::MOB_SPAWNER); - $this->mapSimple(Blocks::MOSSY_COBBLESTONE(), Ids::MOSSY_COBBLESTONE); $this->map(Blocks::MOSSY_COBBLESTONE_SLAB(), fn(Slab $block) => Helper::encodeStoneSlab2($block, StringValues::STONE_SLAB_TYPE_2_MOSSY_COBBLESTONE)); $this->mapStairs(Blocks::MOSSY_COBBLESTONE_STAIRS(), Ids::MOSSY_COBBLESTONE_STAIRS); $this->map(Blocks::MOSSY_COBBLESTONE_WALL(), fn(Wall $block) => Helper::encodeLegacyWall($block, StringValues::WALL_BLOCK_TYPE_MOSSY_COBBLESTONE)); @@ -1026,21 +1071,14 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ $this->map(Blocks::MOSSY_STONE_BRICK_SLAB(), fn(Slab $block) => Helper::encodeStoneSlab4($block, StringValues::STONE_SLAB_TYPE_4_MOSSY_STONE_BRICK)); $this->mapStairs(Blocks::MOSSY_STONE_BRICK_STAIRS(), Ids::MOSSY_STONE_BRICK_STAIRS); $this->map(Blocks::MOSSY_STONE_BRICK_WALL(), fn(Wall $block) => Helper::encodeLegacyWall($block, StringValues::WALL_BLOCK_TYPE_MOSSY_STONE_BRICK)); - $this->mapSimple(Blocks::MUD_BRICKS(), Ids::MUD_BRICKS); $this->mapSlab(Blocks::MUD_BRICK_SLAB(), Ids::MUD_BRICK_SLAB, Ids::MUD_BRICK_DOUBLE_SLAB); $this->mapStairs(Blocks::MUD_BRICK_STAIRS(), Ids::MUD_BRICK_STAIRS); $this->map(Blocks::MUD_BRICK_WALL(), fn(Wall $block) => Helper::encodeWall($block, new Writer(Ids::MUD_BRICK_WALL))); $this->map(Blocks::MUSHROOM_STEM(), fn() => Writer::create(Ids::BROWN_MUSHROOM_BLOCK) ->writeInt(StateNames::HUGE_MUSHROOM_BITS, BlockLegacyMetadata::MUSHROOM_BLOCK_STEM)); - $this->mapSimple(Blocks::MYCELIUM(), Ids::MYCELIUM); - $this->mapSimple(Blocks::NETHERITE(), Ids::NETHERITE_BLOCK); - $this->mapSimple(Blocks::NETHERRACK(), Ids::NETHERRACK); - $this->mapSimple(Blocks::NETHER_BRICKS(), Ids::NETHER_BRICK); - $this->mapSimple(Blocks::NETHER_BRICK_FENCE(), Ids::NETHER_BRICK_FENCE); $this->map(Blocks::NETHER_BRICK_SLAB(), fn(Slab $block) => Helper::encodeStoneSlab1($block, StringValues::STONE_SLAB_TYPE_NETHER_BRICK)); $this->mapStairs(Blocks::NETHER_BRICK_STAIRS(), Ids::NETHER_BRICK_STAIRS); $this->map(Blocks::NETHER_BRICK_WALL(), fn(Wall $block) => Helper::encodeLegacyWall($block, StringValues::WALL_BLOCK_TYPE_NETHER_BRICK)); - $this->mapSimple(Blocks::NETHER_GOLD_ORE(), Ids::NETHER_GOLD_ORE); $this->map(Blocks::NETHER_PORTAL(), function(NetherPortal $block) : Writer{ return Writer::create(Ids::PORTAL) ->writeString(StateNames::PORTAL_AXIS, match($block->getAxis()){ @@ -1049,14 +1087,10 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ default => throw new BlockStateSerializeException("Invalid Nether Portal axis " . $block->getAxis()), }); }); - $this->mapSimple(Blocks::NETHER_QUARTZ_ORE(), Ids::QUARTZ_ORE); - $this->mapSimple(Blocks::NETHER_REACTOR_CORE(), Ids::NETHERREACTOR); $this->map(Blocks::NETHER_WART(), function(NetherWartPlant $block) : Writer{ return Writer::create(Ids::NETHER_WART) ->writeInt(StateNames::AGE, $block->getAge()); }); - $this->mapSimple(Blocks::NETHER_WART_BLOCK(), Ids::NETHER_WART_BLOCK); - $this->mapSimple(Blocks::NOTE_BLOCK(), Ids::NOTEBLOCK); $this->map(Blocks::OAK_BUTTON(), fn(WoodenButton $block) => Helper::encodeButton($block, new Writer(Ids::WOODEN_BUTTON))); $this->map(Blocks::OAK_DOOR(), fn(WoodenDoor $block) => Helper::encodeDoor($block, new Writer(Ids::WOODEN_DOOR))); $this->map(Blocks::OAK_FENCE(), fn() => Writer::create(Ids::FENCE) @@ -1074,13 +1108,10 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ $this->map(Blocks::OAK_TRAPDOOR(), fn(WoodenTrapdoor $block) => Helper::encodeTrapdoor($block, new Writer(Ids::TRAPDOOR))); $this->map(Blocks::OAK_WALL_SIGN(), fn(WallSign $block) => Helper::encodeWallSign($block, new Writer(Ids::WALL_SIGN))); $this->map(Blocks::OAK_WOOD(), fn(Wood $block) => Helper::encodeAllSidedLog($block)); - $this->mapSimple(Blocks::OBSIDIAN(), Ids::OBSIDIAN); $this->map(Blocks::ORANGE_TULIP(), fn() => Helper::encodeRedFlower(StringValues::FLOWER_TYPE_TULIP_ORANGE)); $this->map(Blocks::OXEYE_DAISY(), fn() => Helper::encodeRedFlower(StringValues::FLOWER_TYPE_OXEYE)); - $this->mapSimple(Blocks::PACKED_ICE(), Ids::PACKED_ICE); $this->map(Blocks::PEONY(), fn(DoublePlant $block) => Helper::encodeDoublePlant($block, StringValues::DOUBLE_PLANT_TYPE_PAEONIA, Writer::create(Ids::DOUBLE_PLANT))); $this->map(Blocks::PINK_TULIP(), fn() => Helper::encodeRedFlower(StringValues::FLOWER_TYPE_TULIP_PINK)); - $this->mapSimple(Blocks::PODZOL(), Ids::PODZOL); $this->map(Blocks::POLISHED_ANDESITE(), fn() => Helper::encodeStone(StringValues::STONE_TYPE_ANDESITE_SMOOTH)); $this->map(Blocks::POLISHED_ANDESITE_SLAB(), fn(Slab $block) => Helper::encodeStoneSlab3($block, StringValues::STONE_SLAB_TYPE_3_POLISHED_ANDESITE)); $this->mapStairs(Blocks::POLISHED_ANDESITE_STAIRS(), Ids::POLISHED_ANDESITE_STAIRS); @@ -1088,8 +1119,6 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ return Writer::create(Ids::POLISHED_BASALT) ->writePillarAxis($block->getAxis()); }); - $this->mapSimple(Blocks::POLISHED_BLACKSTONE(), Ids::POLISHED_BLACKSTONE); - $this->mapSimple(Blocks::POLISHED_BLACKSTONE_BRICKS(), Ids::POLISHED_BLACKSTONE_BRICKS); $this->mapSlab(Blocks::POLISHED_BLACKSTONE_BRICK_SLAB(), Ids::POLISHED_BLACKSTONE_BRICK_SLAB, Ids::POLISHED_BLACKSTONE_BRICK_DOUBLE_SLAB); $this->mapStairs(Blocks::POLISHED_BLACKSTONE_BRICK_STAIRS(), Ids::POLISHED_BLACKSTONE_BRICK_STAIRS); $this->map(Blocks::POLISHED_BLACKSTONE_BRICK_WALL(), fn(Wall $block) => Helper::encodeWall($block, new Writer(Ids::POLISHED_BLACKSTONE_BRICK_WALL))); @@ -1098,7 +1127,6 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ $this->mapSlab(Blocks::POLISHED_BLACKSTONE_SLAB(), Ids::POLISHED_BLACKSTONE_SLAB, Ids::POLISHED_BLACKSTONE_DOUBLE_SLAB); $this->mapStairs(Blocks::POLISHED_BLACKSTONE_STAIRS(), Ids::POLISHED_BLACKSTONE_STAIRS); $this->map(Blocks::POLISHED_BLACKSTONE_WALL(), fn(Wall $block) => Helper::encodeWall($block, new Writer(Ids::POLISHED_BLACKSTONE_WALL))); - $this->mapSimple(Blocks::POLISHED_DEEPSLATE(), Ids::POLISHED_DEEPSLATE); $this->mapSlab(Blocks::POLISHED_DEEPSLATE_SLAB(), Ids::POLISHED_DEEPSLATE_SLAB, Ids::POLISHED_DEEPSLATE_DOUBLE_SLAB); $this->mapStairs(Blocks::POLISHED_DEEPSLATE_STAIRS(), Ids::POLISHED_DEEPSLATE_STAIRS); $this->map(Blocks::POLISHED_DEEPSLATE_WALL(), fn(Wall $block) => Helper::encodeWall($block, new Writer(Ids::POLISHED_DEEPSLATE_WALL))); @@ -1143,7 +1171,6 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ $this->map(Blocks::PURPUR_SLAB(), fn(Slab $block) => Helper::encodeStoneSlab2($block, StringValues::STONE_SLAB_TYPE_2_PURPUR)); $this->mapStairs(Blocks::PURPUR_STAIRS(), Ids::PURPUR_STAIRS); $this->map(Blocks::QUARTZ(), fn() => Helper::encodeQuartz(StringValues::CHISEL_TYPE_DEFAULT, Axis::Y)); - $this->mapSimple(Blocks::QUARTZ_BRICKS(), Ids::QUARTZ_BRICKS); $this->map(Blocks::QUARTZ_PILLAR(), fn(SimplePillar $block) => Helper::encodeQuartz(StringValues::CHISEL_TYPE_LINES, $block->getAxis())); $this->map(Blocks::QUARTZ_SLAB(), fn(Slab $block) => Helper::encodeStoneSlab1($block, StringValues::STONE_SLAB_TYPE_QUARTZ)); $this->mapStairs(Blocks::QUARTZ_STAIRS(), Ids::QUARTZ_STAIRS); @@ -1151,10 +1178,6 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ return Writer::create(Ids::RAIL) ->writeInt(StateNames::RAIL_DIRECTION, $block->getShape()); }); - $this->mapSimple(Blocks::RAW_COPPER(), Ids::RAW_COPPER_BLOCK); - $this->mapSimple(Blocks::RAW_GOLD(), Ids::RAW_GOLD_BLOCK); - $this->mapSimple(Blocks::RAW_IRON(), Ids::RAW_IRON_BLOCK); - $this->mapSimple(Blocks::REDSTONE(), Ids::REDSTONE_BLOCK); $this->map(Blocks::REDSTONE_COMPARATOR(), function(RedstoneComparator $block) : Writer{ return Writer::create($block->isPowered() ? Ids::POWERED_COMPARATOR : Ids::UNPOWERED_COMPARATOR) ->writeBool(StateNames::OUTPUT_LIT_BIT, $block->isPowered()) @@ -1176,9 +1199,7 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ return Writer::create(Ids::REDSTONE_WIRE) ->writeInt(StateNames::REDSTONE_SIGNAL, $block->getOutputSignalStrength()); }); - $this->mapSimple(Blocks::RED_MUSHROOM(), Ids::RED_MUSHROOM); $this->map(Blocks::RED_MUSHROOM_BLOCK(), fn(RedMushroomBlock $block) => Helper::encodeMushroomBlock($block, new Writer(Ids::RED_MUSHROOM_BLOCK))); - $this->mapSimple(Blocks::RED_NETHER_BRICKS(), Ids::RED_NETHER_BRICK); $this->map(Blocks::RED_NETHER_BRICK_SLAB(), fn(Slab $block) => Helper::encodeStoneSlab2($block, StringValues::STONE_SLAB_TYPE_2_RED_NETHER_BRICK)); $this->mapStairs(Blocks::RED_NETHER_BRICK_STAIRS(), Ids::RED_NETHER_BRICK_STAIRS); $this->map(Blocks::RED_NETHER_BRICK_WALL(), fn(Wall $block) => Helper::encodeLegacyWall($block, StringValues::WALL_BLOCK_TYPE_RED_NETHER_BRICK)); @@ -1190,7 +1211,6 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ $this->map(Blocks::RED_SANDSTONE_WALL(), fn(Wall $block) => Helper::encodeLegacyWall($block, StringValues::WALL_BLOCK_TYPE_RED_SANDSTONE)); $this->map(Blocks::RED_TORCH(), fn(Torch $block) => Helper::encodeColoredTorch($block, false, Writer::create(Ids::COLORED_TORCH_RG))); $this->map(Blocks::RED_TULIP(), fn() => Helper::encodeRedFlower(StringValues::FLOWER_TYPE_TULIP_RED)); - $this->mapSimple(Blocks::RESERVED6(), Ids::RESERVED6); $this->map(Blocks::ROSE_BUSH(), fn(DoublePlant $block) => Helper::encodeDoublePlant($block, StringValues::DOUBLE_PLANT_TYPE_ROSE, Writer::create(Ids::DOUBLE_PLANT))); $this->map(Blocks::SAND(), fn() => Writer::create(Ids::SAND) ->writeString(StateNames::SAND_TYPE, StringValues::SAND_TYPE_NORMAL)); @@ -1198,18 +1218,12 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ $this->map(Blocks::SANDSTONE_SLAB(), fn(Slab $block) => Helper::encodeStoneSlab1($block, StringValues::STONE_SLAB_TYPE_SANDSTONE)); $this->mapStairs(Blocks::SANDSTONE_STAIRS(), Ids::SANDSTONE_STAIRS); $this->map(Blocks::SANDSTONE_WALL(), fn(Wall $block) => Helper::encodeLegacyWall($block, StringValues::WALL_BLOCK_TYPE_SANDSTONE)); - $this->mapSimple(Blocks::SEA_LANTERN(), Ids::SEA_LANTERN); $this->map(Blocks::SEA_PICKLE(), function(SeaPickle $block) : Writer{ return Writer::create(Ids::SEA_PICKLE) ->writeBool(StateNames::DEAD_BIT, !$block->isUnderwater()) ->writeInt(StateNames::CLUSTER_COUNT, $block->getCount() - 1); }); - $this->mapSimple(Blocks::SHROOMLIGHT(), Ids::SHROOMLIGHT); - $this->mapSimple(Blocks::SHULKER_BOX(), Ids::UNDYED_SHULKER_BOX); - $this->mapSimple(Blocks::SLIME(), Ids::SLIME); - $this->mapSimple(Blocks::SMITHING_TABLE(), Ids::SMITHING_TABLE); $this->map(Blocks::SMOKER(), fn(Furnace $block) => Helper::encodeFurnace($block, Ids::SMOKER, Ids::LIT_SMOKER)); - $this->mapSimple(Blocks::SMOOTH_BASALT(), Ids::SMOOTH_BASALT); $this->map(Blocks::SMOOTH_QUARTZ(), fn() => Helper::encodeQuartz(StringValues::CHISEL_TYPE_SMOOTH, Axis::Y)); $this->map(Blocks::SMOOTH_QUARTZ_SLAB(), fn(Slab $block) => Helper::encodeStoneSlab4($block, StringValues::STONE_SLAB_TYPE_4_SMOOTH_QUARTZ)); $this->mapStairs(Blocks::SMOOTH_QUARTZ_STAIRS(), Ids::SMOOTH_QUARTZ_STAIRS); @@ -1219,9 +1233,7 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ $this->map(Blocks::SMOOTH_SANDSTONE(), fn() => Helper::encodeSandstone(Ids::SANDSTONE, StringValues::SAND_STONE_TYPE_SMOOTH)); $this->map(Blocks::SMOOTH_SANDSTONE_SLAB(), fn(Slab $block) => Helper::encodeStoneSlab2($block, StringValues::STONE_SLAB_TYPE_2_SMOOTH_SANDSTONE)); $this->mapStairs(Blocks::SMOOTH_SANDSTONE_STAIRS(), Ids::SMOOTH_SANDSTONE_STAIRS); - $this->mapSimple(Blocks::SMOOTH_STONE(), Ids::SMOOTH_STONE); $this->map(Blocks::SMOOTH_STONE_SLAB(), fn(Slab $block) => Helper::encodeStoneSlab1($block, StringValues::STONE_SLAB_TYPE_SMOOTH_STONE)); - $this->mapSimple(Blocks::SNOW(), Ids::SNOW); $this->map(Blocks::SNOW_LAYER(), function(SnowLayer $block) : Writer{ return Writer::create(Ids::SNOW_LAYER) ->writeBool(StateNames::COVERED_BIT, false) @@ -1235,8 +1247,6 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ return Writer::create(Ids::SOUL_LANTERN) ->writeBool(StateNames::HANGING, $block->isHanging()); }); - $this->mapSimple(Blocks::SOUL_SAND(), Ids::SOUL_SAND); - $this->mapSimple(Blocks::SOUL_SOIL(), Ids::SOUL_SOIL); $this->map(Blocks::SOUL_TORCH(), function(Torch $block) : Writer{ return Writer::create(Ids::SOUL_TORCH) ->writeTorchFacing($block->getFacing()); @@ -1304,7 +1314,6 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ }); $this->map(Blocks::TALL_GRASS(), fn() => Writer::create(Ids::TALLGRASS) ->writeString(StateNames::TALL_GRASS_TYPE, StringValues::TALL_GRASS_TYPE_TALL)); - $this->mapSimple(Blocks::TINTED_GLASS(), Ids::TINTED_GLASS); $this->map(Blocks::TNT(), function(TNT $block) : Writer{ return Writer::create(Ids::TNT) ->writeBool(StateNames::ALLOW_UNDERWATER_BIT, $block->worksUnderwater()) @@ -1331,7 +1340,6 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ ->writeBool(StateNames::POWERED_BIT, $block->isPowered()) ->writeLegacyHorizontalFacing($block->getFacing()); }); - $this->mapSimple(Blocks::TUFF(), Ids::TUFF); $this->map(Blocks::UNDERWATER_TORCH(), function(UnderwaterTorch $block) : Writer{ return Writer::create(Ids::UNDERWATER_TORCH) ->writeTorchFacing($block->getFacing()); @@ -1358,10 +1366,8 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ }); $this->map(Blocks::WARPED_BUTTON(), fn(Button $block) => Helper::encodeButton($block, new Writer(Ids::WARPED_BUTTON))); $this->map(Blocks::WARPED_DOOR(), fn(Door $block) => Helper::encodeDoor($block, new Writer(Ids::WARPED_DOOR))); - $this->mapSimple(Blocks::WARPED_FENCE(), Ids::WARPED_FENCE); $this->map(Blocks::WARPED_FENCE_GATE(), fn(FenceGate $block) => Helper::encodeFenceGate($block, new Writer(Ids::WARPED_FENCE_GATE))); $this->map(Blocks::WARPED_HYPHAE(), fn(Wood $block) => Helper::encodeNewLog($block, Ids::WARPED_HYPHAE, Ids::STRIPPED_WARPED_HYPHAE)); - $this->mapSimple(Blocks::WARPED_PLANKS(), Ids::WARPED_PLANKS); $this->map(Blocks::WARPED_PRESSURE_PLATE(), fn(SimplePressurePlate $block) => Helper::encodeSimplePressurePlate($block, new Writer(Ids::WARPED_PRESSURE_PLATE))); $this->map(Blocks::WARPED_SIGN(), fn(FloorSign $block) => Helper::encodeFloorSign($block, new Writer(Ids::WARPED_STANDING_SIGN))); $this->mapSlab(Blocks::WARPED_SLAB(), Ids::WARPED_SLAB, Ids::WARPED_DOUBLE_SLAB); @@ -1369,7 +1375,6 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ $this->map(Blocks::WARPED_STEM(), fn(Wood $block) => Helper::encodeNewLog($block, Ids::WARPED_STEM, Ids::STRIPPED_WARPED_STEM)); $this->map(Blocks::WARPED_TRAPDOOR(), fn(Trapdoor $block) => Helper::encodeTrapdoor($block, new Writer(Ids::WARPED_TRAPDOOR))); $this->map(Blocks::WARPED_WALL_SIGN(), fn(WallSign $block) => Helper::encodeWallSign($block, new Writer(Ids::WARPED_WALL_SIGN))); - $this->mapSimple(Blocks::WARPED_WART_BLOCK(), Ids::WARPED_WART_BLOCK); $this->map(Blocks::WATER(), fn(Water $block) => Helper::encodeLiquid($block, Ids::WATER, Ids::FLOWING_WATER)); $this->map(Blocks::WEIGHTED_PRESSURE_PLATE_HEAVY(), function(WeightedPressurePlateHeavy $block) : Writer{ return Writer::create(Ids::HEAVY_WEIGHTED_PRESSURE_PLATE) @@ -1381,7 +1386,6 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ }); $this->map(Blocks::WHEAT(), fn(Wheat $block) => Helper::encodeCrops($block, new Writer(Ids::WHEAT))); $this->map(Blocks::WHITE_TULIP(), fn() => Helper::encodeRedFlower(StringValues::FLOWER_TYPE_TULIP_WHITE)); - $this->mapSimple(Blocks::WITHER_ROSE(), Ids::WITHER_ROSE); $this->map(Blocks::WOOL(), function(Wool $block) : Writer{ return Writer::create(Ids::WOOL) ->writeColor($block->getColor()); diff --git a/src/data/bedrock/block/convert/BlockStateToBlockObjectDeserializer.php b/src/data/bedrock/block/convert/BlockStateToBlockObjectDeserializer.php index 8923008df..111abbc80 100644 --- a/src/data/bedrock/block/convert/BlockStateToBlockObjectDeserializer.php +++ b/src/data/bedrock/block/convert/BlockStateToBlockObjectDeserializer.php @@ -60,6 +60,7 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize public function __construct(){ $this->registerCandleDeserializers(); + $this->registerSimpleDeserializers(); $this->registerDeserializers(); } @@ -135,151 +136,20 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize $this->map(Ids::YELLOW_CANDLE_CAKE, $cakeWithDyedCandleDeserializer(DyeColor::YELLOW())); } - private function registerDeserializers() : void{ - $this->map(Ids::ACACIA_BUTTON, fn(Reader $in) => Helper::decodeButton(Blocks::ACACIA_BUTTON(), $in)); - $this->map(Ids::ACACIA_DOOR, fn(Reader $in) => Helper::decodeDoor(Blocks::ACACIA_DOOR(), $in)); - $this->map(Ids::ACACIA_FENCE_GATE, fn(Reader $in) => Helper::decodeFenceGate(Blocks::ACACIA_FENCE_GATE(), $in)); - $this->map(Ids::ACACIA_PRESSURE_PLATE, fn(Reader $in) => Helper::decodeSimplePressurePlate(Blocks::ACACIA_PRESSURE_PLATE(), $in)); - $this->mapStairs(Ids::ACACIA_STAIRS, fn() => Blocks::ACACIA_STAIRS()); - $this->map(Ids::ACACIA_STANDING_SIGN, fn(Reader $in) => Helper::decodeFloorSign(Blocks::ACACIA_SIGN(), $in)); - $this->map(Ids::ACACIA_TRAPDOOR, fn(Reader $in) => Helper::decodeTrapdoor(Blocks::ACACIA_TRAPDOOR(), $in)); - $this->map(Ids::ACACIA_WALL_SIGN, fn(Reader $in) => Helper::decodeWallSign(Blocks::ACACIA_WALL_SIGN(), $in)); - $this->map(Ids::ACTIVATOR_RAIL, function(Reader $in) : Block{ - return Blocks::ACTIVATOR_RAIL() - ->setPowered($in->readBool(StateNames::RAIL_DATA_BIT)) - ->setShape($in->readBoundedInt(StateNames::RAIL_DIRECTION, 0, 5)); - }); + private function registerSimpleDeserializers() : void{ $this->map(Ids::AIR, fn() => Blocks::AIR()); $this->map(Ids::AMETHYST_BLOCK, fn() => Blocks::AMETHYST()); $this->map(Ids::ANCIENT_DEBRIS, fn() => Blocks::ANCIENT_DEBRIS()); - $this->mapStairs(Ids::ANDESITE_STAIRS, fn() => Blocks::ANDESITE_STAIRS()); - $this->map(Ids::ANVIL, function(Reader $in) : Block{ - return Blocks::ANVIL() - ->setDamage(match($value = $in->readString(StateNames::DAMAGE)){ - StringValues::DAMAGE_UNDAMAGED => 0, - StringValues::DAMAGE_SLIGHTLY_DAMAGED => 1, - StringValues::DAMAGE_VERY_DAMAGED => 2, - StringValues::DAMAGE_BROKEN => 0, - default => throw $in->badValueException(StateNames::DAMAGE, $value), - }) - ->setFacing($in->readLegacyHorizontalFacing()); - }); - $this->map(Ids::BAMBOO, function(Reader $in) : Block{ - return Blocks::BAMBOO() - ->setLeafSize(match($value = $in->readString(StateNames::BAMBOO_LEAF_SIZE)){ - StringValues::BAMBOO_LEAF_SIZE_NO_LEAVES => Bamboo::NO_LEAVES, - StringValues::BAMBOO_LEAF_SIZE_SMALL_LEAVES => Bamboo::SMALL_LEAVES, - StringValues::BAMBOO_LEAF_SIZE_LARGE_LEAVES => Bamboo::LARGE_LEAVES, - default => throw $in->badValueException(StateNames::BAMBOO_LEAF_SIZE, $value), - }) - ->setReady($in->readBool(StateNames::AGE_BIT)) - ->setThick(match($value = $in->readString(StateNames::BAMBOO_STALK_THICKNESS)){ - StringValues::BAMBOO_STALK_THICKNESS_THIN => false, - StringValues::BAMBOO_STALK_THICKNESS_THICK => true, - default => throw $in->badValueException(StateNames::BAMBOO_STALK_THICKNESS, $value), - }); - }); - $this->map(Ids::BAMBOO_SAPLING, function(Reader $in) : Block{ - $in->ignored(StateNames::SAPLING_TYPE); //bug in MCPE - return Blocks::BAMBOO_SAPLING()->setReady($in->readBool(StateNames::AGE_BIT)); - }); - $this->map(Ids::BARREL, function(Reader $in) : Block{ - return Blocks::BARREL() - ->setFacing($in->readFacingDirection()) - ->setOpen($in->readBool(StateNames::OPEN_BIT)); - }); $this->map(Ids::BARRIER, fn() => Blocks::BARRIER()); - $this->map(Ids::BASALT, function(Reader $in){ - return Blocks::BASALT() - ->setAxis($in->readPillarAxis()); - }); $this->map(Ids::BEACON, fn() => Blocks::BEACON()); - $this->map(Ids::BED, function(Reader $in) : Block{ - return Blocks::BED() - ->setFacing($in->readLegacyHorizontalFacing()) - ->setHead($in->readBool(StateNames::HEAD_PIECE_BIT)) - ->setOccupied($in->readBool(StateNames::OCCUPIED_BIT)); - }); - $this->map(Ids::BEDROCK, function(Reader $in) : Block{ - return Blocks::BEDROCK() - ->setBurnsForever($in->readBool(StateNames::INFINIBURN_BIT)); - }); - $this->map(Ids::BEETROOT, fn(Reader $in) => Helper::decodeCrops(Blocks::BEETROOTS(), $in)); - $this->map(Ids::BELL, function(Reader $in) : Block{ - $in->ignored(StateNames::TOGGLE_BIT); //only useful at runtime - return Blocks::BELL() - ->setFacing($in->readLegacyHorizontalFacing()) - ->setAttachmentType($in->readBellAttachmentType()); - }); - $this->map(Ids::BIRCH_BUTTON, fn(Reader $in) => Helper::decodeButton(Blocks::BIRCH_BUTTON(), $in)); - $this->map(Ids::BIRCH_DOOR, fn(Reader $in) => Helper::decodeDoor(Blocks::BIRCH_DOOR(), $in)); - $this->map(Ids::BIRCH_FENCE_GATE, fn(Reader $in) => Helper::decodeFenceGate(Blocks::BIRCH_FENCE_GATE(), $in)); - $this->map(Ids::BIRCH_PRESSURE_PLATE, fn(Reader $in) => Helper::decodeSimplePressurePlate(Blocks::BIRCH_PRESSURE_PLATE(), $in)); - $this->mapStairs(Ids::BIRCH_STAIRS, fn() => Blocks::BIRCH_STAIRS()); - $this->map(Ids::BIRCH_STANDING_SIGN, fn(Reader $in) => Helper::decodeFloorSign(Blocks::BIRCH_SIGN(), $in)); - $this->map(Ids::BIRCH_TRAPDOOR, fn(Reader $in) => Helper::decodeTrapdoor(Blocks::BIRCH_TRAPDOOR(), $in)); - $this->map(Ids::BIRCH_WALL_SIGN, fn(Reader $in) => Helper::decodeWallSign(Blocks::BIRCH_WALL_SIGN(), $in)); $this->map(Ids::BLACKSTONE, fn() => Blocks::BLACKSTONE()); - $this->mapSlab(Ids::BLACKSTONE_SLAB, Ids::BLACKSTONE_DOUBLE_SLAB, fn() => Blocks::BLACKSTONE_SLAB()); - $this->mapStairs(Ids::BLACKSTONE_STAIRS, fn() => Blocks::BLACKSTONE_STAIRS()); - $this->map(Ids::BLACKSTONE_WALL, fn(Reader $in) => Helper::decodeWall(Blocks::BLACKSTONE_WALL(), $in)); - $this->map(Ids::BLACK_GLAZED_TERRACOTTA, fn(Reader $in) => Helper::decodeGlazedTerracotta(DyeColor::BLACK(), $in)); - $this->map(Ids::BLAST_FURNACE, function(Reader $in) : Block{ - return Blocks::BLAST_FURNACE() - ->setFacing($in->readHorizontalFacing()) - ->setLit(false); - }); - $this->map(Ids::BLUE_GLAZED_TERRACOTTA, fn(Reader $in) => Helper::decodeGlazedTerracotta(DyeColor::BLUE(), $in)); $this->map(Ids::BLUE_ICE, fn() => Blocks::BLUE_ICE()); - $this->map(Ids::BONE_BLOCK, function(Reader $in) : Block{ - $in->ignored(StateNames::DEPRECATED); - return Blocks::BONE_BLOCK()->setAxis($in->readPillarAxis()); - }); $this->map(Ids::BOOKSHELF, fn() => Blocks::BOOKSHELF()); - $this->map(Ids::BREWING_STAND, function(Reader $in) : Block{ - return Blocks::BREWING_STAND() - ->setSlot(BrewingStandSlot::EAST(), $in->readBool(StateNames::BREWING_STAND_SLOT_A_BIT)) - ->setSlot(BrewingStandSlot::SOUTHWEST(), $in->readBool(StateNames::BREWING_STAND_SLOT_B_BIT)) - ->setSlot(BrewingStandSlot::NORTHWEST(), $in->readBool(StateNames::BREWING_STAND_SLOT_C_BIT)); - }); $this->map(Ids::BRICK_BLOCK, fn() => Blocks::BRICKS()); - $this->mapStairs(Ids::BRICK_STAIRS, fn() => Blocks::BRICK_STAIRS()); - $this->map(Ids::BROWN_GLAZED_TERRACOTTA, fn(Reader $in) => Helper::decodeGlazedTerracotta(DyeColor::BROWN(), $in)); $this->map(Ids::BROWN_MUSHROOM, fn() => Blocks::BROWN_MUSHROOM()); - $this->map(Ids::BROWN_MUSHROOM_BLOCK, fn(Reader $in) => Helper::decodeMushroomBlock(Blocks::BROWN_MUSHROOM_BLOCK(), $in)); - $this->map(Ids::CACTUS, function(Reader $in) : Block{ - return Blocks::CACTUS() - ->setAge($in->readBoundedInt(StateNames::AGE, 0, 15)); - }); - $this->map(Ids::CAKE, function(Reader $in) : Block{ - return Blocks::CAKE() - ->setBites($in->readBoundedInt(StateNames::BITE_COUNTER, 0, 6)); - }); $this->map(Ids::CALCITE, fn() => Blocks::CALCITE()); - $this->map(Ids::CARPET, function(Reader $in) : Block{ - return Blocks::CARPET() - ->setColor($in->readColor()); - }); - $this->map(Ids::CARROTS, fn(Reader $in) => Helper::decodeCrops(Blocks::CARROTS(), $in)); $this->map(Ids::CARTOGRAPHY_TABLE, fn() => Blocks::CARTOGRAPHY_TABLE()); - $this->map(Ids::CARVED_PUMPKIN, function(Reader $in) : Block{ - return Blocks::CARVED_PUMPKIN() - ->setFacing($in->readLegacyHorizontalFacing()); - }); $this->map(Ids::CHEMICAL_HEAT, fn() => Blocks::CHEMICAL_HEAT()); - $this->map(Ids::CHEMISTRY_TABLE, function(Reader $in) : Block{ - return (match($type = $in->readString(StateNames::CHEMISTRY_TABLE_TYPE)){ - StringValues::CHEMISTRY_TABLE_TYPE_COMPOUND_CREATOR => Blocks::COMPOUND_CREATOR(), - StringValues::CHEMISTRY_TABLE_TYPE_ELEMENT_CONSTRUCTOR => Blocks::ELEMENT_CONSTRUCTOR(), - StringValues::CHEMISTRY_TABLE_TYPE_LAB_TABLE => Blocks::LAB_TABLE(), - StringValues::CHEMISTRY_TABLE_TYPE_MATERIAL_REDUCER => Blocks::MATERIAL_REDUCER(), - default => throw $in->badValueException(StateNames::CHEMISTRY_TABLE_TYPE, $type), - })->setFacing(Facing::opposite($in->readLegacyHorizontalFacing())); - }); - $this->map(Ids::CHEST, function(Reader $in) : Block{ - return Blocks::CHEST() - ->setFacing($in->readHorizontalFacing()); - }); $this->map(Ids::CHISELED_DEEPSLATE, fn() => Blocks::CHISELED_DEEPSLATE()); $this->map(Ids::CHISELED_NETHER_BRICKS, fn() => Blocks::CHISELED_NETHER_BRICKS()); $this->map(Ids::CHISELED_POLISHED_BLACKSTONE, fn() => Blocks::CHISELED_POLISHED_BLACKSTONE()); @@ -287,104 +157,18 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize $this->map(Ids::COAL_BLOCK, fn() => Blocks::COAL()); $this->map(Ids::COAL_ORE, fn() => Blocks::COAL_ORE()); $this->map(Ids::COBBLED_DEEPSLATE, fn() => Blocks::COBBLED_DEEPSLATE()); - $this->mapSlab(Ids::COBBLED_DEEPSLATE_SLAB, Ids::COBBLED_DEEPSLATE_DOUBLE_SLAB, fn() => Blocks::COBBLED_DEEPSLATE_SLAB()); - $this->mapStairs(Ids::COBBLED_DEEPSLATE_STAIRS, fn() => Blocks::COBBLED_DEEPSLATE_STAIRS()); - $this->map(Ids::COBBLED_DEEPSLATE_WALL, fn(Reader $in) => Helper::decodeWall(Blocks::COBBLED_DEEPSLATE_WALL(), $in)); $this->map(Ids::COBBLESTONE, fn() => Blocks::COBBLESTONE()); - $this->map(Ids::COBBLESTONE_WALL, fn(Reader $in) => Helper::mapLegacyWallType($in)); - $this->map(Ids::COCOA, function(Reader $in) : Block{ - return Blocks::COCOA_POD() - ->setAge($in->readBoundedInt(StateNames::AGE, 0, 2)) - ->setFacing(Facing::opposite($in->readLegacyHorizontalFacing())); - }); - $this->map(Ids::COLORED_TORCH_BP, function(Reader $in) : Block{ - return $in->readBool(StateNames::COLOR_BIT) ? - Blocks::PURPLE_TORCH()->setFacing($in->readTorchFacing()) : - Blocks::BLUE_TORCH()->setFacing($in->readTorchFacing()); - }); - $this->map(Ids::COLORED_TORCH_RG, function(Reader $in) : Block{ - return $in->readBool(StateNames::COLOR_BIT) ? - Blocks::GREEN_TORCH()->setFacing($in->readTorchFacing()) : - Blocks::RED_TORCH()->setFacing($in->readTorchFacing()); - }); - $this->map(Ids::CONCRETE, function(Reader $in) : Block{ - return Blocks::CONCRETE() - ->setColor($in->readColor()); - }); - $this->map(Ids::CONCRETE_POWDER, function(Reader $in) : Block{ - return Blocks::CONCRETE_POWDER() - ->setColor($in->readColor()); - }); - $this->map(Ids::COPPER_BLOCK, fn() => Helper::decodeCopper(Blocks::COPPER(), CopperOxidation::NONE())); - $this->map(Ids::CUT_COPPER, fn() => Helper::decodeCopper(Blocks::CUT_COPPER(), CopperOxidation::NONE())); - $this->mapSlab(Ids::CUT_COPPER_SLAB, Ids::DOUBLE_CUT_COPPER_SLAB, fn() => Helper::decodeCopper(Blocks::CUT_COPPER_SLAB(), CopperOxidation::NONE())); - $this->mapStairs(Ids::CUT_COPPER_STAIRS, fn() => Helper::decodeCopper(Blocks::CUT_COPPER_STAIRS(), CopperOxidation::NONE())); $this->map(Ids::COPPER_ORE, fn() => Blocks::COPPER_ORE()); - $this->map(Ids::CORAL, function(Reader $in) : Block{ - return Blocks::CORAL() - ->setCoralType($in->readCoralType()) - ->setDead($in->readBool(StateNames::DEAD_BIT)); - }); - $this->map(Ids::CORAL_BLOCK, function(Reader $in) : Block{ - return Blocks::CORAL_BLOCK() - ->setCoralType($in->readCoralType()) - ->setDead($in->readBool(StateNames::DEAD_BIT)); - }); - $this->map(Ids::CORAL_FAN, fn(Reader $in) => Helper::decodeFloorCoralFan(Blocks::CORAL_FAN(), $in) - ->setDead(false)); - $this->map(Ids::CORAL_FAN_DEAD, fn(Reader $in) => Helper::decodeFloorCoralFan(Blocks::CORAL_FAN(), $in) - ->setDead(true)); - $this->map(Ids::CORAL_FAN_HANG, fn(Reader $in) => Helper::decodeWallCoralFan(Blocks::WALL_CORAL_FAN(), $in) - ->setCoralType($in->readBool(StateNames::CORAL_HANG_TYPE_BIT) ? CoralType::BRAIN() : CoralType::TUBE())); - $this->map(Ids::CORAL_FAN_HANG2, fn(Reader $in) => Helper::decodeWallCoralFan(Blocks::WALL_CORAL_FAN(), $in) - ->setCoralType($in->readBool(StateNames::CORAL_HANG_TYPE_BIT) ? CoralType::FIRE() : CoralType::BUBBLE())); - $this->map(Ids::CORAL_FAN_HANG3, function(Reader $in) : Block{ - $in->ignored(StateNames::CORAL_HANG_TYPE_BIT); //the game always writes this, even though it's not used - return Helper::decodeWallCoralFan(Blocks::WALL_CORAL_FAN(), $in) - ->setCoralType(CoralType::HORN()); - }); $this->map(Ids::CRACKED_DEEPSLATE_BRICKS, fn() => Blocks::CRACKED_DEEPSLATE_BRICKS()); $this->map(Ids::CRACKED_DEEPSLATE_TILES, fn() => Blocks::CRACKED_DEEPSLATE_TILES()); $this->map(Ids::CRACKED_NETHER_BRICKS, fn() => Blocks::CRACKED_NETHER_BRICKS()); $this->map(Ids::CRACKED_POLISHED_BLACKSTONE_BRICKS, fn() => Blocks::CRACKED_POLISHED_BLACKSTONE_BRICKS()); $this->map(Ids::CRAFTING_TABLE, fn() => Blocks::CRAFTING_TABLE()); - $this->map(Ids::CRIMSON_BUTTON, fn(Reader $in) => Helper::decodeButton(Blocks::CRIMSON_BUTTON(), $in)); - $this->map(Ids::CRIMSON_DOOR, fn(Reader $in) => Helper::decodeDoor(Blocks::CRIMSON_DOOR(), $in)); - $this->mapSlab(Ids::CRIMSON_SLAB, Ids::CRIMSON_DOUBLE_SLAB, fn() => Blocks::CRIMSON_SLAB()); $this->map(Ids::CRIMSON_FENCE, fn() => Blocks::CRIMSON_FENCE()); - $this->map(Ids::CRIMSON_FENCE_GATE, fn(Reader $in) => Helper::decodeFenceGate(Blocks::CRIMSON_FENCE_GATE(), $in)); - $this->map(Ids::CRIMSON_HYPHAE, fn(Reader $in) => Helper::decodeLog(Blocks::CRIMSON_HYPHAE(), false, $in)); $this->map(Ids::CRIMSON_PLANKS, fn() => Blocks::CRIMSON_PLANKS()); - $this->map(Ids::CRIMSON_PRESSURE_PLATE, fn(Reader $in) => Helper::decodeSimplePressurePlate(Blocks::CRIMSON_PRESSURE_PLATE(), $in)); - $this->mapStairs(Ids::CRIMSON_STAIRS, fn() => Blocks::CRIMSON_STAIRS()); - $this->map(Ids::CRIMSON_STANDING_SIGN, fn(Reader $in) => Helper::decodeFloorSign(Blocks::CRIMSON_SIGN(), $in)); - $this->map(Ids::CRIMSON_STEM, fn(Reader $in) => Helper::decodeLog(Blocks::CRIMSON_STEM(), false, $in)); - $this->map(Ids::CRIMSON_TRAPDOOR, fn(Reader $in) => Helper::decodeTrapdoor(Blocks::CRIMSON_TRAPDOOR(), $in)); - $this->map(Ids::CRIMSON_WALL_SIGN, fn(Reader $in) => Helper::decodeWallSign(Blocks::CRIMSON_WALL_SIGN(), $in)); $this->map(Ids::CRYING_OBSIDIAN, fn() => Blocks::CRYING_OBSIDIAN()); - $this->map(Ids::CYAN_GLAZED_TERRACOTTA, fn(Reader $in) => Helper::decodeGlazedTerracotta(DyeColor::CYAN(), $in)); - $this->map(Ids::DARK_OAK_BUTTON, fn(Reader $in) => Helper::decodeButton(Blocks::DARK_OAK_BUTTON(), $in)); - $this->map(Ids::DARK_OAK_DOOR, fn(Reader $in) => Helper::decodeDoor(Blocks::DARK_OAK_DOOR(), $in)); - $this->map(Ids::DARK_OAK_FENCE_GATE, fn(Reader $in) => Helper::decodeFenceGate(Blocks::DARK_OAK_FENCE_GATE(), $in)); - $this->map(Ids::DARK_OAK_PRESSURE_PLATE, fn(Reader $in) => Helper::decodeSimplePressurePlate(Blocks::DARK_OAK_PRESSURE_PLATE(), $in)); - $this->mapStairs(Ids::DARK_OAK_STAIRS, fn() => Blocks::DARK_OAK_STAIRS()); - $this->map(Ids::DARK_OAK_TRAPDOOR, fn(Reader $in) => Helper::decodeTrapdoor(Blocks::DARK_OAK_TRAPDOOR(), $in)); - $this->mapStairs(Ids::DARK_PRISMARINE_STAIRS, fn() => Blocks::DARK_PRISMARINE_STAIRS()); - $this->map(Ids::DARKOAK_STANDING_SIGN, fn(Reader $in) => Helper::decodeFloorSign(Blocks::DARK_OAK_SIGN(), $in)); - $this->map(Ids::DARKOAK_WALL_SIGN, fn(Reader $in) => Helper::decodeWallSign(Blocks::DARK_OAK_WALL_SIGN(), $in)); - $this->map(Ids::DAYLIGHT_DETECTOR, fn(Reader $in) => Helper::decodeDaylightSensor(Blocks::DAYLIGHT_SENSOR(), $in) - ->setInverted(false)); - $this->map(Ids::DAYLIGHT_DETECTOR_INVERTED, fn(Reader $in) => Helper::decodeDaylightSensor(Blocks::DAYLIGHT_SENSOR(), $in) - ->setInverted(true)); $this->map(Ids::DEADBUSH, fn() => Blocks::DEAD_BUSH()); - $this->map(Ids::DEEPSLATE, function(Reader $in) : Block{ - return Blocks::DEEPSLATE() - ->setAxis($in->readPillarAxis()); - }); $this->map(Ids::DEEPSLATE_BRICKS, fn() => Blocks::DEEPSLATE_BRICKS()); - $this->mapSlab(Ids::DEEPSLATE_BRICK_SLAB, Ids::DEEPSLATE_BRICK_DOUBLE_SLAB, fn() => Blocks::DEEPSLATE_BRICK_SLAB()); - $this->mapStairs(Ids::DEEPSLATE_BRICK_STAIRS, fn() => Blocks::DEEPSLATE_BRICK_STAIRS()); - $this->map(Ids::DEEPSLATE_BRICK_WALL, fn(Reader $in) => Helper::decodeWall(Blocks::DEEPSLATE_BRICK_WALL(), $in)); $this->map(Ids::DEEPSLATE_COAL_ORE, fn() => Blocks::DEEPSLATE_COAL_ORE()); $this->map(Ids::DEEPSLATE_COPPER_ORE, fn() => Blocks::DEEPSLATE_COPPER_ORE()); $this->map(Ids::DEEPSLATE_DIAMOND_ORE, fn() => Blocks::DEEPSLATE_DIAMOND_ORE()); @@ -392,58 +176,9 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize $this->map(Ids::DEEPSLATE_GOLD_ORE, fn() => Blocks::DEEPSLATE_GOLD_ORE()); $this->map(Ids::DEEPSLATE_IRON_ORE, fn() => Blocks::DEEPSLATE_IRON_ORE()); $this->map(Ids::DEEPSLATE_LAPIS_ORE, fn() => Blocks::DEEPSLATE_LAPIS_LAZULI_ORE()); - $this->map(Ids::DEEPSLATE_REDSTONE_ORE, fn() => Blocks::DEEPSLATE_REDSTONE_ORE()->setLit(false)); $this->map(Ids::DEEPSLATE_TILES, fn() => Blocks::DEEPSLATE_TILES()); - $this->mapSlab(Ids::DEEPSLATE_TILE_SLAB, Ids::DEEPSLATE_TILE_DOUBLE_SLAB, fn() => Blocks::DEEPSLATE_TILE_SLAB()); - $this->mapStairs(Ids::DEEPSLATE_TILE_STAIRS, fn() => Blocks::DEEPSLATE_TILE_STAIRS()); - $this->map(Ids::DEEPSLATE_TILE_WALL, fn(Reader $in) => Helper::decodeWall(Blocks::DEEPSLATE_TILE_WALL(), $in)); - $this->map(Ids::DETECTOR_RAIL, function(Reader $in) : Block{ - return Blocks::DETECTOR_RAIL() - ->setActivated($in->readBool(StateNames::RAIL_DATA_BIT)) - ->setShape($in->readBoundedInt(StateNames::RAIL_DIRECTION, 0, 5)); - }); $this->map(Ids::DIAMOND_BLOCK, fn() => Blocks::DIAMOND()); $this->map(Ids::DIAMOND_ORE, fn() => Blocks::DIAMOND_ORE()); - $this->mapStairs(Ids::DIORITE_STAIRS, fn() => Blocks::DIORITE_STAIRS()); - $this->map(Ids::DIRT, function(Reader $in) : Block{ - return Blocks::DIRT() - ->setCoarse(match($value = $in->readString(StateNames::DIRT_TYPE)){ - StringValues::DIRT_TYPE_NORMAL => false, - StringValues::DIRT_TYPE_COARSE => true, - default => throw $in->badValueException(StateNames::DIRT_TYPE, $value), - }); - }); - $this->map(Ids::DOUBLE_PLANT, function(Reader $in) : Block{ - return (match($type = $in->readString(StateNames::DOUBLE_PLANT_TYPE)){ - StringValues::DOUBLE_PLANT_TYPE_FERN => Blocks::LARGE_FERN(), - StringValues::DOUBLE_PLANT_TYPE_GRASS => Blocks::DOUBLE_TALLGRASS(), - StringValues::DOUBLE_PLANT_TYPE_PAEONIA => Blocks::PEONY(), - StringValues::DOUBLE_PLANT_TYPE_ROSE => Blocks::ROSE_BUSH(), - StringValues::DOUBLE_PLANT_TYPE_SUNFLOWER => Blocks::SUNFLOWER(), - StringValues::DOUBLE_PLANT_TYPE_SYRINGA => Blocks::LILAC(), - default => throw $in->badValueException(StateNames::DOUBLE_PLANT_TYPE, $type), - })->setTop($in->readBool(StateNames::UPPER_BLOCK_BIT)); - }); - $this->map(Ids::DOUBLE_STONE_BLOCK_SLAB, function(Reader $in) : Block{ - $in->ignored(StateNames::TOP_SLOT_BIT); //useless for double slabs - return Helper::mapStoneSlab1Type($in)->setSlabType(SlabType::DOUBLE()); - }); - $this->map(Ids::DOUBLE_STONE_BLOCK_SLAB2, function(Reader $in) : Block{ - $in->ignored(StateNames::TOP_SLOT_BIT); //useless for double slabs - return Helper::mapStoneSlab2Type($in)->setSlabType(SlabType::DOUBLE()); - }); - $this->map(Ids::DOUBLE_STONE_BLOCK_SLAB3, function(Reader $in) : Block{ - $in->ignored(StateNames::TOP_SLOT_BIT); //useless for double slabs - return Helper::mapStoneSlab3Type($in)->setSlabType(SlabType::DOUBLE()); - }); - $this->map(Ids::DOUBLE_STONE_BLOCK_SLAB4, function(Reader $in) : Block{ - $in->ignored(StateNames::TOP_SLOT_BIT); //useless for double slabs - return Helper::mapStoneSlab4Type($in)->setSlabType(SlabType::DOUBLE()); - }); - $this->map(Ids::DOUBLE_WOODEN_SLAB, function(Reader $in) : Block{ - $in->ignored(StateNames::TOP_SLOT_BIT); //useless for double slabs - return Helper::mapWoodenSlabType($in)->setSlabType(SlabType::DOUBLE()); - }); $this->map(Ids::DRAGON_EGG, fn() => Blocks::DRAGON_EGG()); $this->map(Ids::DRIED_KELP_BLOCK, fn() => Blocks::DRIED_KELP()); $this->map(Ids::ELEMENT_0, fn() => Blocks::ELEMENT_ZERO()); @@ -568,8 +303,355 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize $this->map(Ids::EMERALD_BLOCK, fn() => Blocks::EMERALD()); $this->map(Ids::EMERALD_ORE, fn() => Blocks::EMERALD_ORE()); $this->map(Ids::ENCHANTING_TABLE, fn() => Blocks::ENCHANTING_TABLE()); - $this->mapStairs(Ids::END_BRICK_STAIRS, fn() => Blocks::END_STONE_BRICK_STAIRS()); $this->map(Ids::END_BRICKS, fn() => Blocks::END_STONE_BRICKS()); + $this->map(Ids::END_STONE, fn() => Blocks::END_STONE()); + $this->map(Ids::FLETCHING_TABLE, fn() => Blocks::FLETCHING_TABLE()); + $this->map(Ids::GILDED_BLACKSTONE, fn() => Blocks::GILDED_BLACKSTONE()); + $this->map(Ids::GLASS, fn() => Blocks::GLASS()); + $this->map(Ids::GLASS_PANE, fn() => Blocks::GLASS_PANE()); + $this->map(Ids::GLOWINGOBSIDIAN, fn() => Blocks::GLOWING_OBSIDIAN()); + $this->map(Ids::GLOWSTONE, fn() => Blocks::GLOWSTONE()); + $this->map(Ids::GOLD_BLOCK, fn() => Blocks::GOLD()); + $this->map(Ids::GOLD_ORE, fn() => Blocks::GOLD_ORE()); + $this->map(Ids::GRASS, fn() => Blocks::GRASS()); + $this->map(Ids::GRASS_PATH, fn() => Blocks::GRASS_PATH()); + $this->map(Ids::GRAVEL, fn() => Blocks::GRAVEL()); + $this->map(Ids::HANGING_ROOTS, fn() => Blocks::HANGING_ROOTS()); + $this->map(Ids::HARD_GLASS, fn() => Blocks::HARDENED_GLASS()); + $this->map(Ids::HARD_GLASS_PANE, fn() => Blocks::HARDENED_GLASS_PANE()); + $this->map(Ids::HARDENED_CLAY, fn() => Blocks::HARDENED_CLAY()); + $this->map(Ids::HONEYCOMB_BLOCK, fn() => Blocks::HONEYCOMB()); + $this->map(Ids::ICE, fn() => Blocks::ICE()); + $this->map(Ids::INFO_UPDATE, fn() => Blocks::INFO_UPDATE()); + $this->map(Ids::INFO_UPDATE2, fn() => Blocks::INFO_UPDATE2()); + $this->map(Ids::INVISIBLE_BEDROCK, fn() => Blocks::INVISIBLE_BEDROCK()); + $this->map(Ids::IRON_BARS, fn() => Blocks::IRON_BARS()); + $this->map(Ids::IRON_BLOCK, fn() => Blocks::IRON()); + $this->map(Ids::IRON_ORE, fn() => Blocks::IRON_ORE()); + $this->map(Ids::JUKEBOX, fn() => Blocks::JUKEBOX()); + $this->map(Ids::LAPIS_BLOCK, fn() => Blocks::LAPIS_LAZULI()); + $this->map(Ids::LAPIS_ORE, fn() => Blocks::LAPIS_LAZULI_ORE()); + $this->map(Ids::MAGMA, fn() => Blocks::MAGMA()); + $this->map(Ids::MANGROVE_FENCE, fn() => Blocks::MANGROVE_FENCE()); + $this->map(Ids::MANGROVE_PLANKS, fn() => Blocks::MANGROVE_PLANKS()); + $this->map(Ids::MELON_BLOCK, fn() => Blocks::MELON()); + $this->map(Ids::MOB_SPAWNER, fn() => Blocks::MONSTER_SPAWNER()); + $this->map(Ids::MOSSY_COBBLESTONE, fn() => Blocks::MOSSY_COBBLESTONE()); + $this->map(Ids::MUD_BRICKS, fn() => Blocks::MUD_BRICKS()); + $this->map(Ids::MYCELIUM, fn() => Blocks::MYCELIUM()); + $this->map(Ids::NETHER_BRICK, fn() => Blocks::NETHER_BRICKS()); + $this->map(Ids::NETHER_BRICK_FENCE, fn() => Blocks::NETHER_BRICK_FENCE()); + $this->map(Ids::NETHER_GOLD_ORE, fn() => Blocks::NETHER_GOLD_ORE()); + $this->map(Ids::NETHER_WART_BLOCK, fn() => Blocks::NETHER_WART_BLOCK()); + $this->map(Ids::NETHERITE_BLOCK, fn() => Blocks::NETHERITE()); + $this->map(Ids::NETHERRACK, fn() => Blocks::NETHERRACK()); + $this->map(Ids::NETHERREACTOR, fn() => Blocks::NETHER_REACTOR_CORE()); + $this->map(Ids::NOTEBLOCK, fn() => Blocks::NOTE_BLOCK()); + $this->map(Ids::OBSIDIAN, fn() => Blocks::OBSIDIAN()); + $this->map(Ids::PACKED_ICE, fn() => Blocks::PACKED_ICE()); + $this->map(Ids::PODZOL, fn() => Blocks::PODZOL()); + $this->map(Ids::POLISHED_BLACKSTONE, fn() => Blocks::POLISHED_BLACKSTONE()); + $this->map(Ids::POLISHED_BLACKSTONE_BRICKS, fn() => Blocks::POLISHED_BLACKSTONE_BRICKS()); + $this->map(Ids::POLISHED_DEEPSLATE, fn() => Blocks::POLISHED_DEEPSLATE()); + $this->map(Ids::QUARTZ_BRICKS, fn() => Blocks::QUARTZ_BRICKS()); + $this->map(Ids::QUARTZ_ORE, fn() => Blocks::NETHER_QUARTZ_ORE()); + $this->map(Ids::RAW_COPPER_BLOCK, fn() => Blocks::RAW_COPPER()); + $this->map(Ids::RAW_GOLD_BLOCK, fn() => Blocks::RAW_GOLD()); + $this->map(Ids::RAW_IRON_BLOCK, fn() => Blocks::RAW_IRON()); + $this->map(Ids::RED_MUSHROOM, fn() => Blocks::RED_MUSHROOM()); + $this->map(Ids::RED_NETHER_BRICK, fn() => Blocks::RED_NETHER_BRICKS()); + $this->map(Ids::REDSTONE_BLOCK, fn() => Blocks::REDSTONE()); + $this->map(Ids::RESERVED6, fn() => Blocks::RESERVED6()); + $this->map(Ids::SEA_LANTERN, fn() => Blocks::SEA_LANTERN()); + $this->map(Ids::SHROOMLIGHT, fn() => Blocks::SHROOMLIGHT()); + $this->map(Ids::SLIME, fn() => Blocks::SLIME()); + $this->map(Ids::SMITHING_TABLE, fn() => Blocks::SMITHING_TABLE()); + $this->map(Ids::SMOOTH_BASALT, fn() => Blocks::SMOOTH_BASALT()); + $this->map(Ids::SMOOTH_STONE, fn() => Blocks::SMOOTH_STONE()); + $this->map(Ids::SNOW, fn() => Blocks::SNOW()); + $this->map(Ids::SOUL_SAND, fn() => Blocks::SOUL_SAND()); + $this->map(Ids::SOUL_SOIL, fn() => Blocks::SOUL_SOIL()); + $this->map(Ids::STONECUTTER, fn() => Blocks::LEGACY_STONECUTTER()); + $this->map(Ids::TINTED_GLASS, fn() => Blocks::TINTED_GLASS()); + $this->map(Ids::TUFF, fn() => Blocks::TUFF()); + $this->map(Ids::UNDYED_SHULKER_BOX, fn() => Blocks::SHULKER_BOX()); + $this->map(Ids::WARPED_FENCE, fn() => Blocks::WARPED_FENCE()); + $this->map(Ids::WARPED_PLANKS, fn() => Blocks::WARPED_PLANKS()); + $this->map(Ids::WARPED_WART_BLOCK, fn() => Blocks::WARPED_WART_BLOCK()); + $this->map(Ids::WATERLILY, fn() => Blocks::LILY_PAD()); + $this->map(Ids::WEB, fn() => Blocks::COBWEB()); + $this->map(Ids::WITHER_ROSE, fn() => Blocks::WITHER_ROSE()); + $this->map(Ids::YELLOW_FLOWER, fn() => Blocks::DANDELION()); + } + + private function registerDeserializers() : void{ + $this->map(Ids::ACACIA_BUTTON, fn(Reader $in) => Helper::decodeButton(Blocks::ACACIA_BUTTON(), $in)); + $this->map(Ids::ACACIA_DOOR, fn(Reader $in) => Helper::decodeDoor(Blocks::ACACIA_DOOR(), $in)); + $this->map(Ids::ACACIA_FENCE_GATE, fn(Reader $in) => Helper::decodeFenceGate(Blocks::ACACIA_FENCE_GATE(), $in)); + $this->map(Ids::ACACIA_PRESSURE_PLATE, fn(Reader $in) => Helper::decodeSimplePressurePlate(Blocks::ACACIA_PRESSURE_PLATE(), $in)); + $this->mapStairs(Ids::ACACIA_STAIRS, fn() => Blocks::ACACIA_STAIRS()); + $this->map(Ids::ACACIA_STANDING_SIGN, fn(Reader $in) => Helper::decodeFloorSign(Blocks::ACACIA_SIGN(), $in)); + $this->map(Ids::ACACIA_TRAPDOOR, fn(Reader $in) => Helper::decodeTrapdoor(Blocks::ACACIA_TRAPDOOR(), $in)); + $this->map(Ids::ACACIA_WALL_SIGN, fn(Reader $in) => Helper::decodeWallSign(Blocks::ACACIA_WALL_SIGN(), $in)); + $this->map(Ids::ACTIVATOR_RAIL, function(Reader $in) : Block{ + return Blocks::ACTIVATOR_RAIL() + ->setPowered($in->readBool(StateNames::RAIL_DATA_BIT)) + ->setShape($in->readBoundedInt(StateNames::RAIL_DIRECTION, 0, 5)); + }); + $this->mapStairs(Ids::ANDESITE_STAIRS, fn() => Blocks::ANDESITE_STAIRS()); + $this->map(Ids::ANVIL, function(Reader $in) : Block{ + return Blocks::ANVIL() + ->setDamage(match($value = $in->readString(StateNames::DAMAGE)){ + StringValues::DAMAGE_UNDAMAGED => 0, + StringValues::DAMAGE_SLIGHTLY_DAMAGED => 1, + StringValues::DAMAGE_VERY_DAMAGED => 2, + StringValues::DAMAGE_BROKEN => 0, + default => throw $in->badValueException(StateNames::DAMAGE, $value), + }) + ->setFacing($in->readLegacyHorizontalFacing()); + }); + $this->map(Ids::BAMBOO, function(Reader $in) : Block{ + return Blocks::BAMBOO() + ->setLeafSize(match($value = $in->readString(StateNames::BAMBOO_LEAF_SIZE)){ + StringValues::BAMBOO_LEAF_SIZE_NO_LEAVES => Bamboo::NO_LEAVES, + StringValues::BAMBOO_LEAF_SIZE_SMALL_LEAVES => Bamboo::SMALL_LEAVES, + StringValues::BAMBOO_LEAF_SIZE_LARGE_LEAVES => Bamboo::LARGE_LEAVES, + default => throw $in->badValueException(StateNames::BAMBOO_LEAF_SIZE, $value), + }) + ->setReady($in->readBool(StateNames::AGE_BIT)) + ->setThick(match($value = $in->readString(StateNames::BAMBOO_STALK_THICKNESS)){ + StringValues::BAMBOO_STALK_THICKNESS_THIN => false, + StringValues::BAMBOO_STALK_THICKNESS_THICK => true, + default => throw $in->badValueException(StateNames::BAMBOO_STALK_THICKNESS, $value), + }); + }); + $this->map(Ids::BAMBOO_SAPLING, function(Reader $in) : Block{ + $in->ignored(StateNames::SAPLING_TYPE); //bug in MCPE + return Blocks::BAMBOO_SAPLING()->setReady($in->readBool(StateNames::AGE_BIT)); + }); + $this->map(Ids::BARREL, function(Reader $in) : Block{ + return Blocks::BARREL() + ->setFacing($in->readFacingDirection()) + ->setOpen($in->readBool(StateNames::OPEN_BIT)); + }); + $this->map(Ids::BASALT, function(Reader $in){ + return Blocks::BASALT() + ->setAxis($in->readPillarAxis()); + }); + $this->map(Ids::BED, function(Reader $in) : Block{ + return Blocks::BED() + ->setFacing($in->readLegacyHorizontalFacing()) + ->setHead($in->readBool(StateNames::HEAD_PIECE_BIT)) + ->setOccupied($in->readBool(StateNames::OCCUPIED_BIT)); + }); + $this->map(Ids::BEDROCK, function(Reader $in) : Block{ + return Blocks::BEDROCK() + ->setBurnsForever($in->readBool(StateNames::INFINIBURN_BIT)); + }); + $this->map(Ids::BEETROOT, fn(Reader $in) => Helper::decodeCrops(Blocks::BEETROOTS(), $in)); + $this->map(Ids::BELL, function(Reader $in) : Block{ + $in->ignored(StateNames::TOGGLE_BIT); //only useful at runtime + return Blocks::BELL() + ->setFacing($in->readLegacyHorizontalFacing()) + ->setAttachmentType($in->readBellAttachmentType()); + }); + $this->map(Ids::BIRCH_BUTTON, fn(Reader $in) => Helper::decodeButton(Blocks::BIRCH_BUTTON(), $in)); + $this->map(Ids::BIRCH_DOOR, fn(Reader $in) => Helper::decodeDoor(Blocks::BIRCH_DOOR(), $in)); + $this->map(Ids::BIRCH_FENCE_GATE, fn(Reader $in) => Helper::decodeFenceGate(Blocks::BIRCH_FENCE_GATE(), $in)); + $this->map(Ids::BIRCH_PRESSURE_PLATE, fn(Reader $in) => Helper::decodeSimplePressurePlate(Blocks::BIRCH_PRESSURE_PLATE(), $in)); + $this->mapStairs(Ids::BIRCH_STAIRS, fn() => Blocks::BIRCH_STAIRS()); + $this->map(Ids::BIRCH_STANDING_SIGN, fn(Reader $in) => Helper::decodeFloorSign(Blocks::BIRCH_SIGN(), $in)); + $this->map(Ids::BIRCH_TRAPDOOR, fn(Reader $in) => Helper::decodeTrapdoor(Blocks::BIRCH_TRAPDOOR(), $in)); + $this->map(Ids::BIRCH_WALL_SIGN, fn(Reader $in) => Helper::decodeWallSign(Blocks::BIRCH_WALL_SIGN(), $in)); + $this->mapSlab(Ids::BLACKSTONE_SLAB, Ids::BLACKSTONE_DOUBLE_SLAB, fn() => Blocks::BLACKSTONE_SLAB()); + $this->mapStairs(Ids::BLACKSTONE_STAIRS, fn() => Blocks::BLACKSTONE_STAIRS()); + $this->map(Ids::BLACKSTONE_WALL, fn(Reader $in) => Helper::decodeWall(Blocks::BLACKSTONE_WALL(), $in)); + $this->map(Ids::BLACK_GLAZED_TERRACOTTA, fn(Reader $in) => Helper::decodeGlazedTerracotta(DyeColor::BLACK(), $in)); + $this->map(Ids::BLAST_FURNACE, function(Reader $in) : Block{ + return Blocks::BLAST_FURNACE() + ->setFacing($in->readHorizontalFacing()) + ->setLit(false); + }); + $this->map(Ids::BLUE_GLAZED_TERRACOTTA, fn(Reader $in) => Helper::decodeGlazedTerracotta(DyeColor::BLUE(), $in)); + $this->map(Ids::BONE_BLOCK, function(Reader $in) : Block{ + $in->ignored(StateNames::DEPRECATED); + return Blocks::BONE_BLOCK()->setAxis($in->readPillarAxis()); + }); + $this->map(Ids::BREWING_STAND, function(Reader $in) : Block{ + return Blocks::BREWING_STAND() + ->setSlot(BrewingStandSlot::EAST(), $in->readBool(StateNames::BREWING_STAND_SLOT_A_BIT)) + ->setSlot(BrewingStandSlot::SOUTHWEST(), $in->readBool(StateNames::BREWING_STAND_SLOT_B_BIT)) + ->setSlot(BrewingStandSlot::NORTHWEST(), $in->readBool(StateNames::BREWING_STAND_SLOT_C_BIT)); + }); + $this->mapStairs(Ids::BRICK_STAIRS, fn() => Blocks::BRICK_STAIRS()); + $this->map(Ids::BROWN_GLAZED_TERRACOTTA, fn(Reader $in) => Helper::decodeGlazedTerracotta(DyeColor::BROWN(), $in)); + $this->map(Ids::BROWN_MUSHROOM_BLOCK, fn(Reader $in) => Helper::decodeMushroomBlock(Blocks::BROWN_MUSHROOM_BLOCK(), $in)); + $this->map(Ids::CACTUS, function(Reader $in) : Block{ + return Blocks::CACTUS() + ->setAge($in->readBoundedInt(StateNames::AGE, 0, 15)); + }); + $this->map(Ids::CAKE, function(Reader $in) : Block{ + return Blocks::CAKE() + ->setBites($in->readBoundedInt(StateNames::BITE_COUNTER, 0, 6)); + }); + $this->map(Ids::CARPET, function(Reader $in) : Block{ + return Blocks::CARPET() + ->setColor($in->readColor()); + }); + $this->map(Ids::CARROTS, fn(Reader $in) => Helper::decodeCrops(Blocks::CARROTS(), $in)); + $this->map(Ids::CARVED_PUMPKIN, function(Reader $in) : Block{ + return Blocks::CARVED_PUMPKIN() + ->setFacing($in->readLegacyHorizontalFacing()); + }); + $this->map(Ids::CHEMISTRY_TABLE, function(Reader $in) : Block{ + return (match($type = $in->readString(StateNames::CHEMISTRY_TABLE_TYPE)){ + StringValues::CHEMISTRY_TABLE_TYPE_COMPOUND_CREATOR => Blocks::COMPOUND_CREATOR(), + StringValues::CHEMISTRY_TABLE_TYPE_ELEMENT_CONSTRUCTOR => Blocks::ELEMENT_CONSTRUCTOR(), + StringValues::CHEMISTRY_TABLE_TYPE_LAB_TABLE => Blocks::LAB_TABLE(), + StringValues::CHEMISTRY_TABLE_TYPE_MATERIAL_REDUCER => Blocks::MATERIAL_REDUCER(), + default => throw $in->badValueException(StateNames::CHEMISTRY_TABLE_TYPE, $type), + })->setFacing(Facing::opposite($in->readLegacyHorizontalFacing())); + }); + $this->map(Ids::CHEST, function(Reader $in) : Block{ + return Blocks::CHEST() + ->setFacing($in->readHorizontalFacing()); + }); + $this->mapSlab(Ids::COBBLED_DEEPSLATE_SLAB, Ids::COBBLED_DEEPSLATE_DOUBLE_SLAB, fn() => Blocks::COBBLED_DEEPSLATE_SLAB()); + $this->mapStairs(Ids::COBBLED_DEEPSLATE_STAIRS, fn() => Blocks::COBBLED_DEEPSLATE_STAIRS()); + $this->map(Ids::COBBLED_DEEPSLATE_WALL, fn(Reader $in) => Helper::decodeWall(Blocks::COBBLED_DEEPSLATE_WALL(), $in)); + $this->map(Ids::COBBLESTONE_WALL, fn(Reader $in) => Helper::mapLegacyWallType($in)); + $this->map(Ids::COCOA, function(Reader $in) : Block{ + return Blocks::COCOA_POD() + ->setAge($in->readBoundedInt(StateNames::AGE, 0, 2)) + ->setFacing(Facing::opposite($in->readLegacyHorizontalFacing())); + }); + $this->map(Ids::COLORED_TORCH_BP, function(Reader $in) : Block{ + return $in->readBool(StateNames::COLOR_BIT) ? + Blocks::PURPLE_TORCH()->setFacing($in->readTorchFacing()) : + Blocks::BLUE_TORCH()->setFacing($in->readTorchFacing()); + }); + $this->map(Ids::COLORED_TORCH_RG, function(Reader $in) : Block{ + return $in->readBool(StateNames::COLOR_BIT) ? + Blocks::GREEN_TORCH()->setFacing($in->readTorchFacing()) : + Blocks::RED_TORCH()->setFacing($in->readTorchFacing()); + }); + $this->map(Ids::CONCRETE, function(Reader $in) : Block{ + return Blocks::CONCRETE() + ->setColor($in->readColor()); + }); + $this->map(Ids::CONCRETE_POWDER, function(Reader $in) : Block{ + return Blocks::CONCRETE_POWDER() + ->setColor($in->readColor()); + }); + $this->map(Ids::COPPER_BLOCK, fn() => Helper::decodeCopper(Blocks::COPPER(), CopperOxidation::NONE())); + $this->map(Ids::CUT_COPPER, fn() => Helper::decodeCopper(Blocks::CUT_COPPER(), CopperOxidation::NONE())); + $this->mapSlab(Ids::CUT_COPPER_SLAB, Ids::DOUBLE_CUT_COPPER_SLAB, fn() => Helper::decodeCopper(Blocks::CUT_COPPER_SLAB(), CopperOxidation::NONE())); + $this->mapStairs(Ids::CUT_COPPER_STAIRS, fn() => Helper::decodeCopper(Blocks::CUT_COPPER_STAIRS(), CopperOxidation::NONE())); + $this->map(Ids::CORAL, function(Reader $in) : Block{ + return Blocks::CORAL() + ->setCoralType($in->readCoralType()) + ->setDead($in->readBool(StateNames::DEAD_BIT)); + }); + $this->map(Ids::CORAL_BLOCK, function(Reader $in) : Block{ + return Blocks::CORAL_BLOCK() + ->setCoralType($in->readCoralType()) + ->setDead($in->readBool(StateNames::DEAD_BIT)); + }); + $this->map(Ids::CORAL_FAN, fn(Reader $in) => Helper::decodeFloorCoralFan(Blocks::CORAL_FAN(), $in) + ->setDead(false)); + $this->map(Ids::CORAL_FAN_DEAD, fn(Reader $in) => Helper::decodeFloorCoralFan(Blocks::CORAL_FAN(), $in) + ->setDead(true)); + $this->map(Ids::CORAL_FAN_HANG, fn(Reader $in) => Helper::decodeWallCoralFan(Blocks::WALL_CORAL_FAN(), $in) + ->setCoralType($in->readBool(StateNames::CORAL_HANG_TYPE_BIT) ? CoralType::BRAIN() : CoralType::TUBE())); + $this->map(Ids::CORAL_FAN_HANG2, fn(Reader $in) => Helper::decodeWallCoralFan(Blocks::WALL_CORAL_FAN(), $in) + ->setCoralType($in->readBool(StateNames::CORAL_HANG_TYPE_BIT) ? CoralType::FIRE() : CoralType::BUBBLE())); + $this->map(Ids::CORAL_FAN_HANG3, function(Reader $in) : Block{ + $in->ignored(StateNames::CORAL_HANG_TYPE_BIT); //the game always writes this, even though it's not used + return Helper::decodeWallCoralFan(Blocks::WALL_CORAL_FAN(), $in) + ->setCoralType(CoralType::HORN()); + }); + $this->map(Ids::CRIMSON_BUTTON, fn(Reader $in) => Helper::decodeButton(Blocks::CRIMSON_BUTTON(), $in)); + $this->map(Ids::CRIMSON_DOOR, fn(Reader $in) => Helper::decodeDoor(Blocks::CRIMSON_DOOR(), $in)); + $this->mapSlab(Ids::CRIMSON_SLAB, Ids::CRIMSON_DOUBLE_SLAB, fn() => Blocks::CRIMSON_SLAB()); + $this->map(Ids::CRIMSON_FENCE_GATE, fn(Reader $in) => Helper::decodeFenceGate(Blocks::CRIMSON_FENCE_GATE(), $in)); + $this->map(Ids::CRIMSON_HYPHAE, fn(Reader $in) => Helper::decodeLog(Blocks::CRIMSON_HYPHAE(), false, $in)); + $this->map(Ids::CRIMSON_PRESSURE_PLATE, fn(Reader $in) => Helper::decodeSimplePressurePlate(Blocks::CRIMSON_PRESSURE_PLATE(), $in)); + $this->mapStairs(Ids::CRIMSON_STAIRS, fn() => Blocks::CRIMSON_STAIRS()); + $this->map(Ids::CRIMSON_STANDING_SIGN, fn(Reader $in) => Helper::decodeFloorSign(Blocks::CRIMSON_SIGN(), $in)); + $this->map(Ids::CRIMSON_STEM, fn(Reader $in) => Helper::decodeLog(Blocks::CRIMSON_STEM(), false, $in)); + $this->map(Ids::CRIMSON_TRAPDOOR, fn(Reader $in) => Helper::decodeTrapdoor(Blocks::CRIMSON_TRAPDOOR(), $in)); + $this->map(Ids::CRIMSON_WALL_SIGN, fn(Reader $in) => Helper::decodeWallSign(Blocks::CRIMSON_WALL_SIGN(), $in)); + $this->map(Ids::CYAN_GLAZED_TERRACOTTA, fn(Reader $in) => Helper::decodeGlazedTerracotta(DyeColor::CYAN(), $in)); + $this->map(Ids::DARK_OAK_BUTTON, fn(Reader $in) => Helper::decodeButton(Blocks::DARK_OAK_BUTTON(), $in)); + $this->map(Ids::DARK_OAK_DOOR, fn(Reader $in) => Helper::decodeDoor(Blocks::DARK_OAK_DOOR(), $in)); + $this->map(Ids::DARK_OAK_FENCE_GATE, fn(Reader $in) => Helper::decodeFenceGate(Blocks::DARK_OAK_FENCE_GATE(), $in)); + $this->map(Ids::DARK_OAK_PRESSURE_PLATE, fn(Reader $in) => Helper::decodeSimplePressurePlate(Blocks::DARK_OAK_PRESSURE_PLATE(), $in)); + $this->mapStairs(Ids::DARK_OAK_STAIRS, fn() => Blocks::DARK_OAK_STAIRS()); + $this->map(Ids::DARK_OAK_TRAPDOOR, fn(Reader $in) => Helper::decodeTrapdoor(Blocks::DARK_OAK_TRAPDOOR(), $in)); + $this->mapStairs(Ids::DARK_PRISMARINE_STAIRS, fn() => Blocks::DARK_PRISMARINE_STAIRS()); + $this->map(Ids::DARKOAK_STANDING_SIGN, fn(Reader $in) => Helper::decodeFloorSign(Blocks::DARK_OAK_SIGN(), $in)); + $this->map(Ids::DARKOAK_WALL_SIGN, fn(Reader $in) => Helper::decodeWallSign(Blocks::DARK_OAK_WALL_SIGN(), $in)); + $this->map(Ids::DAYLIGHT_DETECTOR, fn(Reader $in) => Helper::decodeDaylightSensor(Blocks::DAYLIGHT_SENSOR(), $in) + ->setInverted(false)); + $this->map(Ids::DAYLIGHT_DETECTOR_INVERTED, fn(Reader $in) => Helper::decodeDaylightSensor(Blocks::DAYLIGHT_SENSOR(), $in) + ->setInverted(true)); + $this->map(Ids::DEEPSLATE, function(Reader $in) : Block{ + return Blocks::DEEPSLATE() + ->setAxis($in->readPillarAxis()); + }); + $this->mapSlab(Ids::DEEPSLATE_BRICK_SLAB, Ids::DEEPSLATE_BRICK_DOUBLE_SLAB, fn() => Blocks::DEEPSLATE_BRICK_SLAB()); + $this->mapStairs(Ids::DEEPSLATE_BRICK_STAIRS, fn() => Blocks::DEEPSLATE_BRICK_STAIRS()); + $this->map(Ids::DEEPSLATE_BRICK_WALL, fn(Reader $in) => Helper::decodeWall(Blocks::DEEPSLATE_BRICK_WALL(), $in)); + $this->map(Ids::DEEPSLATE_REDSTONE_ORE, fn() => Blocks::DEEPSLATE_REDSTONE_ORE()->setLit(false)); + $this->mapSlab(Ids::DEEPSLATE_TILE_SLAB, Ids::DEEPSLATE_TILE_DOUBLE_SLAB, fn() => Blocks::DEEPSLATE_TILE_SLAB()); + $this->mapStairs(Ids::DEEPSLATE_TILE_STAIRS, fn() => Blocks::DEEPSLATE_TILE_STAIRS()); + $this->map(Ids::DEEPSLATE_TILE_WALL, fn(Reader $in) => Helper::decodeWall(Blocks::DEEPSLATE_TILE_WALL(), $in)); + $this->map(Ids::DETECTOR_RAIL, function(Reader $in) : Block{ + return Blocks::DETECTOR_RAIL() + ->setActivated($in->readBool(StateNames::RAIL_DATA_BIT)) + ->setShape($in->readBoundedInt(StateNames::RAIL_DIRECTION, 0, 5)); + }); + $this->mapStairs(Ids::DIORITE_STAIRS, fn() => Blocks::DIORITE_STAIRS()); + $this->map(Ids::DIRT, function(Reader $in) : Block{ + return Blocks::DIRT() + ->setCoarse(match($value = $in->readString(StateNames::DIRT_TYPE)){ + StringValues::DIRT_TYPE_NORMAL => false, + StringValues::DIRT_TYPE_COARSE => true, + default => throw $in->badValueException(StateNames::DIRT_TYPE, $value), + }); + }); + $this->map(Ids::DOUBLE_PLANT, function(Reader $in) : Block{ + return (match($type = $in->readString(StateNames::DOUBLE_PLANT_TYPE)){ + StringValues::DOUBLE_PLANT_TYPE_FERN => Blocks::LARGE_FERN(), + StringValues::DOUBLE_PLANT_TYPE_GRASS => Blocks::DOUBLE_TALLGRASS(), + StringValues::DOUBLE_PLANT_TYPE_PAEONIA => Blocks::PEONY(), + StringValues::DOUBLE_PLANT_TYPE_ROSE => Blocks::ROSE_BUSH(), + StringValues::DOUBLE_PLANT_TYPE_SUNFLOWER => Blocks::SUNFLOWER(), + StringValues::DOUBLE_PLANT_TYPE_SYRINGA => Blocks::LILAC(), + default => throw $in->badValueException(StateNames::DOUBLE_PLANT_TYPE, $type), + })->setTop($in->readBool(StateNames::UPPER_BLOCK_BIT)); + }); + $this->map(Ids::DOUBLE_STONE_BLOCK_SLAB, function(Reader $in) : Block{ + $in->ignored(StateNames::TOP_SLOT_BIT); //useless for double slabs + return Helper::mapStoneSlab1Type($in)->setSlabType(SlabType::DOUBLE()); + }); + $this->map(Ids::DOUBLE_STONE_BLOCK_SLAB2, function(Reader $in) : Block{ + $in->ignored(StateNames::TOP_SLOT_BIT); //useless for double slabs + return Helper::mapStoneSlab2Type($in)->setSlabType(SlabType::DOUBLE()); + }); + $this->map(Ids::DOUBLE_STONE_BLOCK_SLAB3, function(Reader $in) : Block{ + $in->ignored(StateNames::TOP_SLOT_BIT); //useless for double slabs + return Helper::mapStoneSlab3Type($in)->setSlabType(SlabType::DOUBLE()); + }); + $this->map(Ids::DOUBLE_STONE_BLOCK_SLAB4, function(Reader $in) : Block{ + $in->ignored(StateNames::TOP_SLOT_BIT); //useless for double slabs + return Helper::mapStoneSlab4Type($in)->setSlabType(SlabType::DOUBLE()); + }); + $this->map(Ids::DOUBLE_WOODEN_SLAB, function(Reader $in) : Block{ + $in->ignored(StateNames::TOP_SLOT_BIT); //useless for double slabs + return Helper::mapWoodenSlabType($in)->setSlabType(SlabType::DOUBLE()); + }); + $this->mapStairs(Ids::END_BRICK_STAIRS, fn() => Blocks::END_STONE_BRICK_STAIRS()); $this->map(Ids::END_PORTAL_FRAME, function(Reader $in) : Block{ return Blocks::END_PORTAL_FRAME() ->setEye($in->readBool(StateNames::END_PORTAL_EYE_BIT)) @@ -579,7 +661,6 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize return Blocks::END_ROD() ->setFacing($in->readEndRodFacingDirection()); }); - $this->map(Ids::END_STONE, fn() => Blocks::END_STONE()); $this->map(Ids::ENDER_CHEST, function(Reader $in) : Block{ return Blocks::ENDER_CHEST() ->setFacing($in->readHorizontalFacing()); @@ -608,7 +689,6 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize return Blocks::FIRE() ->setAge($in->readBoundedInt(StateNames::AGE, 0, 15)); }); - $this->map(Ids::FLETCHING_TABLE, fn() => Blocks::FLETCHING_TABLE()); $this->map(Ids::FLOWER_POT, function(Reader $in) : Block{ $in->ignored(StateNames::UPDATE_BIT); return Blocks::FLOWER_POT(); @@ -625,28 +705,15 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize ->setFacing($in->readHorizontalFacing()) ->setLit(false); }); - $this->map(Ids::GILDED_BLACKSTONE, fn() => Blocks::GILDED_BLACKSTONE()); - $this->map(Ids::GLASS, fn() => Blocks::GLASS()); - $this->map(Ids::GLASS_PANE, fn() => Blocks::GLASS_PANE()); $this->map(Ids::GLOW_FRAME, fn(Reader $in) => Helper::decodeItemFrame($in, true)); - $this->map(Ids::GLOWINGOBSIDIAN, fn() => Blocks::GLOWING_OBSIDIAN()); - $this->map(Ids::GLOWSTONE, fn() => Blocks::GLOWSTONE()); - $this->map(Ids::GOLD_BLOCK, fn() => Blocks::GOLD()); - $this->map(Ids::GOLD_ORE, fn() => Blocks::GOLD_ORE()); $this->map(Ids::GOLDEN_RAIL, function(Reader $in) : Block{ return Blocks::POWERED_RAIL() ->setPowered($in->readBool(StateNames::RAIL_DATA_BIT)) ->setShape($in->readBoundedInt(StateNames::RAIL_DIRECTION, 0, 5)); }); $this->mapStairs(Ids::GRANITE_STAIRS, fn() => Blocks::GRANITE_STAIRS()); - $this->map(Ids::GRASS, fn() => Blocks::GRASS()); - $this->map(Ids::GRASS_PATH, fn() => Blocks::GRASS_PATH()); - $this->map(Ids::GRAVEL, fn() => Blocks::GRAVEL()); $this->map(Ids::GRAY_GLAZED_TERRACOTTA, fn(Reader $in) => Helper::decodeGlazedTerracotta(DyeColor::GRAY(), $in)); $this->map(Ids::GREEN_GLAZED_TERRACOTTA, fn(Reader $in) => Helper::decodeGlazedTerracotta(DyeColor::GREEN(), $in)); - $this->map(Ids::HANGING_ROOTS, fn() => Blocks::HANGING_ROOTS()); - $this->map(Ids::HARD_GLASS, fn() => Blocks::HARDENED_GLASS()); - $this->map(Ids::HARD_GLASS_PANE, fn() => Blocks::HARDENED_GLASS_PANE()); $this->map(Ids::HARD_STAINED_GLASS, function(Reader $in) : Block{ return Blocks::STAINED_HARDENED_GLASS() ->setColor($in->readColor()); @@ -655,28 +722,18 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize return Blocks::STAINED_HARDENED_GLASS_PANE() ->setColor($in->readColor()); }); - $this->map(Ids::HARDENED_CLAY, fn() => Blocks::HARDENED_CLAY()); $this->map(Ids::HAY_BLOCK, function(Reader $in) : Block{ $in->ignored(StateNames::DEPRECATED); return Blocks::HAY_BALE()->setAxis($in->readPillarAxis()); }); $this->map(Ids::HEAVY_WEIGHTED_PRESSURE_PLATE, fn(Reader $in) => Helper::decodeWeightedPressurePlate(Blocks::WEIGHTED_PRESSURE_PLATE_HEAVY(), $in)); - $this->map(Ids::HONEYCOMB_BLOCK, fn() => Blocks::HONEYCOMB()); $this->map(Ids::HOPPER, function(Reader $in) : Block{ return Blocks::HOPPER() ->setFacing($in->readFacingWithoutUp()) ->setPowered($in->readBool(StateNames::TOGGLE_BIT)); }); - $this->map(Ids::ICE, fn() => Blocks::ICE()); - $this->map(Ids::INFO_UPDATE, fn() => Blocks::INFO_UPDATE()); - $this->map(Ids::INFO_UPDATE2, fn() => Blocks::INFO_UPDATE2()); - $this->map(Ids::INVISIBLE_BEDROCK, fn() => Blocks::INVISIBLE_BEDROCK()); - $this->map(Ids::IRON_BARS, fn() => Blocks::IRON_BARS()); - $this->map(Ids::IRON_BLOCK, fn() => Blocks::IRON()); $this->map(Ids::IRON_DOOR, fn(Reader $in) => Helper::decodeDoor(Blocks::IRON_DOOR(), $in)); - $this->map(Ids::IRON_ORE, fn() => Blocks::IRON_ORE()); $this->map(Ids::IRON_TRAPDOOR, fn(Reader $in) => Helper::decodeTrapdoor(Blocks::IRON_TRAPDOOR(), $in)); - $this->map(Ids::JUKEBOX, fn() => Blocks::JUKEBOX()); $this->map(Ids::JUNGLE_BUTTON, fn(Reader $in) => Helper::decodeButton(Blocks::JUNGLE_BUTTON(), $in)); $this->map(Ids::JUNGLE_DOOR, fn(Reader $in) => Helper::decodeDoor(Blocks::JUNGLE_DOOR(), $in)); $this->map(Ids::JUNGLE_FENCE_GATE, fn(Reader $in) => Helper::decodeFenceGate(Blocks::JUNGLE_FENCE_GATE(), $in)); @@ -693,8 +750,6 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize return Blocks::LANTERN() ->setHanging($in->readBool(StateNames::HANGING)); }); - $this->map(Ids::LAPIS_BLOCK, fn() => Blocks::LAPIS_LAZULI()); - $this->map(Ids::LAPIS_ORE, fn() => Blocks::LAPIS_LAZULI_ORE()); $this->map(Ids::LAVA, fn(Reader $in) => Helper::decodeStillLiquid(Blocks::LAVA(), $in)); $this->map(Ids::LEAVES, function(Reader $in) : Block{ return (match($type = $in->readString(StateNames::OLD_LEAF_TYPE)){ @@ -792,14 +847,11 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize ->setFacing($in->readLegacyHorizontalFacing()); }); $this->map(Ids::MAGENTA_GLAZED_TERRACOTTA, fn(Reader $in) => Helper::decodeGlazedTerracotta(DyeColor::MAGENTA(), $in)); - $this->map(Ids::MAGMA, fn() => Blocks::MAGMA()); $this->map(Ids::MANGROVE_BUTTON, fn(Reader $in) => Helper::decodeButton(Blocks::MANGROVE_BUTTON(), $in)); $this->map(Ids::MANGROVE_DOOR, fn(Reader $in) => Helper::decodeDoor(Blocks::MANGROVE_DOOR(), $in)); $this->mapSlab(Ids::MANGROVE_SLAB, Ids::MANGROVE_DOUBLE_SLAB, fn() => Blocks::MANGROVE_SLAB()); - $this->map(Ids::MANGROVE_FENCE, fn() => Blocks::MANGROVE_FENCE()); $this->map(Ids::MANGROVE_FENCE_GATE, fn(Reader $in) => Helper::decodeFenceGate(Blocks::MANGROVE_FENCE_GATE(), $in)); $this->map(Ids::MANGROVE_LOG, fn(Reader $in) => Helper::decodeLog(Blocks::MANGROVE_LOG(), false, $in)); - $this->map(Ids::MANGROVE_PLANKS, fn() => Blocks::MANGROVE_PLANKS()); $this->map(Ids::MANGROVE_PRESSURE_PLATE, fn(Reader $in) => Helper::decodeSimplePressurePlate(Blocks::MANGROVE_PRESSURE_PLATE(), $in)); $this->mapStairs(Ids::MANGROVE_STAIRS, fn() => Blocks::MANGROVE_STAIRS()); $this->map(Ids::MANGROVE_STANDING_SIGN, fn(Reader $in) => Helper::decodeFloorSign(Blocks::MANGROVE_SIGN(), $in)); @@ -809,9 +861,7 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize $in->ignored(StateNames::STRIPPED_BIT); //this is also ignored by vanilla return Helper::decodeLog(Blocks::MANGROVE_WOOD(), false, $in); }); - $this->map(Ids::MELON_BLOCK, fn() => Blocks::MELON()); $this->map(Ids::MELON_STEM, fn(Reader $in) => Helper::decodeStem(Blocks::MELON_STEM(), $in)); - $this->map(Ids::MOB_SPAWNER, fn() => Blocks::MONSTER_SPAWNER()); $this->map(Ids::MONSTER_EGG, function(Reader $in) : Block{ return match($type = $in->readString(StateNames::MONSTER_EGG_STONE_TYPE)){ StringValues::MONSTER_EGG_STONE_TYPE_CHISELED_STONE_BRICK => Blocks::INFESTED_CHISELED_STONE_BRICK(), @@ -823,36 +873,23 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize default => throw $in->badValueException(StateNames::MONSTER_EGG_STONE_TYPE, $type), }; }); - $this->map(Ids::MOSSY_COBBLESTONE, fn() => Blocks::MOSSY_COBBLESTONE()); $this->mapStairs(Ids::MOSSY_COBBLESTONE_STAIRS, fn() => Blocks::MOSSY_COBBLESTONE_STAIRS()); $this->mapStairs(Ids::MOSSY_STONE_BRICK_STAIRS, fn() => Blocks::MOSSY_STONE_BRICK_STAIRS()); - $this->map(Ids::MUD_BRICKS, fn() => Blocks::MUD_BRICKS()); $this->mapSlab(Ids::MUD_BRICK_SLAB, Ids::MUD_BRICK_DOUBLE_SLAB, fn() => Blocks::MUD_BRICK_SLAB()); $this->mapStairs(Ids::MUD_BRICK_STAIRS, fn() => Blocks::MUD_BRICK_STAIRS()); $this->map(Ids::MUD_BRICK_WALL, fn(Reader $in) => Helper::decodeWall(Blocks::MUD_BRICK_WALL(), $in)); - $this->map(Ids::MYCELIUM, fn() => Blocks::MYCELIUM()); - $this->map(Ids::NETHER_BRICK, fn() => Blocks::NETHER_BRICKS()); - $this->map(Ids::NETHER_BRICK_FENCE, fn() => Blocks::NETHER_BRICK_FENCE()); $this->mapStairs(Ids::NETHER_BRICK_STAIRS, fn() => Blocks::NETHER_BRICK_STAIRS()); - $this->map(Ids::NETHER_GOLD_ORE, fn() => Blocks::NETHER_GOLD_ORE()); $this->map(Ids::NETHER_WART, function(Reader $in) : Block{ return Blocks::NETHER_WART() ->setAge($in->readBoundedInt(StateNames::AGE, 0, 3)); }); - $this->map(Ids::NETHER_WART_BLOCK, fn() => Blocks::NETHER_WART_BLOCK()); - $this->map(Ids::NETHERITE_BLOCK, fn() => Blocks::NETHERITE()); - $this->map(Ids::NETHERRACK, fn() => Blocks::NETHERRACK()); - $this->map(Ids::NETHERREACTOR, fn() => Blocks::NETHER_REACTOR_CORE()); $this->mapStairs(Ids::NORMAL_STONE_STAIRS, fn() => Blocks::STONE_STAIRS()); - $this->map(Ids::NOTEBLOCK, fn() => Blocks::NOTE_BLOCK()); $this->mapStairs(Ids::OAK_STAIRS, fn() => Blocks::OAK_STAIRS()); - $this->map(Ids::OBSIDIAN, fn() => Blocks::OBSIDIAN()); $this->map(Ids::ORANGE_GLAZED_TERRACOTTA, fn(Reader $in) => Helper::decodeGlazedTerracotta(DyeColor::ORANGE(), $in)); $this->map(Ids::OXIDIZED_COPPER, fn() => Helper::decodeCopper(Blocks::COPPER(), CopperOxidation::OXIDIZED())); $this->map(Ids::OXIDIZED_CUT_COPPER, fn() => Helper::decodeCopper(Blocks::CUT_COPPER(), CopperOxidation::OXIDIZED())); $this->mapSlab(Ids::OXIDIZED_CUT_COPPER_SLAB, Ids::OXIDIZED_DOUBLE_CUT_COPPER_SLAB, fn() => Helper::decodeCopper(Blocks::CUT_COPPER_SLAB(), CopperOxidation::OXIDIZED())); $this->mapStairs(Ids::OXIDIZED_CUT_COPPER_STAIRS, fn() => Helper::decodeCopper(Blocks::CUT_COPPER_STAIRS(), CopperOxidation::OXIDIZED())); - $this->map(Ids::PACKED_ICE, fn() => Blocks::PACKED_ICE()); $this->map(Ids::PINK_GLAZED_TERRACOTTA, fn(Reader $in) => Helper::decodeGlazedTerracotta(DyeColor::PINK(), $in)); $this->map(Ids::PLANKS, function(Reader $in) : Block{ return match($woodName = $in->readString(StateNames::WOOD_TYPE)){ @@ -865,23 +902,19 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize default => throw $in->badValueException(StateNames::WOOD_TYPE, $woodName), }; }); - $this->map(Ids::PODZOL, fn() => Blocks::PODZOL()); $this->mapStairs(Ids::POLISHED_ANDESITE_STAIRS, fn() => Blocks::POLISHED_ANDESITE_STAIRS()); $this->map(Ids::POLISHED_BASALT, function(Reader $in) : Block{ return Blocks::POLISHED_BASALT() ->setAxis($in->readPillarAxis()); }); - $this->map(Ids::POLISHED_BLACKSTONE, fn() => Blocks::POLISHED_BLACKSTONE()); $this->map(Ids::POLISHED_BLACKSTONE_BUTTON, fn(Reader $in) => Helper::decodeButton(Blocks::POLISHED_BLACKSTONE_BUTTON(), $in)); $this->mapSlab(Ids::POLISHED_BLACKSTONE_SLAB, Ids::POLISHED_BLACKSTONE_DOUBLE_SLAB, fn() => Blocks::POLISHED_BLACKSTONE_SLAB()); $this->map(Ids::POLISHED_BLACKSTONE_PRESSURE_PLATE, fn(Reader $in) => Helper::decodeSimplePressurePlate(Blocks::POLISHED_BLACKSTONE_PRESSURE_PLATE(), $in)); $this->mapStairs(Ids::POLISHED_BLACKSTONE_STAIRS, fn() => Blocks::POLISHED_BLACKSTONE_STAIRS()); $this->map(Ids::POLISHED_BLACKSTONE_WALL, fn(Reader $in) => Helper::decodeWall(Blocks::POLISHED_BLACKSTONE_WALL(), $in)); - $this->map(Ids::POLISHED_BLACKSTONE_BRICKS, fn() => Blocks::POLISHED_BLACKSTONE_BRICKS()); $this->mapSlab(Ids::POLISHED_BLACKSTONE_BRICK_SLAB, Ids::POLISHED_BLACKSTONE_BRICK_DOUBLE_SLAB, fn() => Blocks::POLISHED_BLACKSTONE_BRICK_SLAB()); $this->mapStairs(Ids::POLISHED_BLACKSTONE_BRICK_STAIRS, fn() => Blocks::POLISHED_BLACKSTONE_BRICK_STAIRS()); $this->map(Ids::POLISHED_BLACKSTONE_BRICK_WALL, fn(Reader $in) => Helper::decodeWall(Blocks::POLISHED_BLACKSTONE_BRICK_WALL(), $in)); - $this->map(Ids::POLISHED_DEEPSLATE, fn() => Blocks::POLISHED_DEEPSLATE()); $this->mapSlab(Ids::POLISHED_DEEPSLATE_SLAB, Ids::POLISHED_DEEPSLATE_DOUBLE_SLAB, fn() => Blocks::POLISHED_DEEPSLATE_SLAB()); $this->mapStairs(Ids::POLISHED_DEEPSLATE_STAIRS, fn() => Blocks::POLISHED_DEEPSLATE_STAIRS()); $this->map(Ids::POLISHED_DEEPSLATE_WALL, fn(Reader $in) => Helper::decodeWall(Blocks::POLISHED_DEEPSLATE_WALL(), $in)); @@ -947,16 +980,11 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize return throw $in->badValueException(StateNames::CHISEL_TYPE, $type); } }); - $this->map(Ids::QUARTZ_BRICKS, fn() => Blocks::QUARTZ_BRICKS()); - $this->map(Ids::QUARTZ_ORE, fn() => Blocks::NETHER_QUARTZ_ORE()); $this->mapStairs(Ids::QUARTZ_STAIRS, fn() => Blocks::QUARTZ_STAIRS()); $this->map(Ids::RAIL, function(Reader $in) : Block{ return Blocks::RAIL() ->setShape($in->readBoundedInt(StateNames::RAIL_DIRECTION, 0, 9)); }); - $this->map(Ids::RAW_COPPER_BLOCK, fn() => Blocks::RAW_COPPER()); - $this->map(Ids::RAW_GOLD_BLOCK, fn() => Blocks::RAW_GOLD()); - $this->map(Ids::RAW_IRON_BLOCK, fn() => Blocks::RAW_IRON()); $this->map(Ids::RED_FLOWER, function(Reader $in) : Block{ return match($type = $in->readString(StateNames::FLOWER_TYPE)){ StringValues::FLOWER_TYPE_ALLIUM => Blocks::ALLIUM(), @@ -974,9 +1002,7 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize }; }); $this->map(Ids::RED_GLAZED_TERRACOTTA, fn(Reader $in) => Helper::decodeGlazedTerracotta(DyeColor::RED(), $in)); - $this->map(Ids::RED_MUSHROOM, fn() => Blocks::RED_MUSHROOM()); $this->map(Ids::RED_MUSHROOM_BLOCK, fn(Reader $in) => Helper::decodeMushroomBlock(Blocks::RED_MUSHROOM_BLOCK(), $in)); - $this->map(Ids::RED_NETHER_BRICK, fn() => Blocks::RED_NETHER_BRICKS()); $this->mapStairs(Ids::RED_NETHER_BRICK_STAIRS, fn() => Blocks::RED_NETHER_BRICK_STAIRS()); $this->map(Ids::RED_SANDSTONE, function(Reader $in) : Block{ return match($type = $in->readString(StateNames::SAND_STONE_TYPE)){ @@ -988,7 +1014,6 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize }; }); $this->mapStairs(Ids::RED_SANDSTONE_STAIRS, fn() => Blocks::RED_SANDSTONE_STAIRS()); - $this->map(Ids::REDSTONE_BLOCK, fn() => Blocks::REDSTONE()); $this->map(Ids::REDSTONE_LAMP, function() : Block{ return Blocks::REDSTONE_LAMP() ->setPowered(false); @@ -1010,7 +1035,6 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize return Blocks::SUGARCANE() ->setAge($in->readBoundedInt(StateNames::AGE, 0, 15)); }); - $this->map(Ids::RESERVED6, fn() => Blocks::RESERVED6()); $this->map(Ids::SAND, function(Reader $in) : Block{ return match($value = $in->readString(StateNames::SAND_TYPE)){ StringValues::SAND_TYPE_NORMAL => Blocks::SAND(), @@ -1040,13 +1064,11 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize }) ->setReady($in->readBool(StateNames::AGE_BIT)); }); - $this->map(Ids::SEA_LANTERN, fn() => Blocks::SEA_LANTERN()); $this->map(Ids::SEA_PICKLE, function(Reader $in) : Block{ return Blocks::SEA_PICKLE() ->setCount($in->readBoundedInt(StateNames::CLUSTER_COUNT, 0, 3) + 1) ->setUnderwater(!$in->readBool(StateNames::DEAD_BIT)); }); - $this->map(Ids::SHROOMLIGHT, fn() => Blocks::SHROOMLIGHT()); $this->map(Ids::SHULKER_BOX, function(Reader $in) : Block{ return Blocks::DYED_SHULKER_BOX() ->setColor($in->readColor()); @@ -1056,19 +1078,14 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize return Blocks::MOB_HEAD() ->setFacing($in->readFacingWithoutDown()); }); - $this->map(Ids::SLIME, fn() => Blocks::SLIME()); - $this->map(Ids::SMITHING_TABLE, fn() => Blocks::SMITHING_TABLE()); $this->map(Ids::SMOKER, function(Reader $in) : Block{ return Blocks::SMOKER() ->setFacing($in->readHorizontalFacing()) ->setLit(false); }); - $this->map(Ids::SMOOTH_BASALT, fn() => Blocks::SMOOTH_BASALT()); $this->mapStairs(Ids::SMOOTH_QUARTZ_STAIRS, fn() => Blocks::SMOOTH_QUARTZ_STAIRS()); $this->mapStairs(Ids::SMOOTH_RED_SANDSTONE_STAIRS, fn() => Blocks::SMOOTH_RED_SANDSTONE_STAIRS()); $this->mapStairs(Ids::SMOOTH_SANDSTONE_STAIRS, fn() => Blocks::SMOOTH_SANDSTONE_STAIRS()); - $this->map(Ids::SMOOTH_STONE, fn() => Blocks::SMOOTH_STONE()); - $this->map(Ids::SNOW, fn() => Blocks::SNOW()); $this->map(Ids::SNOW_LAYER, function(Reader $in) : Block{ $in->ignored(StateNames::COVERED_BIT); //seems to be useless return Blocks::SNOW_LAYER()->setLayers($in->readBoundedInt(StateNames::HEIGHT, 0, 7) + 1); @@ -1081,8 +1098,6 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize return Blocks::SOUL_LANTERN() ->setHanging($in->readBool(StateNames::HANGING)); }); - $this->map(Ids::SOUL_SAND, fn() => Blocks::SOUL_SAND()); - $this->map(Ids::SOUL_SOIL, fn() => Blocks::SOUL_SOIL()); $this->map(Ids::SOUL_TORCH, function(Reader $in) : Block{ return Blocks::SOUL_TORCH() ->setFacing($in->readTorchFacing()); @@ -1149,7 +1164,6 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize default => throw $in->badValueException(StateNames::STONE_BRICK_TYPE, $type), }; }); - $this->map(Ids::STONECUTTER, fn() => Blocks::LEGACY_STONECUTTER()); $this->map(Ids::STONECUTTER_BLOCK, function(Reader $in) : Block{ return Blocks::STONECUTTER() ->setFacing($in->readHorizontalFacing()); @@ -1179,7 +1193,6 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize default => throw $in->badValueException(StateNames::TALL_GRASS_TYPE, $type), }; }); - $this->map(Ids::TINTED_GLASS, fn() => Blocks::TINTED_GLASS()); $this->map(Ids::TNT, function(Reader $in) : Block{ return Blocks::TNT() ->setUnstable($in->readBool(StateNames::EXPLODE_BIT)) @@ -1207,12 +1220,10 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize ->setFacing($in->readLegacyHorizontalFacing()) ->setPowered($in->readBool(StateNames::POWERED_BIT)); }); - $this->map(Ids::TUFF, fn() => Blocks::TUFF()); $this->map(Ids::UNDERWATER_TORCH, function(Reader $in) : Block{ return Blocks::UNDERWATER_TORCH() ->setFacing($in->readTorchFacing()); }); - $this->map(Ids::UNDYED_SHULKER_BOX, fn() => Blocks::SHULKER_BOX()); $this->map(Ids::UNLIT_REDSTONE_TORCH, function(Reader $in) : Block{ return Blocks::REDSTONE_TORCH() ->setFacing($in->readTorchFacing()) @@ -1237,19 +1248,15 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize $this->map(Ids::WARPED_BUTTON, fn(Reader $in) => Helper::decodeButton(Blocks::WARPED_BUTTON(), $in)); $this->map(Ids::WARPED_DOOR, fn(Reader $in) => Helper::decodeDoor(Blocks::WARPED_DOOR(), $in)); $this->mapSlab(Ids::WARPED_SLAB, Ids::WARPED_DOUBLE_SLAB, fn() => Blocks::WARPED_SLAB()); - $this->map(Ids::WARPED_FENCE, fn() => Blocks::WARPED_FENCE()); $this->map(Ids::WARPED_FENCE_GATE, fn(Reader $in) => Helper::decodeFenceGate(Blocks::WARPED_FENCE_GATE(), $in)); $this->map(Ids::WARPED_HYPHAE, fn(Reader $in) => Helper::decodeLog(Blocks::WARPED_HYPHAE(), false, $in)); - $this->map(Ids::WARPED_PLANKS, fn() => Blocks::WARPED_PLANKS()); $this->map(Ids::WARPED_PRESSURE_PLATE, fn(Reader $in) => Helper::decodeSimplePressurePlate(Blocks::WARPED_PRESSURE_PLATE(), $in)); $this->mapStairs(Ids::WARPED_STAIRS, fn() => Blocks::WARPED_STAIRS()); $this->map(Ids::WARPED_STANDING_SIGN, fn(Reader $in) => Helper::decodeFloorSign(Blocks::WARPED_SIGN(), $in)); $this->map(Ids::WARPED_STEM, fn(Reader $in) => Helper::decodeLog(Blocks::WARPED_STEM(), false, $in)); $this->map(Ids::WARPED_TRAPDOOR, fn(Reader $in) => Helper::decodeTrapdoor(Blocks::WARPED_TRAPDOOR(), $in)); $this->map(Ids::WARPED_WALL_SIGN, fn(Reader $in) => Helper::decodeWallSign(Blocks::WARPED_WALL_SIGN(), $in)); - $this->map(Ids::WARPED_WART_BLOCK, fn() => Blocks::WARPED_WART_BLOCK()); $this->map(Ids::WATER, fn(Reader $in) => Helper::decodeStillLiquid(Blocks::WATER(), $in)); - $this->map(Ids::WATERLILY, fn() => Blocks::LILY_PAD()); $this->map(Ids::WAXED_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::COPPER(), CopperOxidation::NONE())); $this->map(Ids::WAXED_CUT_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER(), CopperOxidation::NONE())); $this->mapSlab(Ids::WAXED_CUT_COPPER_SLAB, Ids::WAXED_DOUBLE_CUT_COPPER_SLAB, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER_SLAB(), CopperOxidation::NONE())); @@ -1270,10 +1277,8 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize $this->map(Ids::WEATHERED_CUT_COPPER, fn() => Helper::decodeCopper(Blocks::CUT_COPPER(), CopperOxidation::WEATHERED())); $this->mapSlab(Ids::WEATHERED_CUT_COPPER_SLAB, Ids::WEATHERED_DOUBLE_CUT_COPPER_SLAB, fn() => Helper::decodeCopper(Blocks::CUT_COPPER_SLAB(), CopperOxidation::WEATHERED())); $this->mapStairs(Ids::WEATHERED_CUT_COPPER_STAIRS, fn() => Helper::decodeCopper(Blocks::CUT_COPPER_STAIRS(), CopperOxidation::WEATHERED())); - $this->map(Ids::WEB, fn() => Blocks::COBWEB()); $this->map(Ids::WHEAT, fn(Reader $in) => Helper::decodeCrops(Blocks::WHEAT(), $in)); $this->map(Ids::WHITE_GLAZED_TERRACOTTA, fn(Reader $in) => Helper::decodeGlazedTerracotta(DyeColor::WHITE(), $in)); - $this->map(Ids::WITHER_ROSE, fn() => Blocks::WITHER_ROSE()); $this->map(Ids::WOOD, fn(Reader $in) : Block => Helper::decodeLog(match($woodType = $in->readString(StateNames::WOOD_TYPE)){ StringValues::WOOD_TYPE_ACACIA => Blocks::ACACIA_WOOD(), StringValues::WOOD_TYPE_BIRCH => Blocks::BIRCH_WOOD(), @@ -1291,7 +1296,6 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize return Blocks::WOOL() ->setColor($in->readColor()); }); - $this->map(Ids::YELLOW_FLOWER, fn() => Blocks::DANDELION()); $this->map(Ids::YELLOW_GLAZED_TERRACOTTA, fn(Reader $in) => Helper::decodeGlazedTerracotta(DyeColor::YELLOW(), $in)); }