mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-23 00:55:57 +00:00
Fix reach distance bugs
This commit is contained in:
parent
765bd5ced7
commit
15b9578245
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user