Player: Use fmod() instead of modulo operator for yaw/pitch

the modulo (%) operator only operates on integers. If it's used on floats, they are silently casted to ints, which results in loss of accuracy. Fractions of a degree might not seem important, but for ray-tracing purposes a fraction of a degree can make the difference between hit and miss.
This commit is contained in:
Dylan K. Taylor 2017-12-24 19:48:43 +00:00
parent 1edf69892a
commit ddbc5cf960

View File

@ -2148,8 +2148,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$this->isTeleporting = false;
}
$packet->yaw %= 360;
$packet->pitch %= 360;
$packet->yaw = fmod($packet->yaw, 360);
$packet->pitch = fmod($packet->pitch, 360);
if($packet->yaw < 0){
$packet->yaw += 360;