facing) | ($this->top ? self::MASK_UPPER : 0) | ($this->open ? self::MASK_OPENED : 0); } public function readStateFromData(int $id, int $stateMeta) : void{ //TODO: in PC the values are reversed (facing - 2) $this->facing = BlockDataValidator::readHorizontalFacing(5 - ($stateMeta & 0x03)); $this->top = ($stateMeta & self::MASK_UPPER) !== 0; $this->open = ($stateMeta & self::MASK_OPENED) !== 0; } public function getStateBitmask() : int{ return 0b1111; } public function getHardness() : float{ return 3; } protected function recalculateBoundingBox() : ?AxisAlignedBB{ return AxisAlignedBB::one()->trim($this->open ? $this->facing : ($this->top ? Facing::DOWN : Facing::UP), 13 / 16); } 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()); } if(($clickVector->y > 0.5 and $face !== Facing::UP) or $face === Facing::DOWN){ $this->top = true; } return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player); } public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ $this->open = !$this->open; $this->level->setBlock($this, $this); $this->level->addSound($this, new DoorSound()); return true; } public function getToolType() : int{ return BlockToolType::TYPE_AXE; } public function getFuelTime() : int{ return 300; } }