151
151
use pocketmine \block \utils \DyeColor ;
152
152
use pocketmine \block \utils \FroglightType ;
153
153
use pocketmine \block \utils \LeverFacing ;
154
+ use pocketmine \block \utils \MobHeadType ;
154
155
use pocketmine \block \VanillaBlocks as Blocks ;
155
156
use pocketmine \block \Vine ;
156
157
use pocketmine \block \Wall ;
@@ -205,6 +206,7 @@ public function __construct(){
205
206
$ this ->registerFlatWoodBlockSerializers ();
206
207
$ this ->registerLeavesSerializers ();
207
208
$ this ->registerSaplingSerializers ();
209
+ $ this ->registerMobHeadSerializers ();
208
210
$ this ->registerSimpleSerializers ();
209
211
$ this ->registerSerializers ();
210
212
}
@@ -624,17 +626,7 @@ private function registerFlatWoodBlockSerializers() : void{
624
626
$ this ->mapSimple (Blocks::CHERRY_PLANKS (), Ids::CHERRY_PLANKS );
625
627
$ this ->mapSlab (Blocks::CHERRY_SLAB (), Ids::CHERRY_SLAB , Ids::CHERRY_DOUBLE_SLAB );
626
628
$ this ->mapStairs (Blocks::CHERRY_STAIRS (), Ids::CHERRY_STAIRS );
627
- $ this ->map (Blocks::CHERRY_WOOD (), function (Wood $ block ) : Writer {
628
- //we can't use the standard method for this because cherry_wood has a useless property attached to it
629
- if (!$ block ->isStripped ()){
630
- return Writer::create (Ids::CHERRY_WOOD )
631
- ->writePillarAxis ($ block ->getAxis ())
632
- ->writeBool (StateNames::STRIPPED_BIT , false ); //this is useless, but it has to be written
633
- }else {
634
- return Writer::create (Ids::STRIPPED_CHERRY_WOOD )
635
- ->writePillarAxis ($ block ->getAxis ());
636
- }
637
- });
629
+ $ this ->mapLog (Blocks::CHERRY_WOOD (), Ids::CHERRY_WOOD , Ids::STRIPPED_CHERRY_WOOD );
638
630
639
631
$ this ->map (Blocks::BAMBOO_DOOR (), fn (Door $ block ) => Helper::encodeDoor ($ block , new Writer (Ids::BAMBOO_DOOR )));
640
632
$ this ->map (Blocks::BAMBOO_BUTTON (), fn (Button $ block ) => Helper::encodeButton ($ block , new Writer (Ids::BAMBOO_BUTTON )));
@@ -702,17 +694,7 @@ private function registerFlatWoodBlockSerializers() : void{
702
694
$ this ->mapSimple (Blocks::MANGROVE_PLANKS (), Ids::MANGROVE_PLANKS );
703
695
$ this ->mapSlab (Blocks::MANGROVE_SLAB (), Ids::MANGROVE_SLAB , Ids::MANGROVE_DOUBLE_SLAB );
704
696
$ this ->mapStairs (Blocks::MANGROVE_STAIRS (), Ids::MANGROVE_STAIRS );
705
- $ this ->map (Blocks::MANGROVE_WOOD (), function (Wood $ block ) : Writer {
706
- //we can't use the standard method for this because mangrove_wood has a useless property attached to it
707
- if (!$ block ->isStripped ()){
708
- return Writer::create (Ids::MANGROVE_WOOD )
709
- ->writePillarAxis ($ block ->getAxis ())
710
- ->writeBool (StateNames::STRIPPED_BIT , false ); //this is useless, but it has to be written
711
- }else {
712
- return Writer::create (Ids::STRIPPED_MANGROVE_WOOD )
713
- ->writePillarAxis ($ block ->getAxis ());
714
- }
715
- });
697
+ $ this ->mapLog (Blocks::MANGROVE_WOOD (), Ids::MANGROVE_WOOD , Ids::STRIPPED_MANGROVE_WOOD );
716
698
717
699
$ this ->map (Blocks::OAK_BUTTON (), fn (WoodenButton $ block ) => Helper::encodeButton ($ block , new Writer (Ids::WOODEN_BUTTON )));
718
700
$ this ->map (Blocks::OAK_DOOR (), fn (WoodenDoor $ block ) => Helper::encodeDoor ($ block , new Writer (Ids::WOODEN_DOOR )));
@@ -787,6 +769,18 @@ private function registerSaplingSerializers() : void{
787
769
}
788
770
}
789
771
772
+ private function registerMobHeadSerializers () : void {
773
+ $ this ->map (Blocks::MOB_HEAD (), fn (MobHead $ block ) => Writer::create (match ($ block ->getMobHeadType ()){
774
+ MobHeadType::CREEPER => Ids::CREEPER_HEAD ,
775
+ MobHeadType::DRAGON => Ids::DRAGON_HEAD ,
776
+ MobHeadType::PIGLIN => Ids::PIGLIN_HEAD ,
777
+ MobHeadType::PLAYER => Ids::PLAYER_HEAD ,
778
+ MobHeadType::SKELETON => Ids::SKELETON_SKULL ,
779
+ MobHeadType::WITHER_SKELETON => Ids::WITHER_SKELETON_SKULL ,
780
+ MobHeadType::ZOMBIE => Ids::ZOMBIE_HEAD ,
781
+ })->writeFacingWithoutDown ($ block ->getFacing ()));
782
+ }
783
+
790
784
private function registerSimpleSerializers () : void {
791
785
$ this ->mapSimple (Blocks::AIR (), Ids::AIR );
792
786
$ this ->mapSimple (Blocks::AMETHYST (), Ids::AMETHYST_BLOCK );
@@ -1090,7 +1084,7 @@ private function registerSerializers() : void{
1090
1084
->writeBool (StateNames::RAIL_DATA_BIT , $ block ->isPowered ())
1091
1085
->writeInt (StateNames::RAIL_DIRECTION , $ block ->getShape ());
1092
1086
});
1093
- $ this ->map (Blocks::ALL_SIDED_MUSHROOM_STEM (), fn () => Writer::create (Ids::BROWN_MUSHROOM_BLOCK )
1087
+ $ this ->map (Blocks::ALL_SIDED_MUSHROOM_STEM (), fn () => Writer::create (Ids::MUSHROOM_STEM )
1094
1088
->writeInt (StateNames::HUGE_MUSHROOM_BITS , BlockLegacyMetadata::MUSHROOM_BLOCK_ALL_STEM ));
1095
1089
$ this ->map (Blocks::AMETHYST_CLUSTER (), fn (AmethystCluster $ block ) => Writer::create (
1096
1090
match ($ stage = $ block ->getStage ()){
@@ -1495,10 +1489,6 @@ private function registerSerializers() : void{
1495
1489
});
1496
1490
$ this ->map (Blocks::MATERIAL_REDUCER (), fn (ChemistryTable $ block ) => Helper::encodeChemistryTable ($ block , Writer::create (Ids::MATERIAL_REDUCER )));
1497
1491
$ this ->map (Blocks::MELON_STEM (), fn (MelonStem $ block ) => Helper::encodeStem ($ block , new Writer (Ids::MELON_STEM )));
1498
- $ this ->map (Blocks::MOB_HEAD (), function (MobHead $ block ) : Writer {
1499
- return Writer::create (Ids::SKULL )
1500
- ->writeFacingWithoutDown ($ block ->getFacing ());
1501
- });
1502
1492
$ this ->mapSlab (Blocks::MOSSY_COBBLESTONE_SLAB (), Ids::MOSSY_COBBLESTONE_SLAB , Ids::MOSSY_COBBLESTONE_DOUBLE_SLAB );
1503
1493
$ this ->mapStairs (Blocks::MOSSY_COBBLESTONE_STAIRS (), Ids::MOSSY_COBBLESTONE_STAIRS );
1504
1494
$ this ->map (Blocks::MOSSY_COBBLESTONE_WALL (), fn (Wall $ block ) => Helper::encodeWall ($ block , Writer::create (Ids::MOSSY_COBBLESTONE_WALL )));
@@ -1510,7 +1500,7 @@ private function registerSerializers() : void{
1510
1500
$ this ->map (Blocks::MUD_BRICK_WALL (), fn (Wall $ block ) => Helper::encodeWall ($ block , new Writer (Ids::MUD_BRICK_WALL )));
1511
1501
$ this ->map (Blocks::MUDDY_MANGROVE_ROOTS (), fn (SimplePillar $ block ) => Writer::create (Ids::MUDDY_MANGROVE_ROOTS )
1512
1502
->writePillarAxis ($ block ->getAxis ()));
1513
- $ this ->map (Blocks::MUSHROOM_STEM (), fn () => Writer::create (Ids::BROWN_MUSHROOM_BLOCK )
1503
+ $ this ->map (Blocks::MUSHROOM_STEM (), fn () => Writer::create (Ids::MUSHROOM_STEM )
1514
1504
->writeInt (StateNames::HUGE_MUSHROOM_BITS , BlockLegacyMetadata::MUSHROOM_BLOCK_STEM ));
1515
1505
$ this ->mapSlab (Blocks::NETHER_BRICK_SLAB (), Ids::NETHER_BRICK_SLAB , Ids::NETHER_BRICK_DOUBLE_SLAB );
1516
1506
$ this ->mapStairs (Blocks::NETHER_BRICK_STAIRS (), Ids::NETHER_BRICK_STAIRS );
0 commit comments