mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 16:51:42 +00:00
parent
86eee429bb
commit
ddc9dca8b4
@ -1754,6 +1754,10 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
public function isHungry() : bool{
|
||||
return $this->isSurvival() and parent::isHungry();
|
||||
}
|
||||
|
||||
public function canBreathe() : bool{
|
||||
return $this->isCreative() or parent::canBreathe();
|
||||
}
|
||||
|
@ -208,6 +208,15 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
$this->setFood($amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this Human may consume objects requiring hunger.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isHungry() : bool{
|
||||
return $this->getFood() < $this->getMaxFood();
|
||||
}
|
||||
|
||||
public function getSaturation() : float{
|
||||
return $this->attributeMap->getAttribute(Attribute::SATURATION)->getValue();
|
||||
}
|
||||
@ -282,7 +291,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
|
||||
public function consumeObject(Consumable $consumable) : bool{
|
||||
if($consumable instanceof FoodSource){
|
||||
if($consumable->requiresHunger() and $this->getFood() >= $this->getMaxFood()){
|
||||
if($consumable->requiresHunger() and !$this->isHungry()){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user