Entity: added getEyePos()

This commit is contained in:
Dylan K. Taylor
2019-08-02 17:29:32 +01:00
parent e03f918806
commit 1cd955c216
5 changed files with 8 additions and 4 deletions

View File

@@ -1171,6 +1171,10 @@ abstract class Entity extends Location{
return $this->eyeHeight;
}
public function getEyePos() : Vector3{
return new Vector3($this->x, $this->y + $this->getEyeHeight(), $this->z);
}
public function onCollideWithPlayer(Player $player) : void{
}

View File

@@ -96,7 +96,7 @@ class SplashPotion extends Throwable{
if(!$this->willLinger()){
foreach($this->world->getNearbyEntities($this->boundingBox->expandedCopy(4.125, 2.125, 4.125), $this) as $entity){
if($entity instanceof Living and $entity->isAlive()){
$distanceSquared = $entity->add(0, $entity->getEyeHeight(), 0)->distanceSquared($this);
$distanceSquared = $entity->getEyePos()->distanceSquared($this);
if($distanceSquared > 16){ //4 blocks
continue;
}