facing; } public function readStateFromData(int $id, int $stateMeta) : void{ $this->facing = $stateMeta === 5 ? Facing::UP : BlockDataValidator::readHorizontalFacing(6 - $stateMeta); } public function getStateBitmask() : int{ return 0b111; } public function getLightLevel() : int{ return 14; } public function onNearbyBlockChange() : void{ $below = $this->getSide(Facing::DOWN); $face = Facing::opposite($this->facing); if($this->getSide($face)->isTransparent() and !($face === Facing::DOWN and ($below->getId() === BlockIds::FENCE or $below->getId() === BlockIds::COBBLESTONE_WALL))){ $this->getLevel()->useBreakOn($this); } } public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if($blockClicked->canBeReplaced() and !$blockClicked->getSide(Facing::DOWN)->isTransparent()){ $this->facing = Facing::UP; return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player); }elseif($face !== Facing::DOWN and (!$blockClicked->isTransparent() or ($face === Facing::UP and ($blockClicked->getId() === BlockIds::FENCE or $blockClicked->getId() === BlockIds::COBBLESTONE_WALL)))){ $this->facing = $face; return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player); }else{ static $faces = [ Facing::SOUTH, Facing::WEST, Facing::NORTH, Facing::EAST, Facing::DOWN ]; foreach($faces as $side){ $block = $this->getSide($side); if(!$block->isTransparent()){ $this->facing = Facing::opposite($side); return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player); } } } return false; } }