Fixed XP orbs trying to track players after teleport

closes #2028

@mal0ne-23, you are today's MVP.
This commit is contained in:
Dylan K. Taylor 2018-02-17 10:58:54 +00:00
parent cacd0f5d8f
commit a3fa8adf4a

View File

@ -165,16 +165,16 @@ class ExperienceOrb extends Entity{
}
$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);
}
}
@ -183,6 +183,8 @@ class ExperienceOrb extends Entity{
$this->lookForTargetTime += $tickDiff;
}
$this->setTargetPlayer($currentTarget);
if($currentTarget !== null){
$vector = $currentTarget->subtract($this)->add(0, $currentTarget->getEyeHeight() / 2, 0)->divide(self::MAX_TARGET_DISTANCE);