当前位置: 首页>>代码示例>>PHP>>正文


PHP Player::getHealth方法代码示例

本文整理汇总了PHP中pocketmine\Player::getHealth方法的典型用法代码示例。如果您正苦于以下问题:PHP Player::getHealth方法的具体用法?PHP Player::getHealth怎么用?PHP Player::getHealth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pocketmine\Player的用法示例。


在下文中一共展示了Player::getHealth方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onActivate

 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;
 }
开发者ID:ianju,项目名称:PocketMine-MP,代码行数:11,代码来源:Cake.php

示例2: onActivate

 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;
 }
开发者ID:boybook,项目名称:PocketMine-MP,代码行数:14,代码来源:Cake.php

示例3: onActivate

 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;
 }
开发者ID:Edwardthedog2,项目名称:Steadfast2,代码行数:15,代码来源:Cake.php

示例4: onActivate

 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;
 }
开发者ID:rryy,项目名称:PocketMine-MP,代码行数:17,代码来源:Cake.php

示例5: getHealthStatus

 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;
 }
开发者ID:Pocket-GAD,项目名称:PocketMine-MP-Plugins,代码行数:9,代码来源:Main.php


注:本文中的pocketmine\Player::getHealth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。