52 $world = $this->position->getWorld();
53 $tile = $world->getTile($this->position);
54 if($tile instanceof TileChest){
55 foreach([
false,
true] as $clockwise){
56 $side = Facing::rotateY($this->facing, $clockwise);
57 $c = $this->getSide($side);
59 $pair = $world->getTile($c->position);
60 if($pair instanceof TileChest && !$pair->isPaired()){
61 [$left, $right] = $clockwise ? [$c, $this] : [$this, $c];
64 if(!$ev->isCancelled() && $world->getBlock($this->position)->hasSameTypeId($this) && $world->getBlock($c->position)->hasSameTypeId($c)){
65 $pair->pairWith($tile);
66 $tile->pairWith($pair);
76 if($player instanceof
Player){
78 $chest = $this->position->getWorld()->getTile($this->position);
79 if($chest instanceof TileChest){
81 !$this->getSide(Facing::UP)->isTransparent() ||
82 (($pair = $chest->getPair()) !==
null && !$pair->getBlock()->getSide(Facing::UP)->isTransparent()) ||
83 !$chest->canOpenWith($item->getCustomName())
88 $player->setCurrentWindow($chest->getInventory());