Skip to content

Commit

Permalink
Fixed XP orbs trying to track players after teleport
Browse files Browse the repository at this point in the history
closes #2028

@mal0ne-23, you are today's MVP.
  • Loading branch information
dktapps committed Feb 17, 2018
1 parent cacd0f5 commit a3fa8ad
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/pocketmine/entity/object/ExperienceOrb.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,16 @@ public function entityBaseTick(int $tickDiff = 1) : bool{
}

$currentTarget = $this->getTargetPlayer();
if($currentTarget !== null and $currentTarget->distanceSquared($this) > self::MAX_TARGET_DISTANCE ** 2){
$currentTarget = null;
}

if($this->lookForTargetTime >= 20){
if($currentTarget === null or $currentTarget->distanceSquared($this) > self::MAX_TARGET_DISTANCE ** 2){
$this->setTargetPlayer(null);

if($currentTarget === null){
$newTarget = $this->level->getNearestEntity($this, self::MAX_TARGET_DISTANCE, Human::class);

if($newTarget instanceof Human and !($newTarget instanceof Player and $newTarget->isSpectator())){
$currentTarget = $newTarget;
$this->setTargetPlayer($currentTarget);
}
}

Expand All @@ -183,6 +183,8 @@ public function entityBaseTick(int $tickDiff = 1) : bool{
$this->lookForTargetTime += $tickDiff;
}

$this->setTargetPlayer($currentTarget);

if($currentTarget !== null){
$vector = $currentTarget->subtract($this)->add(0, $currentTarget->getEyeHeight() / 2, 0)->divide(self::MAX_TARGET_DISTANCE);

Expand Down

0 comments on commit a3fa8ad

Please sign in to comment.