diff --git a/src/pocketmine/block/utils/Color.php b/src/pocketmine/block/utils/Color.php new file mode 100644 index 000000000..2b89fad1f --- /dev/null +++ b/src/pocketmine/block/utils/Color.php @@ -0,0 +1,81 @@ + "White", + self::ORANGE => "Orange", + self::MAGENTA => "Magenta", + self::LIGHT_BLUE => "Light Blue", + self::YELLOW => "Yellow", + self::LIME => "Lime", + self::PINK => "Pink", + self::GRAY => "Gray", + self::LIGHT_GRAY => "Light Gray", + self::CYAN => "Cyan", + self::PURPLE => "Purple", + self::BLUE => "Blue", + self::BROWN => "Brown", + self::GREEN => "Green", + self::RED => "Red", + self::BLACK => "Black" + ]; +} diff --git a/src/pocketmine/block/utils/PillarRotationTrait.php b/src/pocketmine/block/utils/PillarRotationTrait.php new file mode 100644 index 000000000..a7531e77f --- /dev/null +++ b/src/pocketmine/block/utils/PillarRotationTrait.php @@ -0,0 +1,76 @@ +writeAxisToMeta(); + } + + /** + * @see Block::readStateFromMeta() + * @param int $meta + */ + public function readStateFromMeta(int $meta) : void{ + $this->readAxisFromMeta($meta); + } + + /** + * @see Block::getStateBitmask() + * @return int + */ + public function getStateBitmask() : int{ + return 0b1100; + } + + protected function readAxisFromMeta(int $meta) : void{ + static $map = [ + 0 => Facing::AXIS_Y, + 1 => Facing::AXIS_X, + 2 => Facing::AXIS_Z, + 3 => Facing::AXIS_Y //TODO: how to deal with all-bark logs? + ]; + $this->axis = $map[$meta >> 2]; + } + + protected function writeAxisToMeta() : int{ + static $bits = [ + Facing::AXIS_Y => 0, + Facing::AXIS_Z => 2, + Facing::AXIS_X => 1 + ]; + return $bits[$this->axis] << 2; + } +} diff --git a/src/pocketmine/block/utils/WoodType.php b/src/pocketmine/block/utils/WoodType.php new file mode 100644 index 000000000..8963b5e5a --- /dev/null +++ b/src/pocketmine/block/utils/WoodType.php @@ -0,0 +1,51 @@ + "Oak", + self::SPRUCE => "Spruce", + self::BIRCH => "Birch", + self::JUNGLE => "Jungle", + self::ACACIA => "Acacia", + self::DARK_OAK => "Dark Oak" + ]; +}