Player: Do direction checks for interaction in 3D instead of 2D

This fixes #983, but I haven't yet tested if this will prevent cheating in an actual hacker scenario. Needs more tests.

Additionally, this should remove the need for the negative threshold - if the diff is less than 0, the player is almost definitely cheating.
This commit is contained in:
Dylan K. Taylor 2017-12-22 20:06:59 +00:00
parent 0688a86f57
commit a8bf2191b9

View File

@ -1753,10 +1753,10 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
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) >= -$maxDiff;
}
protected function initHumanData(){