public function getDrops(Item $item)
 {
     if ($item->isPickaxe()) {
         return [$this->id, 0, 1];
     }
     return [];
 }
Exemplo n.º 2
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;
 }
Exemplo n.º 3
0
 public function getDrops(Item $item)
 {
     if ($item->isPickaxe() >= Tool::TIER_STONE) {
         return [[Item::DYE, 4, mt_rand(4, 8)]];
     } else {
         return [];
     }
 }
Exemplo n.º 4
0
 public function getDrops(Item $item)
 {
     if ($item->isPickaxe() >= Tool::TIER_DIAMOND) {
         return [[Item::OBSIDIAN, 0, 1]];
     } else {
         return [];
     }
 }
Exemplo n.º 5
0
 public function getDrops(Item $item)
 {
     if ($item->isPickaxe() >= Tool::TIER_WOODEN) {
         return [[Item::SLAB, $this->meta & 0x7, 2]];
     } else {
         return [];
     }
 }
Exemplo n.º 6
0
 public function getDrops(Item $item)
 {
     if ($item->isPickaxe() >= Tool::TIER_WOODEN) {
         return [[$this->id, $this->meta, 1]];
     } else {
         return [];
     }
 }
Exemplo n.º 7
0
 public function getDrops(Item $item)
 {
     if ($item->isPickaxe() >= Tool::TIER_WOODEN) {
         return [[Item::QUARTZ_BLOCK, $this->meta & 0x3, 1]];
     } else {
         return [];
     }
 }
Exemplo n.º 8
0
 public function getDrops(Item $item)
 {
     if ($item->isPickaxe() >= Tool::TIER_WOODEN) {
         return [[Item::STONE_BRICKS, $this->meta & 0x3, 1]];
     } else {
         return [];
     }
 }
Exemplo n.º 9
0
 public function getDrops(Item $item)
 {
     if ($item->isShovel() !== false) {
         return [[Item::SNOWBALL, 0, $this->getDamage() + 1]];
         // Amount in PC version is based on the number of layers
     }
     return [];
 }
Exemplo n.º 10
0
 public function getDrops(Item $item)
 {
     if ($item->isPickaxe() >= Tool::TIER_STONE) {
         return [[Item::LAPIS_BLOCK, 0, 1]];
     } else {
         return [];
     }
 }
Exemplo n.º 11
0
 public function getDrops(Item $item)
 {
     $drops = [];
     if ($item->isPickaxe() >= Tool::TIER_WOODEN) {
         $drops[] = [Item::BREWING_STAND, 0, 1];
     }
     return $drops;
 }
Exemplo n.º 12
0
 public function getDrops(Item $item)
 {
     if ($item->isPickaxe() >= Tool::TIER_WOODEN) {
         return [[$this->getDamage() === 0 ? Item::COBBLESTONE : Item::STONE, $this->getDamage(), 1]];
     } else {
         return [];
     }
 }
Exemplo n.º 13
0
 public function getDrops(Item $item)
 {
     if ($item->isPickaxe() >= Tool::TIER_IRON) {
         return [[Item::GOLD_ORE, 0, 1]];
     } else {
         return [];
     }
 }
Exemplo n.º 14
0
 public function getDrops(Item $item)
 {
     if ($item->isPickaxe() >= Tool::TIER_GOLD) {
         return [[Item::REDSTONE_DUST, 0, mt_rand(4, 5)]];
     } else {
         return [];
     }
 }
Exemplo n.º 15
0
 public function getDrops(Item $item)
 {
     if ($item->isPickaxe() >= Tool::TIER_WOODEN) {
         return [[Item::COAL, 0, 1]];
     } else {
         return [];
     }
 }
Exemplo n.º 16
0
 public function onActivate(Item $item, Player $player = null)
 {
     if ($item->isHoe()) {
         $item->useOn($this);
         $this->getLevel()->setBlock($this, Block::get(Item::FARMLAND, 0), true);
         return true;
     }
     return false;
 }
Exemplo n.º 17
0
 public function getDrops(Item $item)
 {
     if ($item->isShears()) {
         return [$this->id, $this->meta, 1];
     } elseif (mt_rand(0, 15) === 0) {
         return [Item::WHEAT_SEEDS, 0, 1];
     }
     return [];
 }
Exemplo n.º 18
0
 public function onActivate(Item $item, Player $player = null)
 {
     if ($item->getId() === Item::FLINT_STEEL) {
         $item->useOn($this);
         $this->getLevel()->setBlock($this, new Air(), true);
         $mot = (new Random())->nextSignedFloat() * M_PI * 2;
         $tnt = Entity::createEntity("PrimedTNT", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new Compound("", ["Pos" => new Enum("Pos", [new Double("", $this->x + 0.5), new Double("", $this->y), new Double("", $this->z + 0.5)]), "Motion" => new Enum("Motion", [new Double("", -sin($mot) * 0.02), new Double("", 0.2), new Double("", -cos($mot) * 0.02)]), "Rotation" => new Enum("Rotation", [new Float("", 0), new Float("", 0)]), "Fuse" => new Byte("Fuse", 80)]));
         $tnt->spawnToAll();
         return true;
     }
     return false;
 }
Exemplo n.º 19
0
 /**
  * @param Item $item
  *
  * @return $this
  */
 public function removeIngredient(Item $item)
 {
     foreach ($this->ingredients as $index => $ingredient) {
         if ($item->getCount() <= 0) {
             break;
         }
         if ($ingredient->equals($item, $item->getDamage() === null ? false : true, $item->getCompoundTag() === null ? false : true)) {
             unset($this->ingredients[$index]);
             $item->setCount($item->getCount() - 1);
         }
     }
     return $this;
 }
Exemplo n.º 20
0
 public function onActivate(Item $item, Player $player = null)
 {
     if ($item->getId() === Item::DYE and $item->getDamage() === 0xf) {
         //Bonemeal
         //TODO: change log type
         Tree::growTree($this->getLevel(), $this->x, $this->y, $this->z, new Random(mt_rand()), $this->meta & 0x7);
         if (($player->gamemode & 0x1) === 0) {
             $item->count--;
         }
         return true;
     }
     return false;
 }
Exemplo n.º 21
0
 public function __construct($meta = 0, $count = 1)
 {
     if ($meta === self::COCOA_BEANS) {
         $this->block = Block::get(Item::COCOA_POD);
         $this->meta = 1;
     }
     parent::__construct(self::DYE, $meta, $count, $this->getNameByMeta($meta));
 }
Exemplo n.º 22
0
 public function onActivate(Item $item, Player $player = null)
 {
     if ($item->getId() === Item::DYE and $item->getDamage() === 0xf) {
         //Bonemeal
         $block = clone $this;
         $block->meta += mt_rand(2, 5);
         if ($block->meta > 7) {
             $block->meta = 7;
         }
         Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($this, $block));
         if (!$ev->isCancelled()) {
             $this->getLevel()->setBlock($this, $ev->getNewState(), true, true);
         }
         $item->count--;
         return true;
     }
     return false;
 }
Exemplo n.º 23
0
 public function getDrops(Item $item)
 {
     $damage = $this->getDamage();
     if ($item->isPickaxe() >= Tool::TIER_WOODEN) {
         if ($damage >= 0 && $damage <= 3) {
             //Anvil
             return [[$this->id, 0, 1]];
         } elseif ($damage >= 4 && $damage <= 7) {
             //Slightly Anvil
             return [[$this->id, $this->meta & 0x4, 1]];
         } elseif ($damage >= 8 && $damage <= 11) {
             //Very Damaged Anvil
             return [[$this->id, $this->meta & 0x8, 1]];
         }
     } else {
         return [];
     }
 }
Exemplo n.º 24
0
 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;
 }
Exemplo n.º 25
0
 /**
  * This method should not be used by plugins, use the Inventory
  *
  * @param int $index
  *
  * @return Item
  */
 public function getItem($index)
 {
     $i = $this->getSlotIndex($index);
     if ($i < 0) {
         return Item::get(Item::AIR, 0, 0);
     } else {
         return NBT::getItemHelper($this->namedtag->Items[$i]);
     }
 }
Exemplo n.º 26
0
 public function getDrops()
 {
     $drops = [];
     if ($this->getLastDamageCause() === EntityDamageEvent::CAUSE_FIRE) {
         $drops[] = ItemItem::get(ItemItem::COOKED_PORKCHOP, 0, mt_rand(1, 3));
     } else {
         $drops[] = ItemItem::get(ItemItem::RAW_PORKCHOP, 0, mt_rand(1, 3));
     }
     return $drops;
 }
Exemplo n.º 27
0
 public function getResult()
 {
     if ($brew = $this->getHolder()->getServer()->getCraftingManager()->matchBrewingRecipe($this->getIngredient())) {
         $canbrew = $brew instanceof BrewingRecipe;
         if ($canbrew) {
             return $brew->getResult();
         }
     }
     return Item::get(Item::AIR, 0, 1);
 }
Exemplo n.º 28
0
 public function getDrops()
 {
     $drops = [ItemItem::get(ItemItem::FEATHER, 0, mt_rand(0, 2))];
     if ($this->getLastDamageCause() === EntityDamageEvent::CAUSE_FIRE) {
         $drops[] = ItemItem::get(ItemItem::COOKED_CHICKEN, 0, mt_rand(1, 2));
     } else {
         $drops[] = ItemItem::get(ItemItem::RAW_CHICKEN, 0, mt_rand(1, 2));
     }
     return $drops;
 }
Exemplo n.º 29
0
 public function getDrops()
 {
     $drops = [ItemItem::get(ItemItem::LEATHER, 0, mt_rand(0, 2))];
     if ($this->getLastDamageCause() === EntityDamageEvent::CAUSE_FIRE) {
         $drops[] = ItemItem::get(ItemItem::COOKED_BEEF, 0, mt_rand(1, 3));
     } else {
         $drops[] = ItemItem::get(ItemItem::RAW_BEEF, 0, mt_rand(1, 3));
     }
     //TODO Add shearing drop red mushrooms
     return $drops;
 }
Exemplo n.º 30
0
 public function getDrops()
 {
     $drops = [];
     if ($this->lastDamageCause instanceof EntityDamageByEntityEvent and $this->lastDamageCause->getEntity() instanceof Player) {
         $drops = [ItemItem::get(ItemItem::COAL, 0, mt_rand(0, 1)), ItemItem::get(ItemItem::BONE, 0, mt_rand(0, 2))];
     }
     if ($this->lastDamageCause instanceof EntityDamageByEntityEvent and $this->lastDamageCause->getEntity() instanceof ChargedCreeper) {
         $drops = [ItemItem::get(ItemItem::SKULL, 1, 1)];
     }
     return $drops;
 }