public function onUpdate($currentTick)
{
if ($this->closed) {
return false;
}
$this->timings->startTiming();
$hasUpdate = parent::onUpdate($currentTick);
if ($this->isCollidedVertically && $this->isInsideOfWater()) {
$this->motionX = 0;
$this->motionY += 0.01;
$this->motionZ = 0;
$this->motionChanged = true;
$hasUpdate = true;
} elseif ($this->isCollided && $this->keepMovement === true) {
$this->motionX = 0;
$this->motionY = 0;
$this->motionZ = 0;
$this->motionChanged = true;
$this->keepMovement = false;
$hasUpdate = true;
}
if ($this->attractTimer === 0 && mt_rand(0, 100) <= 30) {
// chance, that a fish bites
$this->coughtTimer = mt_rand(5, 10) * 20;
// random delay to catch fish
$this->attractTimer = mt_rand(30, 100) * 20;
// reset timer
$this->attractFish();
if ($this->shootingEntity instanceof Player) {
$this->shootingEntity->sendTip("A fish bites!");
}
} elseif ($this->attractTimer > 0) {
$this->attractTimer--;
}
if ($this->coughtTimer > 0) {
$this->coughtTimer--;
$this->fishBites();
}
$this->timings->stopTiming();
return $hasUpdate;
}