コード例 #1
0
ファイル: Cake.php プロジェクト: ianju/PocketMine-MP
 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;
 }
コード例 #2
0
ファイル: Cake.php プロジェクト: xHFx/ImagicalMine
 public function onActivate(Item $item, Player $player = null)
 {
     if ($player instanceof Player and $player->getHealth() < $player->getMaxHealth()) {
         ++$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 getHealthStatus(Player $player)
 {
     $config = $this->getConfig()->getAll();
     $symbol = $config["Symbol"];
     $currenthealth = $player->getHealth();
     $usedhealth = $player->getMaxHealth() - $player->getHealth();
     $healthstatus = $config["Health-Color"] . str_repeat($symbol, $currenthealth / 2) . TextFormat::RESET . $config["Used-Health-Color"] . str_repeat($symbol, $usedhealth / 2);
     return $healthstatus;
 }