当前位置: 首页>>代码示例>>PHP>>正文


PHP Item::getCount方法代码示例

本文整理汇总了PHP中BukkitPE\item\Item::getCount方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::getCount方法的具体用法?PHP Item::getCount怎么用?PHP Item::getCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BukkitPE\item\Item的用法示例。


在下文中一共展示了Item::getCount方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: putItemHelper

 /**
  * @param Item $item
  * @param int  $slot
  * @return Compound
  */
 public static function putItemHelper(Item $item, $slot = null)
 {
     $tag = new Compound(null, ["id" => new Short("id", $item->getId()), "Count" => new Byte("Count", $item->getCount()), "Damage" => new Short("Damage", $item->getDamage())]);
     if ($slot !== null) {
         $tag->Slot = new Byte("Slot", (int) $slot);
     }
     if ($item->hasCompoundTag()) {
         $tag->tag = clone $item->getNamedTag();
         $tag->tag->setName("tag");
     }
     return $tag;
 }
开发者ID:MunkySkunk,项目名称:BukkitPE,代码行数:17,代码来源:NBT.php

示例2: removeIngredient

 /**
  * @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;
 }
开发者ID:MunkySkunk,项目名称:BukkitPE,代码行数:18,代码来源:ShapelessRecipe.php

示例3: 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

示例4: first

 public function first(Item $item)
 {
     $count = max(1, $item->getCount());
     $checkDamage = $item->getDamage() === null ? false : true;
     $checkTags = $item->getCompoundTag() === null ? false : true;
     foreach ($this->getContents() as $index => $i) {
         if ($item->equals($i, $checkDamage, $checkTags) and $i->getCount() >= $count) {
             return $index;
         }
     }
     return -1;
 }
开发者ID:MunkySkunk,项目名称:BukkitPE,代码行数:12,代码来源:BaseInventory.php

示例5: sort

 public function sort(Item $i1, Item $i2)
 {
     if ($i1->getId() > $i2->getId()) {
         return 1;
     } elseif ($i1->getId() < $i2->getId()) {
         return -1;
     } elseif ($i1->getDamage() > $i2->getDamage()) {
         return 1;
     } elseif ($i1->getDamage() < $i2->getDamage()) {
         return -1;
     } elseif ($i1->getCount() > $i2->getCount()) {
         return 1;
     } elseif ($i1->getCount() < $i2->getCount()) {
         return -1;
     } else {
         return 0;
     }
 }
开发者ID:gitter-badger,项目名称:BukkitPE,代码行数:18,代码来源:CraftingManager.php

示例6: putSlot

 public function putSlot(Item $item)
 {
     if ($item->getId() === 0) {
         $this->putShort(0);
         return;
     }
     $this->putShort($item->getId());
     $this->putByte($item->getCount());
     $this->putShort($item->getDamage() === null ? -1 : $item->getDamage());
     $nbt = $item->getCompoundTag();
     $this->putShort(strlen($nbt));
     $this->put($nbt);
 }
开发者ID:MunkySkunk,项目名称:BukkitPE,代码行数:13,代码来源:BinaryStream.php

示例7: setItem

 public function setItem($index, Item $item)
 {
     if ($index < 0 or $index >= $this->size) {
         return false;
     } elseif ($item->getId() === 0 or $item->getCount() <= 0) {
         return $this->clear($index);
     }
     if ($index >= $this->getSize()) {
         //Armor change
         Server::getInstance()->getPluginManager()->callEvent($ev = new EntityArmorChangeEvent($this->getHolder(), $this->getItem($index), $item, $index));
         if ($ev->isCancelled() and $this->getHolder() instanceof Human) {
             $this->sendArmorSlot($index, $this->getViewers());
             return false;
         }
         $item = $ev->getNewItem();
     } else {
         Server::getInstance()->getPluginManager()->callEvent($ev = new EntityInventoryChangeEvent($this->getHolder(), $this->getItem($index), $item, $index));
         if ($ev->isCancelled()) {
             $this->sendSlot($index, $this->getViewers());
             return false;
         }
         $item = $ev->getNewItem();
     }
     $old = $this->getItem($index);
     $this->slots[$index] = clone $item;
     $this->onSlotChange($index, $old);
     if ($this->getHolder() instanceof Player) {
         if ($this->getHolder()->isSurvival()) {
             $this->sendContents($this->getHolder());
         }
     }
     return true;
 }
开发者ID:MunkySkunk,项目名称:BukkitPE,代码行数:33,代码来源:PlayerInventory.php


注:本文中的BukkitPE\item\Item::getCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。