Skip to content

Commit

Permalink
Add Bamboo Block Mappings
Browse files Browse the repository at this point in the history
Added mappings for Bamboo blocks, including Bamboo Door and Bamboo Sign, to the ItemSerializerDeserializerRegistrar.
  • Loading branch information
AzaleeX committed Oct 25, 2024
1 parent f1b1a70 commit fb4eaa8
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/block/BlockTypeIds.php
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,18 @@ private function __construct(){
public const PITCHER_CROP = 10716;
public const DOUBLE_PITCHER_CROP = 10717;

public const BAMBOO_BUTTON = 10718;
public const BAMBOO_DOOR = 10719;
public const BAMBOO_FENCE = 10720;
public const BAMBOO_FENCE_GATE = 10721;
public const BAMBOO_PLANKS = 10722;
public const BAMBOO_PRESSURE_PLATE = 10723;
public const BAMBOO_SIGN = 10724;
public const BAMBOO_SLAB = 10725;
public const BAMBOO_STAIRS = 10726;
public const BAMBOO_TRAPDOOR = 10727;
public const BAMBOO_WALL_SIGN = 10728;

public const FIRST_UNUSED_BLOCK_ID = 10718;

private static int $nextDynamicId = self::FIRST_UNUSED_BLOCK_ID;
Expand Down
11 changes: 11 additions & 0 deletions src/block/VanillaBlocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,17 @@
* @method static Wood WARPED_STEM()
* @method static WoodenTrapdoor WARPED_TRAPDOOR()
* @method static WallSign WARPED_WALL_SIGN()
* @method static WoodenButton BAMBOO_BUTTON()
* @method static WoodenDoor BAMBOO_DOOR()
* @method static WoodenFence BAMBOO_FENCE()
* @method static FenceGate BAMBOO_FENCE_GATE()
* @method static Planks BAMBOO_PLANKS()
* @method static WoodenPressurePlate BAMBOO_PRESSURE_PLATE()
* @method static FloorSign BAMBOO_SIGN()
* @method static WoodenSlab BAMBOO_SLAB()
* @method static WoodenStairs BAMBOO_STAIRS()
* @method static WoodenTrapdoor BAMBOO_TRAPDOOR()
* @method static WallSign BAMBOO_WALL_SIGN()
* @method static Opaque WARPED_WART_BLOCK()
* @method static Water WATER()
* @method static WaterCauldron WATER_CAULDRON()
Expand Down
15 changes: 15 additions & 0 deletions src/block/WoodLikeBlockIdHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public static function getPlanksIdentifier(WoodType $type) : BID{
WoodType::CRIMSON => Ids::CRIMSON_PLANKS,
WoodType::WARPED => Ids::WARPED_PLANKS,
WoodType::CHERRY => Ids::CHERRY_PLANKS,
WoodType::BAMBOO => Ids::BAMBOO_PLANKS,
});
}

Expand All @@ -73,6 +74,7 @@ public static function getFenceIdentifier(WoodType $type) : BID{
WoodType::CRIMSON => Ids::CRIMSON_FENCE,
WoodType::WARPED => Ids::WARPED_FENCE,
WoodType::CHERRY => Ids::CHERRY_FENCE,
WoodType::BAMBOO => Ids::BAMBOO_FENCE,
});
}

Expand All @@ -88,9 +90,13 @@ public static function getSlabIdentifier(WoodType $type) : BID{
WoodType::CRIMSON => Ids::CRIMSON_SLAB,
WoodType::WARPED => Ids::WARPED_SLAB,
WoodType::CHERRY => Ids::CHERRY_SLAB,
WoodType::BAMBOO => Ids::BAMBOO_SLAB,
});
}

/**
* @throws \Exception
*/
public static function getLogIdentifier(WoodType $treeType) : BID{
return new BID(match($treeType){
WoodType::OAK => Ids::OAK_LOG,
Expand All @@ -103,6 +109,7 @@ public static function getLogIdentifier(WoodType $treeType) : BID{
WoodType::CRIMSON => Ids::CRIMSON_STEM,
WoodType::WARPED => Ids::WARPED_STEM,
WoodType::CHERRY => Ids::CHERRY_LOG,
WoodType::BAMBOO => 59000,
});
}

Expand All @@ -118,6 +125,7 @@ public static function getAllSidedLogIdentifier(WoodType $treeType) : BID{
WoodType::CRIMSON => Ids::CRIMSON_HYPHAE,
WoodType::WARPED => Ids::WARPED_HYPHAE,
WoodType::CHERRY => Ids::CHERRY_WOOD,
WoodType::BAMBOO => 59001,
});
}

Expand Down Expand Up @@ -168,6 +176,7 @@ public static function getSignInfo(WoodType $treeType) : array{
WoodType::CRIMSON => $make(Ids::CRIMSON_SIGN, Ids::CRIMSON_WALL_SIGN, fn() => VanillaItems::CRIMSON_SIGN()),
WoodType::WARPED => $make(Ids::WARPED_SIGN, Ids::WARPED_WALL_SIGN, fn() => VanillaItems::WARPED_SIGN()),
WoodType::CHERRY => $make(Ids::CHERRY_SIGN, Ids::CHERRY_WALL_SIGN, fn() => VanillaItems::CHERRY_SIGN()),
WoodType::BAMBOO => $make(Ids::BAMBOO_SIGN, Ids::BAMBOO_WALL_SIGN, fn() => VanillaItems::BAMBOO_SIGN()),
};
}

Expand All @@ -183,6 +192,7 @@ public static function getTrapdoorIdentifier(WoodType $treeType) : BID{
WoodType::CRIMSON => Ids::CRIMSON_TRAPDOOR,
WoodType::WARPED => Ids::WARPED_TRAPDOOR,
WoodType::CHERRY => Ids::CHERRY_TRAPDOOR,
WoodType::BAMBOO => Ids::BAMBOO_TRAPDOOR,
});
}

Expand All @@ -198,6 +208,7 @@ public static function getButtonIdentifier(WoodType $treeType) : BID{
WoodType::CRIMSON => Ids::CRIMSON_BUTTON,
WoodType::WARPED => Ids::WARPED_BUTTON,
WoodType::CHERRY => Ids::CHERRY_BUTTON,
WoodType::BAMBOO => Ids::BAMBOO_BUTTON,
});
}

Expand All @@ -213,6 +224,7 @@ public static function getPressurePlateIdentifier(WoodType $treeType) : BID{
WoodType::CRIMSON => Ids::CRIMSON_PRESSURE_PLATE,
WoodType::WARPED => Ids::WARPED_PRESSURE_PLATE,
WoodType::CHERRY => Ids::CHERRY_PRESSURE_PLATE,
WoodType::BAMBOO => Ids::BAMBOO_PRESSURE_PLATE,
});
}

Expand All @@ -228,6 +240,7 @@ public static function getDoorIdentifier(WoodType $treeType) : BID{
WoodType::CRIMSON => Ids::CRIMSON_DOOR,
WoodType::WARPED => Ids::WARPED_DOOR,
WoodType::CHERRY => Ids::CHERRY_DOOR,
WoodType::BAMBOO => Ids::BAMBOO_DOOR,
});
}

Expand All @@ -243,6 +256,7 @@ public static function getFenceGateIdentifier(WoodType $treeType) : BID{
WoodType::CRIMSON => Ids::CRIMSON_FENCE_GATE,
WoodType::WARPED => Ids::WARPED_FENCE_GATE,
WoodType::CHERRY => Ids::CHERRY_FENCE_GATE,
WoodType::BAMBOO => Ids::BAMBOO_FENCE_GATE,
});
}

Expand All @@ -258,6 +272,7 @@ public static function getStairsIdentifier(WoodType $treeType) : BID{
WoodType::CRIMSON => Ids::CRIMSON_STAIRS,
WoodType::WARPED => Ids::WARPED_STAIRS,
WoodType::CHERRY => Ids::CHERRY_STAIRS,
WoodType::BAMBOO => Ids::BAMBOO_STAIRS,
});
}
}
2 changes: 2 additions & 0 deletions src/block/utils/WoodType.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ enum WoodType{
case CRIMSON;
case WARPED;
case CHERRY;
case BAMBOO;

public function getDisplayName() : string{
return match($this){
Expand All @@ -66,6 +67,7 @@ public function getDisplayName() : string{
self::CRIMSON => "Crimson",
self::WARPED => "Warped",
self::CHERRY => "Cherry",
self::BAMBOO => "Bamboo",
};
}

Expand Down
12 changes: 12 additions & 0 deletions src/data/bedrock/block/convert/BlockObjectToStateSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,18 @@ private function registerFlatWoodBlockSerializers() : void{
}
});

$this->map(Blocks::BAMBOO_DOOR(), fn(Door $block) => Helper::encodeDoor($block, new Writer(Ids::BAMBOO_DOOR)));
$this->map(Blocks::BAMBOO_BUTTON(), fn(Button $block) => Helper::encodeButton($block, new Writer(Ids::BAMBOO_BUTTON)));
$this->map(Blocks::BAMBOO_SIGN(), fn(FloorSign $block) => Helper::encodeFloorSign($block, new Writer(Ids::BAMBOO_STANDING_SIGN)));
$this->map(Blocks::BAMBOO_TRAPDOOR(), fn(Trapdoor $block) => Helper::encodeTrapdoor($block, new Writer(Ids::BAMBOO_TRAPDOOR)));
$this->map(Blocks::BAMBOO_WALL_SIGN(), fn(WallSign $block) => Helper::encodeWallSign($block, new Writer(Ids::BAMBOO_WALL_SIGN)));
$this->mapSimple(Blocks::BAMBOO_PLANKS(), Ids::BAMBOO_PLANKS);
$this->mapSlab(Blocks::BAMBOO_SLAB(), Ids::BAMBOO_SLAB, Ids::BAMBOO_DOUBLE_SLAB);
$this->mapStairs(Blocks::BAMBOO_STAIRS(), Ids::BAMBOO_STAIRS);
$this->mapSimple(Blocks::BAMBOO_FENCE(), Ids::BAMBOO_FENCE);
$this->map(Blocks::BAMBOO_PRESSURE_PLATE(), fn(SimplePressurePlate $block) => Helper::encodeSimplePressurePlate($block, new Writer(Ids::BAMBOO_PRESSURE_PLATE)));
$this->map(Blocks::BAMBOO_FENCE_GATE(), fn(FenceGate $block) => Helper::encodeFenceGate($block, new Writer(Ids::BAMBOO_FENCE_GATE)));

$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)));
Expand Down
12 changes: 12 additions & 0 deletions src/data/bedrock/block/convert/BlockStateToObjectDeserializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,18 @@ private function registerFlatWoodBlockDeserializers() : void{
});
$this->map(Ids::STRIPPED_CHERRY_WOOD, fn(Reader $in) => Helper::decodeLog(Blocks::CHERRY_WOOD(), true, $in));

$this->map(Ids::BAMBOO_BUTTON, fn(Reader $in) => Helper::decodeButton(Blocks::BAMBOO_BUTTON(), $in));
$this->map(Ids::BAMBOO_DOOR, fn(Reader $in) => Helper::decodeDoor(Blocks::BAMBOO_DOOR(), $in));
$this->map(Ids::BAMBOO_FENCE_GATE, fn(Reader $in) => Helper::decodeFenceGate(Blocks::BAMBOO_FENCE_GATE(), $in));
$this->map(Ids::BAMBOO_PRESSURE_PLATE, fn(Reader $in) => Helper::decodeSimplePressurePlate(Blocks::BAMBOO_PRESSURE_PLATE(), $in));
$this->map(Ids::BAMBOO_STANDING_SIGN, fn(Reader $in) => Helper::decodeFloorSign(Blocks::BAMBOO_SIGN(), $in));
$this->map(Ids::BAMBOO_TRAPDOOR, fn(Reader $in) => Helper::decodeTrapdoor(Blocks::BAMBOO_TRAPDOOR(), $in));
$this->map(Ids::BAMBOO_WALL_SIGN, fn(Reader $in) => Helper::decodeWallSign(Blocks::BAMBOO_WALL_SIGN(), $in));
$this->mapSimple(Ids::BAMBOO_FENCE, fn() => Blocks::BAMBOO_FENCE());
$this->mapSimple(Ids::BAMBOO_PLANKS, fn() => Blocks::BAMBOO_PLANKS());
$this->mapSlab(Ids::BAMBOO_SLAB, Ids::BAMBOO_DOUBLE_SLAB, fn() => Blocks::BAMBOO_SLAB());
$this->mapStairs(Ids::BAMBOO_STAIRS, fn() => Blocks::BAMBOO_STAIRS());

$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->map(Ids::CRIMSON_FENCE_GATE, fn(Reader $in) => Helper::decodeFenceGate(Blocks::CRIMSON_FENCE_GATE(), $in));
Expand Down
2 changes: 2 additions & 0 deletions src/data/bedrock/item/ItemSerializerDeserializerRegistrar.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ private function register1to1BlockMappings() : void{
$this->map1to1Block(Ids::CAULDRON, Blocks::CAULDRON());
$this->map1to1Block(Ids::CHAIN, Blocks::CHAIN());
$this->map1to1Block(Ids::CHERRY_DOOR, Blocks::CHERRY_DOOR());
$this->map1to1Block(Ids::BAMBOO_DOOR, Blocks::BAMBOO_DOOR());
$this->map1to1Block(Ids::COMPARATOR, Blocks::REDSTONE_COMPARATOR());
$this->map1to1Block(Ids::CRIMSON_DOOR, Blocks::CRIMSON_DOOR());
$this->map1to1Block(Ids::DARK_OAK_DOOR, Blocks::DARK_OAK_DOOR());
Expand Down Expand Up @@ -187,6 +188,7 @@ private function register1to1ItemMappings() : void{
$this->map1to1Item(Ids::CHAINMAIL_LEGGINGS, Items::CHAINMAIL_LEGGINGS());
$this->map1to1Item(Ids::CHARCOAL, Items::CHARCOAL());
$this->map1to1Item(Ids::CHERRY_SIGN, Items::CHERRY_SIGN());
$this->map1to1Item(Ids::BAMBOO_SIGN, Items::BAMBOO_SIGN());
$this->map1to1Item(Ids::CHICKEN, Items::RAW_CHICKEN());
$this->map1to1Item(Ids::CHORUS_FRUIT, Items::CHORUS_FRUIT());
$this->map1to1Item(Ids::CLAY_BALL, Items::CLAY());
Expand Down
3 changes: 2 additions & 1 deletion src/item/ItemTypeIds.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,9 @@ private function __construct(){
public const SPIRE_ARMOR_TRIM_SMITHING_TEMPLATE = 20285;
public const PITCHER_POD = 20286;
public const NAME_TAG = 20287;
public const BAMBOO_SIGN = 20288;

public const FIRST_UNUSED_ITEM_ID = 20288;
public const FIRST_UNUSED_ITEM_ID = 20289;

private static int $nextDynamicId = self::FIRST_UNUSED_ITEM_ID;

Expand Down
10 changes: 10 additions & 0 deletions src/item/StringToItemParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,16 @@ private static function registerBlocks(self $result) : void{
$result->registerBlock("azure_bluet", fn() => Blocks::AZURE_BLUET());
$result->registerBlock("bamboo", fn() => Blocks::BAMBOO());
$result->registerBlock("bamboo_sapling", fn() => Blocks::BAMBOO_SAPLING());
$result->registerBlock("bamboo_button", fn() => Blocks::BAMBOO_BUTTON());
$result->registerBlock("bamboo_door", fn() => Blocks::BAMBOO_DOOR());
$result->registerBlock("bamboo_fence", fn() => Blocks::BAMBOO_FENCE());
$result->registerBlock("bamboo_fence_gate", fn() => Blocks::BAMBOO_FENCE_GATE());
$result->registerBlock("bamboo_planks", fn() => Blocks::BAMBOO_PLANKS());
$result->registerBlock("bamboo_pressure_plate", fn() => Blocks::BAMBOO_PRESSURE_PLATE());
$result->registerBlock("bamboo_sign", fn() => Blocks::BAMBOO_SIGN());
$result->registerBlock("bamboo_slab", fn() => Blocks::BAMBOO_SLAB());
$result->registerBlock("bamboo_stairs", fn() => Blocks::BAMBOO_STAIRS());
$result->registerBlock("bamboo_trapdoor", fn() => Blocks::BAMBOO_TRAPDOOR());
$result->registerBlock("banner", fn() => Blocks::BANNER());
$result->registerBlock("barrel", fn() => Blocks::BARREL());
$result->registerBlock("barrier", fn() => Blocks::BARRIER());
Expand Down
2 changes: 2 additions & 0 deletions src/item/VanillaItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@
* @method static WritableBook WRITABLE_BOOK()
* @method static WrittenBook WRITTEN_BOOK()
* @method static SpawnEgg ZOMBIE_SPAWN_EGG()
* @method static ItemBlockWallOrFloor BAMBOO_SIGN()
*/
final class VanillaItems{
use CloningRegistryTrait;
Expand Down Expand Up @@ -387,6 +388,7 @@ protected static function setup() : void{
self::register("carrot", new Carrot(new IID(Ids::CARROT), "Carrot"));
self::register("charcoal", new Coal(new IID(Ids::CHARCOAL), "Charcoal"));
self::register("cherry_sign", new ItemBlockWallOrFloor(new IID(Ids::CHERRY_SIGN), Blocks::CHERRY_SIGN(), Blocks::CHERRY_WALL_SIGN()));
self::register("bamboo_sign", new ItemBlockWallOrFloor(new IID(Ids::BAMBOO_SIGN), Blocks::BAMBOO_SIGN(), Blocks::BAMBOO_WALL_SIGN()));
self::register("chemical_aluminium_oxide", new Item(new IID(Ids::CHEMICAL_ALUMINIUM_OXIDE), "Aluminium Oxide"));
self::register("chemical_ammonia", new Item(new IID(Ids::CHEMICAL_AMMONIA), "Ammonia"));
self::register("chemical_barium_sulphate", new Item(new IID(Ids::CHEMICAL_BARIUM_SULPHATE), "Barium Sulphate"));
Expand Down

0 comments on commit fb4eaa8

Please sign in to comment.