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