mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-11 04:17:48 +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;
|
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(){
|
public function checkNetwork(){
|
||||||
if(!$this->isOnline()){
|
if(!$this->isOnline()){
|
||||||
return;
|
return;
|
||||||
|
@ -374,12 +374,18 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
|||||||
public function entityBaseTick($tickDiff = 1){
|
public function entityBaseTick($tickDiff = 1){
|
||||||
$hasUpdate = parent::entityBaseTick($tickDiff);
|
$hasUpdate = parent::entityBaseTick($tickDiff);
|
||||||
|
|
||||||
|
$this->doFoodTick($tickDiff);
|
||||||
|
|
||||||
|
return $hasUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function doFoodTick(int $tickDiff = 1){
|
||||||
if($this->isAlive()){
|
if($this->isAlive()){
|
||||||
$food = $this->getFood();
|
$food = $this->getFood();
|
||||||
$health = $this->getHealth();
|
$health = $this->getHealth();
|
||||||
$difficulty = $this->server->getDifficulty();
|
$difficulty = $this->server->getDifficulty();
|
||||||
|
|
||||||
$this->foodTickTimer++;
|
$this->foodTickTimer += $tickDiff;
|
||||||
if($this->foodTickTimer >= 80){
|
if($this->foodTickTimer >= 80){
|
||||||
$this->foodTickTimer = 0;
|
$this->foodTickTimer = 0;
|
||||||
}
|
}
|
||||||
@ -412,8 +418,6 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $hasUpdate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user