Merge branch 'legacy/alpha11'

This commit is contained in:
Dylan K. Taylor 2018-02-17 10:59:19 +00:00
commit 3f41628bf3

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);