facing; } public function readStateFromData(int $id, int $stateMeta) : void{ $this->facing = BlockDataValidator::readHorizontalFacing($stateMeta); } public function getStateBitmask() : int{ return 0b111; } protected function recalculateBoundingBox() : ?AxisAlignedBB{ //these are slightly bigger than in PC return AxisAlignedBB::one()->contract(0.025, 0, 0.025)->trim(Facing::UP, 0.05); } 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(parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player)){ $tile = $this->world->getTile($this); if($tile instanceof TileChest){ foreach([ Facing::rotateY($this->facing, true), Facing::rotateY($this->facing, false) ] as $side){ $c = $this->getSide($side); if($c instanceof Chest and $c->isSameType($this) and $c->facing === $this->facing){ $pair = $this->world->getTile($c); if($pair instanceof TileChest and !$pair->isPaired()){ $pair->pairWith($tile); $tile->pairWith($pair); break; } } } } return true; } return false; } public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if($player instanceof Player){ $chest = $this->getWorld()->getTile($this); if($chest instanceof TileChest){ if( !$this->getSide(Facing::UP)->isTransparent() or ($chest->isPaired() and !$chest->getPair()->getBlock()->getSide(Facing::UP)->isTransparent()) or !$chest->canOpenWith($item->getCustomName()) ){ return true; } $player->addWindow($chest->getInventory()); } } return true; } public function getFuelTime() : int{ return 300; } }