25
25
26
26
use pocketmine \block \ActivatorRail ;
27
27
use pocketmine \block \BambooSapling ;
28
+ use pocketmine \block \Bed ;
28
29
use pocketmine \block \Bedrock ;
30
+ use pocketmine \block \Bell ;
29
31
use pocketmine \block \Block ;
32
+ use pocketmine \block \BrewingStand ;
30
33
use pocketmine \block \Cactus ;
31
34
use pocketmine \block \Cake ;
32
35
use pocketmine \block \ChorusFlower ;
40
43
use pocketmine \block \FrostedIce ;
41
44
use pocketmine \block \Lantern ;
42
45
use pocketmine \block \Lectern ;
46
+ use pocketmine \block \Lever ;
43
47
use pocketmine \block \MobHead ;
44
48
use pocketmine \block \NetherVines ;
45
49
use pocketmine \block \NetherWartPlant ;
50
+ use pocketmine \block \PinkPetals ;
46
51
use pocketmine \block \PoweredRail ;
47
52
use pocketmine \block \Rail ;
48
53
use pocketmine \block \RedstoneWire ;
53
58
use pocketmine \block \StraightOnlyRail ;
54
59
use pocketmine \block \Sugarcane ;
55
60
use pocketmine \block \Tripwire ;
61
+ use pocketmine \block \TripwireHook ;
62
+ use pocketmine \block \utils \BellAttachmentType ;
63
+ use pocketmine \block \utils \BrewingStandSlot ;
56
64
use pocketmine \block \utils \Colored ;
57
65
use pocketmine \block \utils \FroglightType ;
66
+ use pocketmine \block \utils \LeverFacing ;
58
67
use pocketmine \block \utils \MobHeadType ;
59
68
use pocketmine \block \VanillaBlocks as Blocks ;
60
69
use pocketmine \block \WeightedPressurePlate ;
66
75
use pocketmine \data \bedrock \block \convert \property \AxisProperty ;
67
76
use pocketmine \data \bedrock \block \convert \property \BoolProperty ;
68
77
use pocketmine \data \bedrock \block \convert \property \CardinalHorizontalFacingProperty ;
78
+ use pocketmine \data \bedrock \block \convert \property \EnumProperty ;
69
79
use pocketmine \data \bedrock \block \convert \property \IntProperty ;
80
+ use pocketmine \data \bedrock \block \convert \property \LegacyHorizontalFacingProperty ;
70
81
use pocketmine \data \bedrock \block \convert \property \Model ;
82
+ use function array_map ;
83
+ use function min ;
71
84
72
85
/**
73
86
* Registers serializers and deserializers for block data in a unified style, to avoid code duplication.
@@ -943,9 +956,29 @@ private function register1to1CustomMappings() : void{
943
956
new IntProperty (StateNames::GROUND_SIGN_DIRECTION , 0 , 15 , fn (FloorBanner $ b ) => $ b ->getRotation (), fn (FloorBanner $ b , int $ v ) => $ b ->setRotation ($ v ))
944
957
]));
945
958
$ this ->mapModel (Model::create (Blocks::BASALT (), Ids::BASALT )->properties ([AxisProperty::getInstance ()]));
959
+ $ this ->mapModel (Model::create (Blocks::BED (), Ids::BED )->properties ([
960
+ new BoolProperty (StateNames::HEAD_PIECE_BIT , fn (Bed $ b ) => $ b ->isHeadPart (), fn (Bed $ b , bool $ v ) => $ b ->setHead ($ v )),
961
+ new BoolProperty (StateNames::OCCUPIED_BIT , fn (Bed $ b ) => $ b ->isOccupied (), fn (Bed $ b , bool $ v ) => $ b ->setOccupied ($ v )),
962
+ LegacyHorizontalFacingProperty::getInstance ()
963
+ ]));
946
964
$ this ->mapModel (Model::create (Blocks::BEDROCK (), Ids::BEDROCK )->properties ([
947
965
new BoolProperty (StateNames::INFINIBURN_BIT , fn (Bedrock $ b ) => $ b ->burnsForever (), fn (Bedrock $ b , bool $ v ) => $ b ->setBurnsForever ($ v ))
948
966
]));
967
+ $ this ->mapModel (Model::create (Blocks::BELL (), Ids::BELL )->properties ([
968
+ BoolProperty::unused (StateNames::TOGGLE_BIT , false ),
969
+ new EnumProperty (StateNames::ATTACHMENT , BellAttachmentType::class, fn (Bell $ b ) => $ b ->getAttachmentType (), fn (Bell $ b , BellAttachmentType $ v ) => $ b ->setAttachmentType ($ v )),
970
+ LegacyHorizontalFacingProperty::getInstance ()
971
+ ]));
972
+ $ this ->mapModel (Model::create (Blocks::BONE_BLOCK (), Ids::BONE_BLOCK )->properties ([
973
+ IntProperty::unused (StateNames::DEPRECATED , 0 ),
974
+ AxisProperty::getInstance ()
975
+ ]));
976
+
977
+ $ this ->mapModel (Model::create (Blocks::BREWING_STAND (), Ids::BREWING_STAND )->properties (array_map (fn (BrewingStandSlot $ slot ) => new BoolProperty (match ($ slot ){
978
+ BrewingStandSlot::EAST => StateNames::BREWING_STAND_SLOT_A_BIT ,
979
+ BrewingStandSlot::SOUTHWEST => StateNames::BREWING_STAND_SLOT_B_BIT ,
980
+ BrewingStandSlot::NORTHWEST => StateNames::BREWING_STAND_SLOT_C_BIT
981
+ }, fn (BrewingStand $ b ) => $ b ->hasSlot ($ slot ), fn (BrewingStand $ b , bool $ v ) => $ b ->setSlot ($ slot , $ v )), BrewingStandSlot::cases ())));
949
982
950
983
//C
951
984
$ this ->mapModel (Model::create (Blocks::CAKE (), Ids::CAKE )->properties ([
@@ -985,6 +1018,9 @@ private function register1to1CustomMappings() : void{
985
1018
$ this ->mapModel (Model::create (Blocks::FIRE (), Ids::FIRE )->properties ([
986
1019
new IntProperty (StateNames::AGE , 0 , 15 , fn (Fire $ b ) => $ b ->getAge (), fn (Fire $ b , int $ v ) => $ b ->setAge ($ v ))
987
1020
]));
1021
+ $ this ->mapModel (Model::create (Blocks::FLOWER_POT (), Ids::FLOWER_POT )->properties ([
1022
+ BoolProperty::unused (StateNames::UPDATE_BIT , false )
1023
+ ]));
988
1024
$ this ->mapModel (Model::create (Blocks::FROSTED_ICE (), Ids::FROSTED_ICE )->properties ([
989
1025
new IntProperty (StateNames::AGE , 0 , 3 , fn (FrostedIce $ b ) => $ b ->getAge (), fn (FrostedIce $ b , int $ v ) => $ b ->setAge ($ v ))
990
1026
]));
@@ -997,9 +1033,16 @@ private function register1to1CustomMappings() : void{
997
1033
new BoolProperty (StateNames::POWERED_BIT , fn (Lectern $ b ) => $ b ->isProducingSignal (), fn (Lectern $ b , bool $ v ) => $ b ->setProducingSignal ($ v )),
998
1034
CardinalHorizontalFacingProperty::getInstance ()
999
1035
]));
1036
+ $ this ->mapModel (Model::create (Blocks::LEVER (), Ids::LEVER )->properties ([
1037
+ new EnumProperty (StateNames::LEVER_DIRECTION , LeverFacing::class, fn (Lever $ b ) => $ b ->getFacing (), fn (Lever $ b , LeverFacing $ v ) => $ b ->setFacing ($ v )),
1038
+ new BoolProperty (StateNames::OPEN_BIT , fn (Lever $ b ) => $ b ->isActivated (), fn (Lever $ b , bool $ v ) => $ b ->setActivated ($ v )),
1039
+ ]));
1000
1040
$ this ->mapModel (Model::create (Blocks::LIT_PUMPKIN (), Ids::LIT_PUMPKIN )->properties ([
1001
1041
CardinalHorizontalFacingProperty::getInstance ()
1002
1042
]));
1043
+ $ this ->mapModel (Model::create (Blocks::LOOM (), Ids::LOOM )->properties ([
1044
+ LegacyHorizontalFacingProperty::getInstance ()
1045
+ ]));
1003
1046
1004
1047
//M
1005
1048
$ this ->mapModel (Model::create (Blocks::MUDDY_MANGROVE_ROOTS (), Ids::MUDDY_MANGROVE_ROOTS )->properties ([AxisProperty::getInstance ()]));
@@ -1008,6 +1051,11 @@ private function register1to1CustomMappings() : void{
1008
1051
]));
1009
1052
1010
1053
//P
1054
+ $ this ->mapModel (Model::create (Blocks::PINK_PETALS (), Ids::PINK_PETALS )->properties ([
1055
+ //Pink petals only uses 0-3, but GROWTH state can go up to 7
1056
+ new IntProperty (StateNames::GROWTH , 0 , 7 , fn (PinkPetals $ b ) => $ b ->getCount (), fn (PinkPetals $ b , int $ v ) => $ b ->setCount (min ($ v , PinkPetals::MAX_COUNT )), offset: 1 ),
1057
+ CardinalHorizontalFacingProperty::getInstance ()
1058
+ ]));
1011
1059
$ this ->mapModel (Model::create (Blocks::POWERED_RAIL (), Ids::GOLDEN_RAIL )->properties ([
1012
1060
new BoolProperty (StateNames::RAIL_DATA_BIT , fn (PoweredRail $ b ) => $ b ->isPowered (), fn (PoweredRail $ b , bool $ v ) => $ b ->setPowered ($ v )), //TODO: shared with ActivatorRail
1013
1061
new IntProperty (StateNames::RAIL_DIRECTION , 0 , 5 , fn (StraightOnlyRail $ b ) => $ b ->getShape (), fn (StraightOnlyRail $ b , int $ v ) => $ b ->setShape ($ v )) //TODO: shared with ActivatorRail
@@ -1051,13 +1099,17 @@ private function register1to1CustomMappings() : void{
1051
1099
$ this ->mapModel (Model::create (Blocks::TRAPPED_CHEST (), Ids::TRAPPED_CHEST )->properties ([
1052
1100
CardinalHorizontalFacingProperty::getInstance ()
1053
1101
]));
1054
- //tripwire connected disarmed suspended triggered
1055
1102
$ this ->mapModel (Model::create (Blocks::TRIPWIRE (), Ids::TRIP_WIRE )->properties ([
1056
1103
new BoolProperty (StateNames::ATTACHED_BIT , fn (Tripwire $ b ) => $ b ->isConnected (), fn (Tripwire $ b , bool $ v ) => $ b ->setConnected ($ v )),
1057
1104
new BoolProperty (StateNames::DISARMED_BIT , fn (Tripwire $ b ) => $ b ->isDisarmed (), fn (Tripwire $ b , bool $ v ) => $ b ->setDisarmed ($ v )),
1058
1105
new BoolProperty (StateNames::SUSPENDED_BIT , fn (Tripwire $ b ) => $ b ->isSuspended (), fn (Tripwire $ b , bool $ v ) => $ b ->setSuspended ($ v )),
1059
1106
new BoolProperty (StateNames::POWERED_BIT , fn (Tripwire $ b ) => $ b ->isTriggered (), fn (Tripwire $ b , bool $ v ) => $ b ->setTriggered ($ v )),
1060
1107
]));
1108
+ $ this ->mapModel (Model::create (Blocks::TRIPWIRE_HOOK (), Ids::TRIPWIRE_HOOK )->properties ([
1109
+ new BoolProperty (StateNames::ATTACHED_BIT , fn (TripwireHook $ b ) => $ b ->isConnected (), fn (TripwireHook $ b , bool $ v ) => $ b ->setConnected ($ v )),
1110
+ new BoolProperty (StateNames::POWERED_BIT , fn (TripwireHook $ b ) => $ b ->isPowered (), fn (TripwireHook $ b , bool $ v ) => $ b ->setPowered ($ v )),
1111
+ LegacyHorizontalFacingProperty::getInstance ()
1112
+ ]));
1061
1113
1062
1114
$ this ->mapModel (Model::create (Blocks::TWISTING_VINES (), Ids::TWISTING_VINES )->properties ([
1063
1115
new IntProperty (StateNames::TWISTING_VINES_AGE , 0 , 25 , fn (NetherVines $ b ) => $ b ->getAge (), fn (NetherVines $ b , int $ v ) => $ b ->setAge ($ v ))
0 commit comments