Revert "Player: Remove obsolete maxDiff parameter from canInteract()"

This reverts commit a5c3fbdd7a648d4a774e167570d2fc0165c66a80.
This commit is contained in:
Dylan K. Taylor 2018-01-04 15:33:23 +00:00
parent 5f48433c95
commit 3ca162f23f

View File

@ -1743,10 +1743,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
*
* @param Vector3 $pos
* @param float $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, float $maxDistance) : bool{
public function canInteract(Vector3 $pos, float $maxDistance, float $maxDiff = 0.71) : bool{
$eyePos = $this->getPosition()->add(0, $this->getEyeHeight(), 0);
if($eyePos->distanceSquared($pos) > $maxDistance ** 2){
return false;
@ -1755,7 +1756,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$dV = $this->getDirectionVector();
$eyeDot = $dV->dot($eyePos);
$targetDot = $dV->dot($pos);
return ($targetDot - $eyeDot) >= 0;
return ($targetDot - $eyeDot) >= -$maxDiff;
}
protected function initHumanData(){