49 $world = $this->position->getWorld();
50 $tile = $world->getTile($this->position);
51 if($tile instanceof TileChest){
52 foreach([
false,
true] as $clockwise){
53 $side = Facing::rotateY($this->facing, $clockwise);
54 $c = $this->getSide($side);
56 $pair = $world->getTile($c->position);
57 if($pair instanceof TileChest && !$pair->isPaired()){
58 [$left, $right] = $clockwise ? [$c, $this] : [$this, $c];
61 if(!$ev->isCancelled() && $world->getBlock($this->position)->hasSameTypeId($this) && $world->getBlock($c->position)->hasSameTypeId($c)){
62 $pair->pairWith($tile);
63 $tile->pairWith($pair);
73 if($player instanceof
Player){
75 $chest = $this->position->getWorld()->getTile($this->position);
76 if($chest instanceof TileChest){
78 !$this->getSide(Facing::UP)->isTransparent() ||
79 (($pair = $chest->getPair()) !==
null && !$pair->getBlock()->getSide(Facing::UP)->isTransparent()) ||
80 !$chest->canOpenWith($item->getCustomName())
85 $player->setCurrentWindow($chest->getInventory());