diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 474f397d0..c113d27cb 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -1743,20 +1743,19 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ * * @param Vector3 $pos * @param $maxDistance - * @param float $maxDiff default 0.71 (approximately sqrt(2) / 2, half of the diagonal width of a block) * * @return bool */ - public function canInteract(Vector3 $pos, $maxDistance, float $maxDiff = 0.71) : bool{ + public function canInteract(Vector3 $pos, $maxDistance) : bool{ $eyePos = $this->getPosition()->add(0, $this->getEyeHeight(), 0); if($eyePos->distanceSquared($pos) > $maxDistance ** 2){ return false; } - $dV = $this->getDirectionPlane(); - $dot = $dV->dot(new Vector2($eyePos->x, $eyePos->z)); - $dot1 = $dV->dot(new Vector2($pos->x, $pos->z)); - return ($dot1 - $dot) >= -$maxDiff; + $dV = $this->getDirectionVector(); + $eyeDot = $dV->dot($eyePos); + $targetDot = $dV->dot($pos); + return ($targetDot - $eyeDot) >= 0; } protected function initHumanData(){