本文整理汇总了PHP中pocketmine\Player::getFood方法的典型用法代码示例。如果您正苦于以下问题:PHP Player::getFood方法的具体用法?PHP Player::getFood怎么用?PHP Player::getFood使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\Player
的用法示例。
在下文中一共展示了Player::getFood方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onActivate
public function onActivate(Item $item, Player $player = null)
{
if ($player instanceof Player and $player->getFood() < 20) {
++$this->meta;
$player->setFood($player->getFood() + 2);
if ($this->meta >= 0x6) {
$this->getLevel()->setBlock($this, new Air(), true);
} else {
$this->getLevel()->setBlock($this, $this, true);
}
return true;
}
return false;
}
示例2: onActivate
public function onActivate(Item $item, Player $player = null)
{
if ($player instanceof Player and $player->getFood() < $player->getMaxFood()) {
$ev = new EntityEatBlockEvent($player, $this);
if (!$ev->isCancelled()) {
$this->getLevel()->setBlock($this, $ev->getResidue());
return true;
}
}
return false;
}
示例3: onActivate
public function onActivate(Item $item, Player $player = null)
{
if ($player instanceof Player and $player->getFood() < 20) {
$player->getServer()->getPluginManager()->callEvent($ev = new EntityEatBlockEvent($player, $this));
if (!$ev->isCancelled()) {
$player->setFood($player->getFood() + 2);
++$this->meta;
if ($this->meta >= 0x6) {
$this->getLevel()->setBlock($this, new Air(), true);
} else {
$this->getLevel()->setBlock($this, $this, true);
}
return true;
}
}
return false;
}