public function close() { if ($this->closed === false) { foreach ($this->getInventory()->getViewers() as $player) { $player->removeWindow($this->getInventory()); } parent::close(); } }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { $down = $block->getSide(0); if ($down->isTransparent() === false || $down instanceof Slab && ($down->meta & 0x8) === 0x8 || $down instanceof WoodSlab && ($down->meta & 0x8) === 0x8 || $down instanceof Stair && ($down->meta & 0x4) === 0x4) { $this->getLevel()->setBlock($block, $this, true, true); $nbt = new Compound("", [new String("id", Tile::FLOWER_POT), new Int("x", $block->x), new Int("y", $block->y), new Int("z", $block->z), new Int("item", 0), new Int("data", 0)]); $pot = Tile::createTile("FlowerPot", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt); return true; } return false; }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { $this->getLevel()->setBlock($block, $this, true, true); $nbt = new Compound("", [new String("id", Tile::ENCHANT_TABLE), new Int("x", $this->x), new Int("y", $this->y), new Int("z", $this->z)]); if ($item->hasCustomName()) { $nbt->CustomName = new String("CustomName", $item->getCustomName()); } if ($item->hasCustomBlockData()) { foreach ($item->getCustomBlockData() as $key => $v) { $nbt->{$key} = $v; } } Tile::createTile(Tile::ENCHANT_TABLE, $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt); return true; }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { $down = $this->getSide(0); if ($face !== 0 && $fy > 0.5 && $target->getId() !== self::SKULL_BLOCK && !$down instanceof SkullBlock) { $this->getLevel()->setBlock($block, Block::get(Block::SKULL_BLOCK, 0), true, true); if ($face === 1) { $rot = new Byte("Rot", floor($player->yaw * 16 / 360 + 0.5) & 0xf); } else { $rot = new Byte("Rot", 0); } $nbt = new Compound("", [new String("id", Tile::SKULL), new Int("x", $block->x), new Int("y", $block->y), new Int("z", $block->z), new Byte("SkullType", $item->getDamage()), $rot]); $chunk = $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4); $pot = Tile::createTile("Skull", $chunk, $nbt); $this->getLevel()->setBlock($block, Block::get(Block::SKULL_BLOCK, $face), true, true); return true; } return false; }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { if ($block->getSide(Vector3::SIDE_DOWN)->isTransparent() === false) { $this->getLevel()->setBlock($block, $this, true, true); $nbt = new Compound("", [new String("id", Tile::BREWING_STAND), new Int("x", $this->x), new Int("y", $this->y), new Int("z", $this->z)]); if ($item->hasCustomName()) { $nbt->CustomName = new String("CustomName", $item->getCustomName()); } if ($item->hasCustomBlockData()) { foreach ($item->getCustomBlockData() as $key => $v) { $nbt->{$key} = $v; } } Tile::createTile(Tile::BREWING_STAND, $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt); return true; } return false; }
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("", [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 = Tile::createTile("Chest", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt); } if (isset($chest->namedtag->Lock) and $chest->namedtag->Lock instanceof String) { if ($chest->namedtag->Lock->getValue() !== $item->getCustomName()) { return true; } } if ($player->isCreative()) { return true; } $player->addWindow($chest->getInventory()); } return true; }
public function __construct(FullChunk $chunk, Compound $nbt) { parent::__construct($chunk, $nbt); $this->spawnToAll(); }
/** * @param Tile $tile * * @throws LevelException */ public function removeTile(Tile $tile) { if ($tile->getLevel() !== $this) { throw new LevelException("Invalid Tile level"); } unset($this->tiles[$tile->getId()]); unset($this->updateTiles[$tile->getId()]); $this->clearChunkCache($tile->getX() >> 4, $tile->getZ() >> 4); }
public function removeTile(Tile $tile) { unset($this->tiles[$tile->getId()]); unset($this->tileList[($tile->z & 0xf) << 12 | ($tile->x & 0xf) << 8 | $tile->y & 0xff]); if ($this->isInit) { $this->hasChanged = true; } }
public function onActivate(Item $item, Player $player = null) { if ($player instanceof Player) { $t = $this->getLevel()->getTile($this); $furnace = false; if ($t instanceof Furnace) { $furnace = $t; } else { $nbt = new Compound("", [new Enum("Items", []), new String("id", Tile::FURNACE), new Int("x", $this->x), new Int("y", $this->y), new Int("z", $this->z)]); $nbt->Items->setTagType(NBT::TAG_Compound); $furnace = Tile::createTile("Furnace", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt); } if (isset($furnace->namedtag->Lock) and $furnace->namedtag->Lock instanceof String) { if ($furnace->namedtag->Lock->getValue() !== $item->getCustomName()) { return true; } } if ($player->isCreative()) { return true; } $player->addWindow($furnace->getInventory()); } return true; }