mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-14 15:35:31 +00:00
Fixed XP orbs trying to track players after teleport
closes #2028 @mal0ne-23, you are today's MVP.
This commit is contained in:
parent
cacd0f5d8f
commit
a3fa8adf4a
@ -165,16 +165,16 @@ class ExperienceOrb extends Entity{
|
|||||||
}
|
}
|
||||||
|
|
||||||
$currentTarget = $this->getTargetPlayer();
|
$currentTarget = $this->getTargetPlayer();
|
||||||
|
if($currentTarget !== null and $currentTarget->distanceSquared($this) > self::MAX_TARGET_DISTANCE ** 2){
|
||||||
|
$currentTarget = null;
|
||||||
|
}
|
||||||
|
|
||||||
if($this->lookForTargetTime >= 20){
|
if($this->lookForTargetTime >= 20){
|
||||||
if($currentTarget === null or $currentTarget->distanceSquared($this) > self::MAX_TARGET_DISTANCE ** 2){
|
if($currentTarget === null){
|
||||||
$this->setTargetPlayer(null);
|
|
||||||
|
|
||||||
$newTarget = $this->level->getNearestEntity($this, self::MAX_TARGET_DISTANCE, Human::class);
|
$newTarget = $this->level->getNearestEntity($this, self::MAX_TARGET_DISTANCE, Human::class);
|
||||||
|
|
||||||
if($newTarget instanceof Human and !($newTarget instanceof Player and $newTarget->isSpectator())){
|
if($newTarget instanceof Human and !($newTarget instanceof Player and $newTarget->isSpectator())){
|
||||||
$currentTarget = $newTarget;
|
$currentTarget = $newTarget;
|
||||||
$this->setTargetPlayer($currentTarget);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,6 +183,8 @@ class ExperienceOrb extends Entity{
|
|||||||
$this->lookForTargetTime += $tickDiff;
|
$this->lookForTargetTime += $tickDiff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->setTargetPlayer($currentTarget);
|
||||||
|
|
||||||
if($currentTarget !== null){
|
if($currentTarget !== null){
|
||||||
$vector = $currentTarget->subtract($this)->add(0, $currentTarget->getEyeHeight() / 2, 0)->divide(self::MAX_TARGET_DISTANCE);
|
$vector = $currentTarget->subtract($this)->add(0, $currentTarget->getEyeHeight() / 2, 0)->divide(self::MAX_TARGET_DISTANCE);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user