public function entityBaseTick($tickDiff = 1)
{
Timings::$timerEntityBaseTick->startTiming();
if (!$this->isCreated()) {
return false;
}
$hasUpdate = Entity::entityBaseTick($tickDiff);
if ($this->attackTime > 0) {
$this->attackTime -= $tickDiff;
}
if ($this->isInsideOfSolid()) {
$hasUpdate = true;
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_SUFFOCATION, 1);
$this->attack($ev->getFinalDamage(), $ev);
}
if ($this instanceof Enderman) {
if ($this->level->getBlock(new Vector3(Math::floorFloat($this->x), (int) $this->y, Math::floorFloat($this->z))) instanceof Water) {
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_DROWNING, 2);
$this->attack($ev->getFinalDamage(), $ev);
$this->move(mt_rand(-20, 20), mt_rand(-20, 20), mt_rand(-20, 20));
}
} else {
if (!$this->hasEffect(Effect::WATER_BREATHING) && $this->isInsideOfWater()) {
$hasUpdate = true;
$airTicks = $this->getDataProperty(self::DATA_AIR) - $tickDiff;
if ($airTicks <= -20) {
$airTicks = 0;
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_DROWNING, 2);
$this->attack($ev->getFinalDamage(), $ev);
}
$this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, $airTicks);
} else {
$this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, 300);
}
}
Timings::$timerEntityBaseTick->stopTiming();
return $hasUpdate;
}