diff --git a/src/pocketmine/block/Pumpkin.php b/src/pocketmine/block/Pumpkin.php index 245996a71..5e4832418 100644 --- a/src/pocketmine/block/Pumpkin.php +++ b/src/pocketmine/block/Pumpkin.php @@ -23,14 +23,36 @@ declare(strict_types=1); namespace pocketmine\block; +use pocketmine\block\utils\BlockDataValidator; +use pocketmine\item\Item; +use pocketmine\math\Bearing; +use pocketmine\math\Facing; +use pocketmine\math\Vector3; +use pocketmine\Player; + class Pumpkin extends Solid{ protected $id = self::PUMPKIN; + /** @var int */ + protected $facing = Facing::NORTH; + public function __construct(){ } + public function readStateFromMeta(int $meta) : void{ + $this->facing = BlockDataValidator::readLegacyHorizontalFacing($meta & 0x03); + } + + protected function writeStateToMeta() : int{ + return Bearing::fromFacing($this->facing); + } + + public function getStateBitmask() : int{ + return 0b11; + } + public function getHardness() : float{ return 1; } @@ -42,4 +64,11 @@ class Pumpkin extends Solid{ public function getName() : string{ return "Pumpkin"; } + + public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{ + if($player !== null){ + $this->facing = Facing::opposite($player->getHorizontalFacing()); + } + return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player); + } }