mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
Food and exhaustion should not apply in creative, close #860
This commit is contained in:
parent
0e7f364a41
commit
d682fdfdf0
@ -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;
|
||||
|
@ -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(){
|
||||
|
Loading…
x
Reference in New Issue
Block a user