Пример #1
0
 public function getDrops(Item $item)
 {
     if ($item->isPickaxe() >= Tool::TIER_DIAMOND) {
         return [[Item::OBSIDIAN, 0, 1]];
     }
     return [];
 }
Пример #2
0
 public function getDrops(Item $item)
 {
     if ($item->isPickaxe() >= Tool::TIER_STONE) {
         return [[Item::IRON_BLOCK, 0, 1]];
     }
     return [];
 }
Пример #3
0
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     $dispenser = null;
     if ($player instanceof Player) {
         $pitch = $player->getPitch();
         if (abs($pitch) >= 45) {
             if ($pitch < 0) {
                 $f = 4;
             } else {
                 $f = 5;
             }
         } else {
             $f = $player->getDirection();
         }
     } else {
         $f = 0;
     }
     $faces = [3 => 3, 0 => 4, 2 => 5, 1 => 2, 4 => 0, 5 => 1];
     $this->meta = $faces[$f];
     $this->getLevel()->setBlock($block, $this, true, true);
     $nbt = new CompoundTag("", [new ListTag("Items", []), new StringTag("id", Tile::DISPENSER), new IntTag("x", $this->x), new IntTag("y", $this->y), new IntTag("z", $this->z)]);
     $nbt->Items->setTagType(NBT::TAG_Compound);
     if ($item->hasCustomName()) {
         $nbt->CustomName = new StringTag("CustomName", $item->getCustomName());
     }
     if ($item->hasCustomBlockData()) {
         foreach ($item->getCustomBlockData() as $key => $v) {
             $nbt->{$key} = $v;
         }
     }
     Tile::createTile(Tile::DISPENSER, $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
     return true;
 }
Пример #4
0
 public function getDrops(Item $item)
 {
     if ($item->isPickaxe() >= Tool::TIER_STONE) {
         return [[Item::DYE, 4, mt_rand(4, 8)]];
     }
     return [];
 }
Пример #5
0
 public function onActivate(Item $item, Player $player = null)
 {
     if ($item->getId() === Item::DYE and $item->getDamage() === Dye::BONEMEAL) {
         $grow = false;
         if ($this->getSide(0)->getId() !== self::SUGARCANE_BLOCK && $this->getSide(0, 2)->getId() !== self::SUGARCANE_BLOCK) {
             for ($y = 1; $y < 2; $y++) {
                 $b = $this->getSide(1, $y);
                 if ($b->getId() === self::AIR) {
                     Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($b, new Sugarcane()));
                     if (!$ev->isCancelled()) {
                         $this->getLevel()->setBlock($b, $ev->getNewState(), true);
                         $grow = true;
                     }
                     break;
                 } else {
                     break;
                 }
             }
             $this->meta = 0;
             $this->getLevel()->setBlock($this, $this, true);
         }
         if ($grow && $player->isSurvival()) {
             $item->count--;
         }
         return true;
     }
     return false;
 }
Пример #6
0
 public function getDrops(Item $item)
 {
     if ($item->isPickaxe() >= Tool::TIER_IRON) {
         return [[Item::EMERALD_BLOCK, 0, 1]];
     }
     return [];
 }
 public function onActivate(Item $item, Player $player = null)
 {
     $tile = $this->getLevel()->getTile($this);
     if ($tile instanceof FlowerPot) {
         if ($tile->getFlowerPotItem() === Item::AIR) {
             switch ($item->getId()) {
                 case Item::TALL_GRASS:
                     if ($item->getDamage() === 1) {
                         break;
                     }
                 case Item::SAPLING:
                 case Item::DEAD_BUSH:
                 case Item::DANDELION:
                 case Item::RED_FLOWER:
                 case Item::BROWN_MUSHROOM:
                 case Item::RED_MUSHROOM:
                 case Item::CACTUS:
                     $tile->setFlowerPotData($item->getId(), $item->getDamage());
                     if ($player->isSurvival()) {
                         //$item->setCount($item->getCount() - 1);
                         $item->count--;
                     }
                     return true;
                     break;
             }
         }
     }
     return false;
 }
Пример #8
0
 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;
 }
Пример #9
0
 public function getDrops(Item $item)
 {
     if ($item->isPickaxe() >= 1) {
         return [[Item::SLAB, 0, 2]];
     }
     return [];
 }
Пример #10
0
 /**
  * @param string $name
  * @param array|Item[] $items
  */
 public function __construct($name, array $items)
 {
     $this->name = $name;
     foreach ($items as $i) {
         if (!$i instanceof Item) {
             $i = explode(" ", $i);
             if (count($i) > 1) {
                 $amount = $i[1];
                 unset($i[1]);
             } else {
                 $amount = 1;
             }
             $i = explode(":", $i[0]);
             if (count($i) > 1) {
                 $id = $i[0];
                 $meta = $i[1];
             } else {
                 $id = $i[0];
                 $meta = 0;
             }
             $i = new Item($id, $meta, $amount);
         }
         $this->items[$i->getId()] = $i;
     }
 }
Пример #11
0
 public function getDrops(Item $item)
 {
     if ($item->isPickaxe() >= Tool::TIER_WOODEN) {
         return [[Item::REDSTONE_BLOCK, 0, 1]];
     }
     return [];
 }
Пример #12
0
 public function getDrops(Item $item)
 {
     if ($item->isPickaxe() >= Tool::TIER_IRON) {
         return [[Item::REDSTONE_DUST, 0, mt_rand(4, 5)]];
     }
     return [];
 }
Пример #13
0
 protected function initEntity()
 {
     parent::initEntity();
     $this->setMaxHealth(5);
     $this->setHealth($this->namedtag["Health"]);
     if (isset($this->namedtag->Age)) {
         $this->age = $this->namedtag["Age"];
     }
     if (isset($this->namedtag->PickupDelay)) {
         $this->pickupDelay = $this->namedtag["PickupDelay"];
     }
     if (isset($this->namedtag->Owner)) {
         $this->owner = $this->namedtag["Owner"];
     }
     if (isset($this->namedtag->Thrower)) {
         $this->thrower = $this->namedtag["Thrower"];
     }
     if (!isset($this->namedtag->Item)) {
         $this->close();
         return;
     }
     $this->item = NBT::getItemHelper($this->namedtag->Item);
     if ($this->item->getId() <= 0) {
         $this->close();
         return;
     }
     $this->server->getPluginManager()->callEvent(new ItemSpawnEvent($this));
 }
Пример #14
0
 public function getDrops(Item $item)
 {
     if ($item->isPickaxe() >= Tool::TIER_WOODEN) {
         return [[Item::QUARTZ, 0, 1]];
     }
     return [];
 }
Пример #15
0
 public function getDrops(Item $item)
 {
     if ($item->isPickaxe() >= Tool::TIER_WOODEN) {
         return [[Item::SANDSTONE, $this->meta & 0x3, 1]];
     }
     return [];
 }
Пример #16
0
 public function getDrops(Item $item)
 {
     if ($item->isShovel() !== false) {
         return [[Item::SNOWBALL, 0, 1]];
     }
     return [];
 }
Пример #17
0
 public function getDrops(Item $item)
 {
     if ($item->isPickaxe() >= Tool::TIER_IRON) {
         return [[Item::DIAMOND, 0, 1]];
     }
     return [];
 }
 public function getDrops(Item $item)
 {
     if ($item->isPickaxe()) {
         return [[$this->id, 0, 1]];
     }
     return [];
 }
Пример #19
0
 public function onActivate(Item $item, Player $player = null)
 {
     if ($item->getId() === Item::DYE and $item->getDamage() === 0xf) {
         //Bonemeal
         if ($this->getSide(0)->getId() !== self::SUGARCANE_BLOCK) {
             for ($y = 1; $y < 3; ++$y) {
                 $b = $this->getLevel()->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
                 if ($b->getId() === self::AIR) {
                     Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($b, new Sugarcane()));
                     if (!$ev->isCancelled()) {
                         $this->getLevel()->setBlock($b, $ev->getNewState(), true);
                     }
                     break;
                 }
             }
             $this->meta = 0;
             $this->getLevel()->setBlock($this, $this, true);
         }
         if (($player->gamemode & 0x1) === 0) {
             $item->count--;
         }
         return true;
     }
     return false;
 }
Пример #20
0
 public function getDrops(Item $item)
 {
     if ($item->isSword()) {
         return [[Item::STRING, 0, 1]];
     }
     return [];
 }
Пример #21
0
 public function getDrops(Item $item)
 {
     if ($item->isPickaxe() >= Tool::TIER_WOODEN) {
         return [[$this->id, $this->meta, 1]];
     }
     return [];
 }
Пример #22
0
 public function getDrops(Item $item)
 {
     if ($item->isPickaxe() >= Tool::TIER_WOODEN) {
         return [[$this->getDamage() === 0 ? Item::COBBLESTONE : Item::STONE, $this->getDamage(), 1]];
     }
     return [];
 }
Пример #23
0
 public function getDrops(Item $item)
 {
     if ($item->isPickaxe() >= Tool::TIER_WOODEN) {
         return [[Item::NETHER_BRICKS, 0, 1]];
     } else {
         return [];
     }
 }
Пример #24
0
 public function getDrops(Item $item)
 {
     if ($item->isPickaxe() >= 1) {
         return [[Item::IRON_BARS, 0, 1]];
     } else {
         return [];
     }
 }
Пример #25
0
 public function getDrops(Item $item)
 {
     if ($item->isPickaxe() >= Tool::TIER_WOODEN) {
         return [[Item::MOSS_STONE, $this->meta, 1]];
     } else {
         return [];
     }
 }
Пример #26
0
 public function getDrops(Item $item) : array
 {
     if ($item->isPickaxe() >= 1) {
         return [[Item::SLAB, $this->meta & 0x7, 2]];
     } else {
         return [];
     }
 }
Пример #27
0
 public function getDrops(Item $item)
 {
     if ($item->isPickaxe() >= 1) {
         return [[Item::QUARTZ_BLOCK, $this->meta & 0x3, 1]];
     } else {
         return [];
     }
 }
 public function getDrops(Item $item) : array
 {
     if ($item->isPickaxe() >= 1) {
         return [[Item::REDSTONE_BLOCK, 0, 1]];
     } else {
         return [];
     }
 }
Пример #29
0
 public function getDrops(Item $item)
 {
     if ($item->isPickaxe() >= Tool::TIER_WOODEN) {
         return [[Item::COAL_BLOCK, 0, 1]];
     } else {
         return [];
     }
 }
Пример #30
-1
 public function setRPGItem(Item $item, $name, $desc, $class)
 {
     $classData = self::$ITEM_CLASS[$class];
     $item->setCustomName($classData["COLOR"] . ToAruPG::getTranslation($classData["TID"]) . $name);
     $item->getNamedTag()->desc = new String("desc", $desc);
     return $item;
 }