當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Item::setCount方法代碼示例

本文整理匯總了PHP中BukkitPE\item\Item::setCount方法的典型用法代碼示例。如果您正苦於以下問題:PHP Item::setCount方法的具體用法?PHP Item::setCount怎麽用?PHP Item::setCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在BukkitPE\item\Item的用法示例。


在下文中一共展示了Item::setCount方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: addIngredient

 /**
  * @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;
 }
開發者ID:MunkySkunk,項目名稱:BukkitPE,代碼行數:20,代碼來源:ShapelessRecipe.php

示例2: checkFuel

 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);
     }
 }
開發者ID:gitter-badger,項目名稱:BukkitPE,代碼行數:20,代碼來源:Furnace.php


注:本文中的BukkitPE\item\Item::setCount方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。