pocketmine\entity\ExperienceOrb::onUpdate PHP Метод

onUpdate() публичный Метод

public onUpdate ( $currentTick )
    public function onUpdate($currentTick)
    {
        if ($this->closed) {
            return false;
        }
        $tickDiff = $currentTick - $this->lastUpdate;
        $this->lastUpdate = $currentTick;
        $this->timings->startTiming();
        $hasUpdate = $this->entityBaseTick($tickDiff);
        $this->age++;
        if ($this->age > 7000) {
            $this->timings->stopTiming();
            $this->close();
            return true;
        }
        if (!$this->onGround) {
            $this->motionY -= $this->gravity;
        }
        $Target = $this->FetchNearbyPlayer($this->followrange);
        if ($Target instanceof Player) {
            $moveSpeed = 0.5;
            $motX = ($Target->getX() - $this->x) / 8;
            $motY = ($Target->getY() - $this->y) / 8;
            $motZ = ($Target->getZ() - $this->z) / 8;
            $motSqrt = sqrt($motX * $motX + $motY * $motY + $motZ * $motZ);
            $motC = 1 - $motSqrt;
            if ($motC > 0) {
                $motC *= $motC;
                $this->motionX = $motX / $motSqrt * $motC * $moveSpeed;
                $this->motionY = $motY / $motSqrt * $motC * $moveSpeed;
                $this->motionZ = $motZ / $motSqrt * $motC * $moveSpeed;
            }
            if ($Target->distance($this) <= $this->pickuprange) {
                $this->timings->stopTiming();
                $this->close();
                if ($this->getExperience() > 0) {
                    $Target->addExp($this->getExperience());
                }
                return true;
            }
        }
        $this->move($this->motionX, $this->motionY, $this->motionZ);
        $this->updateMovement();
        $this->timings->stopTiming();
        return $hasUpdate or !$this->onGround or abs($this->motionX) > 1.0E-5 or abs($this->motionY) > 1.0E-5 or abs($this->motionZ) > 1.0E-5;
    }