mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-13 13:25:16 +00:00
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:
parent
1edf69892a
commit
ddbc5cf960
@ -2148,8 +2148,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
|||||||
$this->isTeleporting = false;
|
$this->isTeleporting = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$packet->yaw %= 360;
|
$packet->yaw = fmod($packet->yaw, 360);
|
||||||
$packet->pitch %= 360;
|
$packet->pitch = fmod($packet->pitch, 360);
|
||||||
|
|
||||||
if($packet->yaw < 0){
|
if($packet->yaw < 0){
|
||||||
$packet->yaw += 360;
|
$packet->yaw += 360;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user