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) <= 0.1 * 100) { // chance, that a fish bites $this->attractTimer = mt_rand(5, 10) * 20; // random delay when a fish bites (5-10 seconds) } else { $this->attractFish(); $this->attractTimer--; } $this->timings->stopTiming(); return $hasUpdate; }
public function onUpdate($currentTick) { if ($this->closed) { return false; } $this->timings->startTiming(); $hasUpdate = parent::onUpdate($currentTick); if ($this->age > 1200 or $this->isCollided) { $this->kill(); $hasUpdate = true; } $this->timings->stopTiming(); return $hasUpdate; }
public function onUpdate($currentTick) { if ($this->closed) { return false; } $this->timings->startTiming(); $hasUpdate = parent::onUpdate($currentTick); if (!$this->hadCollision and $this->isCritical) { $this->level->addParticle(new CriticalParticle($this->add($this->width / 2 + mt_rand(-100, 100) / 500, $this->height / 2 + mt_rand(-100, 100) / 500, $this->width / 2 + mt_rand(-100, 100) / 500))); } elseif ($this->onGround) { $this->isCritical = false; } if ($this->age > 1200) { $this->kill(); $hasUpdate = true; } $this->timings->stopTiming(); return $hasUpdate; }
public function onUpdate($currentTick) { if ($this->closed) { return false; } $this->timings->startTiming(); $hasUpdate = parent::onUpdate($currentTick); if ($this->age > 1200 or $this->isCollided) { $this->kill(); $this->close(); $hasUpdate = true; } if ($this->onGround) { $this->kill(); $this->close(); $this->getLevel()->spawnExperienceOrb($this->add(0, 1, 0), mt_rand(3, 11)); } $this->timings->stopTiming(); return $hasUpdate; }