Fix reach distance bugs

This commit is contained in:
dktapps 2016-08-25 10:42:14 +01:00 committed by Dylan K. Taylor
parent 765bd5ced7
commit 15b9578245

View File

@ -1552,12 +1552,13 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
}
public function canInteract(Vector3 $pos, $maxDistance, $maxDiff = 0.5){
if($this->distanceSquared($pos) > $maxDistance ** 2){
$eyePos = $this->getPosition()->add(0, $this->getEyeHeight(), 0);
if($eyePos->distanceSquared($pos) > $maxDistance ** 2){
return false;
}
$dV = $this->getDirectionPlane();
$dot = $dV->dot(new Vector2($this->x, $this->z));
$dot = $dV->dot(new Vector2($eyePos->x, $eyePos->z));
$dot1 = $dV->dot(new Vector2($pos->x, $pos->z));
return ($dot1 - $dot) >= -$maxDiff;
}