Пример #1
0
 public function onActivate(Item $item, Player $player = null)
 {
     if ($player instanceof Player and $player->getHealth() < 20) {
         ++$this->meta;
         $player->heal(3, "cake");
         if ($this->meta >= 0x6) {
             $this->getLevel()->setBlock($this, new Air(), true);
         } else {
             $this->getLevel()->setBlock($this, $this, true);
         }
         return true;
     }
     return false;
 }
Пример #2
0
 public function onActivate(Item $item, Player $player = \null)
 {
     if ($player instanceof Player and $player->getHealth() < 20) {
         ++$this->meta;
         $ev = new EntityRegainHealthEvent($player, 3, EntityRegainHealthEvent::CAUSE_EATING);
         $player->heal($ev->getAmount(), $ev);
         if ($this->meta >= 0x6) {
             $this->getLevel()->setBlock($this, new Air(), \true);
         } else {
             $this->getLevel()->setBlock($this, $this, \true);
         }
         return \true;
     }
     return \false;
 }
Пример #3
0
 public function onActivate(Item $item, Player $player = null)
 {
     if ($player instanceof Player and $player->getHealth() < 20) {
         ++$this->meta;
         Server::getInstance()->getPluginManager()->callEvent($ev = new EntityRegainHealthEvent($player, 3, EntityRegainHealthEvent::CAUSE_EATING));
         if (!$ev->isCancelled()) {
             $player->heal($ev->getAmount(), $ev);
         }
         if ($this->meta >= 0x6) {
             $this->getLevel()->setBlock($this, new Air(), true);
         } else {
             $this->getLevel()->setBlock($this, $this, true);
         }
         return true;
     }
     return false;
 }