Food and exhaustion should not apply in creative, close #860

This commit is contained in:
Dylan K. Taylor 2017-04-24 13:31:05 +01:00
parent 0e7f364a41
commit d682fdfdf0
2 changed files with 21 additions and 3 deletions

View File

@ -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;

View File

@ -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(){