mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-13 23:15:29 +00:00
Fix players regenerating health from food while dead, fixes issue 2 in #23
This commit is contained in:
parent
67940ad6ab
commit
441961b199
@ -347,36 +347,38 @@ 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);
|
||||||
|
|
||||||
$food = $this->getFood();
|
if($this->isAlive()){
|
||||||
$health = $this->getHealth();
|
$food = $this->getFood();
|
||||||
if($food >= 18){
|
$health = $this->getHealth();
|
||||||
$this->foodTickTimer++;
|
if($food >= 18){
|
||||||
if($this->foodTickTimer >= 80 and $health < $this->getMaxHealth()){
|
$this->foodTickTimer++;
|
||||||
$this->heal(1, new EntityRegainHealthEvent($this, 1, EntityRegainHealthEvent::CAUSE_SATURATION));
|
if($this->foodTickTimer >= 80 and $health < $this->getMaxHealth()){
|
||||||
$this->exhaust(3.0, PlayerExhaustEvent::CAUSE_HEALTH_REGEN);
|
$this->heal(1, new EntityRegainHealthEvent($this, 1, EntityRegainHealthEvent::CAUSE_SATURATION));
|
||||||
$this->foodTickTimer = 0;
|
$this->exhaust(3.0, PlayerExhaustEvent::CAUSE_HEALTH_REGEN);
|
||||||
|
$this->foodTickTimer = 0;
|
||||||
|
|
||||||
}
|
|
||||||
}elseif($food === 0){
|
|
||||||
$this->foodTickTimer++;
|
|
||||||
if($this->foodTickTimer >= 80){
|
|
||||||
$diff = $this->server->getDifficulty();
|
|
||||||
$can = false;
|
|
||||||
if($diff === 1){
|
|
||||||
$can = $health > 10;
|
|
||||||
}elseif($diff === 2){
|
|
||||||
$can = $health > 1;
|
|
||||||
}elseif($diff === 3){
|
|
||||||
$can = true;
|
|
||||||
}
|
}
|
||||||
if($can){
|
}elseif($food === 0){
|
||||||
$this->attack(1, new EntityDamageEvent($this, EntityDamageEvent::CAUSE_STARVATION, 1));
|
$this->foodTickTimer++;
|
||||||
|
if($this->foodTickTimer >= 80){
|
||||||
|
$diff = $this->server->getDifficulty();
|
||||||
|
$can = false;
|
||||||
|
if($diff === 1){
|
||||||
|
$can = $health > 10;
|
||||||
|
}elseif($diff === 2){
|
||||||
|
$can = $health > 1;
|
||||||
|
}elseif($diff === 3){
|
||||||
|
$can = true;
|
||||||
|
}
|
||||||
|
if($can){
|
||||||
|
$this->attack(1, new EntityDamageEvent($this, EntityDamageEvent::CAUSE_STARVATION, 1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if($food <= 6){
|
||||||
if($food <= 6){
|
if($this->isSprinting()){
|
||||||
if($this->isSprinting()){
|
$this->setSprinting(false);
|
||||||
$this->setSprinting(false);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user