diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index b5e461731..27f71bef3 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -1706,6 +1706,20 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade return true; } + public function doFoodTick(int $tickDiff = 1){ + if($this->isSurvival()){ + parent::doFoodTick($tickDiff); + } + } + + public function exhaust(float $amount, int $cause = PlayerExhaustEvent::CAUSE_CUSTOM) : float{ + if($this->isSurvival()){ + return parent::exhaust($amount, $cause); + } + + return 0.0; + } + public function checkNetwork(){ if(!$this->isOnline()){ return; diff --git a/src/pocketmine/entity/Human.php b/src/pocketmine/entity/Human.php index 3ff95d79c..9797ead87 100644 --- a/src/pocketmine/entity/Human.php +++ b/src/pocketmine/entity/Human.php @@ -374,12 +374,18 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ public function entityBaseTick($tickDiff = 1){ $hasUpdate = parent::entityBaseTick($tickDiff); + $this->doFoodTick($tickDiff); + + return $hasUpdate; + } + + public function doFoodTick(int $tickDiff = 1){ if($this->isAlive()){ $food = $this->getFood(); $health = $this->getHealth(); $difficulty = $this->server->getDifficulty(); - $this->foodTickTimer++; + $this->foodTickTimer += $tickDiff; if($this->foodTickTimer >= 80){ $this->foodTickTimer = 0; } @@ -412,8 +418,6 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ } } } - - return $hasUpdate; } public function getName(){