public function onActivate(Item $item, Player $player = null) { if ($player instanceof Player) { $t = $this->getLevel()->getTile($this); if ($t instanceof FurnaceTile) { $furnace = $t; } else { $nbt = new CompoundTag("", [new ListTag("Items", []), new StringTag("id", Tile::FURNACE), new IntTag("x", $this->x), new IntTag("y", $this->y), new IntTag("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 StringTag) { if ($furnace->namedtag->Lock->getValue() !== $item->getCustomName()) { return true; } } if ($player->isCreative() and $player->getServer()->limitedCreative) { return true; } $player->addWindow($furnace->getInventory()); } return true; }
/** * @param Tile $tile * @return bool */ public function isBadSign(Tile $tile) { if ($tile instanceof Sign) { $text = ""; foreach ($tile->getText() as $line) { $text .= strtolower(trim($line)); } } }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { $this->getLevel()->setBlock($this, $this, true, true); $nbt = new CompoundTag("", [new StringTag("id", MainClass::TILE_NOTE), new IntTag("x", $block->x), new IntTag("y", $block->y), new IntTag("z", $block->z), new ByteTag("note", 0)]); $pot = Tile::createTile("Note", $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) { $this->getLevel()->setBlock($block, $this, true, false); $nbt = new CompoundTag("", [new StringTag("id", Tile::DAY_LIGHT_DETECTOR), new IntTag("x", $this->x), new IntTag("y", $this->y), new IntTag("z", $this->z)]); Tile::createTile(Tile::DAY_LIGHT_DETECTOR, $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) { $this->getLevel()->setBlock($block, $this, true, true); $nbt = new CompoundTag("", [new StringTag("id", Tile::MOB_SPAWNER), new IntTag("x", $block->x), new IntTag("y", $block->y), new IntTag("z", $block->z), new IntTag("EntityId", 0)]); Tile::createTile(Tile::MOB_SPAWNER, $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt); return true; }
public function onEnable() { //アイテムの追加 Item::$list[self::ITEM_FLOWER_POT] = ItemFlowerPot::class; //ブロックの追加 $this->registerBlock(self::BLOCK_FLOWER_POT, BlockFlowerPot::class); //ブロックタイルエンティティの追加 Tile::registerTile(FlowerPot::class); //アイテムをクリエイティブタブに追加 Item::addCreativeItem(Item::get(self::ITEM_FLOWER_POT, 0)); //一応レシピ追加 Server::getInstance()->getCraftingManager()->registerRecipe((new ShapedRecipe(Item::get(MainClass::ITEM_FLOWER_POT, 0, 1), "X X", " X "))->setIngredient("X", Item::get(Item::BRICK, null))); //omake skull //アイテムの追加 Item::$list[self::ITEM_SKULL] = ItemSkull::class; //ブロックの追加 $this->registerBlock(self::BLOCK_SKULL, BlockSkull::class); //ブロックタイルエンティティの追加 Tile::registerTile(Skull::class); //アイテムをクリエイティブタブに追加 Item::addCreativeItem(Item::get(self::ITEM_SKULL, 0)); Item::addCreativeItem(Item::get(self::ITEM_SKULL, 1)); Item::addCreativeItem(Item::get(self::ITEM_SKULL, 2)); Item::addCreativeItem(Item::get(self::ITEM_SKULL, 3)); Item::addCreativeItem(Item::get(self::ITEM_SKULL, 4)); }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { if ($face !== 0) { $nbt = new CompoundTag("", ["id" => new StringTag("id", Tile::SIGN), "x" => new IntTag("x", $block->x), "y" => new IntTag("y", $block->y), "z" => new IntTag("z", $block->z), "Text1" => new StringTag("Text1", ""), "Text2" => new StringTag("Text2", ""), "Text3" => new StringTag("Text3", ""), "Text4" => new StringTag("Text4", "")]); if ($player !== null) { $nbt->Creator = new StringTag("Creator", $player->getRawUniqueId()); } if ($item->hasCustomBlockData()) { foreach ($item->getCustomBlockData() as $key => $v) { $nbt->{$key} = $v; } } if ($face === 1) { $this->meta = floor(($player->yaw + 180) * 16 / 360 + 0.5) & 0xf; $this->getLevel()->setBlock($block, Block::get(Item::SIGN_POST, $this->meta), true); Tile::createTile(Tile::SIGN, $this->getLevel()->getChunk($block->x >> 4, $block->z >> 4), $nbt); return true; } else { $this->meta = $face; $this->getLevel()->setBlock($block, Block::get(Item::WALL_SIGN, $this->meta), true); Tile::createTile(Tile::SIGN, $this->getLevel()->getChunk($block->x >> 4, $block->z >> 4), $nbt); return true; } } return false; }
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) { $nbt = new CompoundTag("", [new StringTag("id", MainClass::TILE_CAULDRON), new IntTag("x", $block->x), new IntTag("y", $block->y), new IntTag("z", $block->z), new ShortTag("PotionId", 0xffff), new ByteTag("SplashPotion", 0), new ListTag("Items", [])]); $chunk = $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4); $tile = Tile::createTile("Cauldron", $chunk, $nbt); // $this->getLevel()->setBlock($block, $this, true, true); return true; }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { if ($this->getSide(Vector3::SIDE_DOWN)->isTransparent() === false) { $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; }
/** * @return DLDetector */ protected function getTile() { $t = $this->getLevel()->getTile($this); if ($t instanceof DLDetector) { return $t; } else { $nbt = new CompoundTag("", [new StringTag("id", Tile::DAY_LIGHT_DETECTOR), new IntTag("x", $this->x), new IntTag("y", $this->y), new IntTag("z", $this->z)]); return Tile::createTile(Tile::DAY_LIGHT_DETECTOR, $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt); } }
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 Short("item", 0), new Int("mData", 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) { if ($face !== 0) { $this->getLevel()->setBlock($block, Block::get(MainClass::BLOCK_SKULL, 0), true, true); $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()), new Byte("Rot", floor($player->yaw * 16 / 360 + 0.5) & 0xf)]); $chunk = $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4); $pot = Tile::createTile("Skull", $chunk, $nbt); $this->getLevel()->setBlock($block, Block::get(MainClass::BLOCK_SKULL, $face), true, true); 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 CompoundTag("", [new StringTag("id", Tile::MOB_SPAWNER), new IntTag("x", $block->x), new IntTag("y", $block->y), new IntTag("z", $block->z), new IntTag("EntityId", 0)]); if ($item->hasCustomBlockData()) { foreach ($item->getCustomBlockData() as $key => $v) { $nbt->{$key} = $v; } } Tile::createTile(Tile::MOB_SPAWNER, $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) { $nbt = new CompoundTag("", [new StringTag("id", Tile::CAULDRON), new IntTag("x", $block->x), new IntTag("y", $block->y), new IntTag("z", $block->z), new ShortTag("PotionId", 0xffff), new ByteTag("SplashPotion", 0), new ListTag("Items", [])]); if ($item->hasCustomBlockData()) { foreach ($item->getCustomBlockData() as $key => $v) { $nbt->{$key} = $v; } } $chunk = $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4); $tile = Tile::createTile("Cauldron", $chunk, $nbt); $this->getLevel()->setBlock($block, $this, true, true); return true; }
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) { if ($this->getSide(Vector3::SIDE_DOWN)->isTransparent()) { return false; } $this->getLevel()->setBlock($block, $this, true, true); $nbt = new CompoundTag("", [new StringTag("id", Tile::FLOWER_POT), new IntTag("x", $block->x), new IntTag("y", $block->y), new IntTag("z", $block->z), new ShortTag("item", 0), new IntTag("mData", 0)]); if ($item->hasCustomBlockData()) { foreach ($item->getCustomBlockData() as $key => $v) { $nbt->{$key} = $v; } } Tile::createTile(Tile::FLOWER_POT, $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt); return true; }
public function onActivate(Item $item, Player $player = null) { if ($player instanceof Player) { //TODO lock $t = $this->getLevel()->getTile($this); //$brewingStand = false; if ($t instanceof TileBrewingStand) { $brewingStand = $t; } else { $nbt = new CompoundTag("", [new ListTag("Items", []), new StringTag("id", Tile::BREWING_STAND), new IntTag("x", $this->x), new IntTag("y", $this->y), new IntTag("z", $this->z)]); $nbt->Items->setTagType(NBT::TAG_Compound); $brewingStand = Tile::createTile(Tile::BREWING_STAND, $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt); } $player->addWindow($brewingStand->getInventory()); } 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) { $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 ($player->isCreative()) { return true; } $player->addWindow($furnace->getInventory()); } return true; }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { if ($face !== 0) { $this->meta = $face; if ($face === 1) { $rot = floor($player->yaw * 16 / 360 + 0.5) & 0xf; } else { $rot = $face; } $this->getLevel()->setBlock($block, $this, true); $nbt = new CompoundTag("", [new StringTag("id", Tile::SKULL), new ByteTag("SkullType", $item->getDamage()), new ByteTag("Rot", $rot), new IntTag("x", (int) $this->x), new IntTag("y", (int) $this->y), new IntTag("z", (int) $this->z)]); if ($item->hasCustomName()) { $nbt->CustomName = new StringTag("CustomName", $item->getCustomName()); } /** @var Spawnable $tile */ Tile::createTile("Skull", $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) { $t = $this->getLevel()->getTile($this); $hopper = null; if ($t instanceof HopperTile) { $hopper = $t; } else { $nbt = new CompoundTag("", [new ListTag("Items", []), new StringTag("id", Tile::HOPPER), new IntTag("x", $this->x), new IntTag("y", $this->y), new IntTag("z", $this->z)]); $nbt->Items->setTagType(NBT::TAG_Compound); $hopper = Tile::createTile(Tile::HOPPER, $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt); } if (isset($hopper->namedtag->Lock) and $hopper->namedtag->Lock instanceof StringTag) { if ($hopper->namedtag->Lock->getValue() !== $item->getCustomName()) { return true; } } $player->addWindow($hopper->getInventory()); } return true; }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { if ($player instanceof Player) { $pitch = $player->getPitch(); if (abs($pitch) >= 45) { if ($pitch < 0) { $f = 0; } else { $f = 1; } } else { $f = $player->getDirection() + 2; } } else { $f = 0; } $faces = [0 => 0, 1 => 1, 2 => 5, 3 => 3, 4 => 4, 5 => 2]; $this->meta = $faces[$f]; $this->getLevel()->setBlock($block, $this, true, true); $nbt = new CompoundTag("", [new StringTag("id", Tile::PISTON), new IntTag("x", $this->x), new IntTag("y", $this->y), new IntTag("z", $this->z), new IntTag("blockData", 0), new IntTag("blockId", Item::PISTON_HEAD), new ByteTag("extending", 0), new IntTag("facing", $faces[$f]), new FloatTag("progress", 0.0)]); $tile = Tile::createTile("Piston", $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) { if ($face > 1) { $faces = [2 => 3, 3 => 2, 4 => 1, 5 => 4]; $itemTag = NBT::putItemHelper(Item::get(Item::AIR)); $itemTag->setName("Item"); $nbt = new CompoundTag("", [new StringTag("id", MainClass::TILE_ITEM_FRAME), new IntTag("x", $block->x), new IntTag("y", $block->y), new IntTag("z", $block->z), new CompoundTag("Item", $itemTag->getValue()), new FloatTag("ItemDropChance", 1.0), new ByteTag("ItemRotation", 0)]); if ($item->hasCustomBlockData()) { foreach ($item->getCustomBlockData() as $key => $value) { //Reformat: support "Item" tag by give command if ($key === "Item" and $value instanceof CompoundTag) { $value = NBT::putItemHelper(NBT::getItemHelper($value)); $value->setName("Item"); } $nbt->{$key} = $value; } } //var_dump($nbt);//debug Tile::createTile("ItemFrame", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt); $this->getLevel()->setBlock($block, Block::get(MainClass::BLOCK_ITEM_FRAME, $faces[$face]), true, true); return true; } return false; }
/** * @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()]); }
/** * @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); }
/** * @param Tile $tile * * @throws \RuntimeException */ public function removeTile(Tile $tile) { if ($tile->getLevel() !== $this) { throw new \RuntimeException("Invalid Tile level"); } if ($this->isChunkLoaded($tile->chunk->getX(), $tile->chunk->getZ())) { $this->getChunkAt($tile->chunk->getX(), $tile->chunk->getZ(), true)->removeTile($tile); } unset($this->tiles[$tile->getID()]); }
private function registerTiles() { Tile::registerTile(Chest::class); Tile::registerTile(Furnace::class); Tile::registerTile(Sign::class); Tile::registerTile(Skull::class); Tile::registerTile(BrewingStand::class); Tile::registerTile(EnchantTable::class); }
private function registerTiles() { Tile::registerTile(Chest::class); Tile::registerTile(Furnace::class); Tile::registerTile(Sign::class); }