public function onActivate(Item $item, Player $player = null) { if ($player instanceof Player) { $top = $this->getSide(1); if ($top->isTransparent !== true) { return true; } $t = $this->getLevel()->getTile($this); $chest = null; if ($t instanceof TileChest) { $chest = $t; } else { $nbt = new Compound(false, [new Enum("Items", []), new String("id", Tile::CHEST), new Int("x", $this->x), new Int("y", $this->y), new Int("z", $this->z)]); $nbt->Items->setTagType(NBT::TAG_Compound); $chest = new TileChest($this->getLevel()->getChunkAt($this->x >> 4, $this->z >> 4), $nbt); } if (($player->gamemode & 0x1) === 0x1) { return true; } $player->addWindow($chest->getInventory()); } return true; }