本文整理匯總了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;
}
示例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);
}
}