Пример #1
0
 /**
  * @param Item $item
  *
  * @returns ShapelessRecipe
  *
  * @throws \InvalidArgumentException
  */
 public function addIngredient(Item $item)
 {
     if (count($this->ingredients) >= 9) {
         throw new \InvalidArgumentException("Shapeless recipes cannot have more than 9 ingredients");
     }
     $it = clone $item;
     $it->setCount(1);
     while ($item->getCount() > 0) {
         $this->ingredients[] = clone $it;
         $item->setCount($item->getCount() - 1);
     }
     return $this;
 }
Пример #2
0
 protected function checkFuel(Item $fuel)
 {
     $this->server->getPluginManager()->callEvent($ev = new FurnaceBurnEvent($this, $fuel, $fuel->getFuelTime()));
     if ($ev->isCancelled()) {
         return;
     }
     $this->namedtag->MaxTime = new Short("MaxTime", $ev->getBurnTime());
     $this->namedtag->BurnTime = new Short("BurnTime", $ev->getBurnTime());
     $this->namedtag->BurnTicks = new Short("BurnTicks", 0);
     if ($this->getBlock()->getId() === Item::FURNACE) {
         $this->getLevel()->setBlock($this, Block::get(Item::BURNING_FURNACE, $this->getBlock()->getDamage()), true);
     }
     if ($this->namedtag["BurnTime"] > 0 and $ev->isBurning()) {
         $fuel->setCount($fuel->getCount() - 1);
         if ($fuel->getCount() === 0) {
             $fuel = Item::get(Item::AIR, 0, 0);
         }
         $this->inventory->setFuel($fuel);
     }
 }