public function entityBaseTick($tickDiff = 1, $EnchantL = 0) { if ($this->getInventory() instanceof PlayerInventory) { $EnchantL = $this->getInventory()->getHelmet()->getEnchantmentLevel(Enchantment::TYPE_WATER_BREATHING); } $hasUpdate = parent::entityBaseTick($tickDiff, $EnchantL); if ($this->server->foodEnabled) { $food = $this->getFood(); $health = $this->getHealth(); if ($food >= 18) { $this->foodTickTimer++; if ($this->foodTickTimer >= 80 and $health < $this->getMaxHealth()) { $this->heal(1, new EntityRegainHealthEvent($this, 1, EntityRegainHealthEvent::CAUSE_SATURATION)); $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) { $this->attack(1, new EntityDamageEvent($this, EntityDamageEvent::CAUSE_STARVATION, 1)); } } } if ($food <= 6) { if ($this->isSprinting()) { $this->setSprinting(false); } } } return $hasUpdate; }
public function entityBaseTick($tickDiff = 1) { $hasUpdate = parent::entityBaseTick($tickDiff); $food = $this->getFood(); $health = $this->getHealth(); if ($this instanceof Player && $this->isSurvival() || $this instanceof Human) { if ($food >= 18) { $this->foodTickTimer++; if ($this->foodTickTimer >= 80 and $health < $this->getMaxHealth()) { $this->heal(1, new EntityRegainHealthEvent($this, 1, EntityRegainHealthEvent::CAUSE_SATURATION)); $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) { $this->attack(1, new EntityDamageEvent($this, EntityDamageEvent::CAUSE_STARVATION, 1)); } } } if ($food <= 6) { if ($this->isSprinting()) { $this->setSprinting(false); } } } return $hasUpdate; }
public function entityBaseTick($tickDiff = 1) { Timings::$timerEntityBaseTick->startTiming(); $hasUpdate = parent::entityBaseTick($tickDiff); if ($this->isInsideOfSolid()) { $hasUpdate = true; $ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_SUFFOCATION, 1); $this->attack($ev->getFinalDamage(), $ev); } if ($this->moveTime > 0) { $this->moveTime -= $tickDiff; } if ($this->attackTime > 0) { $this->attackTime -= $tickDiff; } Timings::$timerEntityBaseTick->startTiming(); return $hasUpdate; }