Ejemplo n.º 1
0
 public function onActivate(Item $item, Player $player = null)
 {
     if ($player instanceof Player and $player->getHealth() < $player->getMaxHealth()) {
         $ev = new EntityEatBlockEvent($player, $this);
         if (!$ev->isCancelled()) {
             $this->getLevel()->setBlock($this, $ev->getResidue());
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 2
0
 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;
 }