Yaw exceeding limits
Alvsch opened this issue · 4 comments
Valence Version
v0.2.0-alpha.1+mc.1.20.1 (#7e91ca0f)
What You Did Do
spin around
https://drive.google.com/file/d/1FSWOni9cGB2K6jDE3VipBOpPVIQJvSt_/view?usp=sharing
What Went Wrong
The yaw in valence::entity::Look
is not wrapped making it exceed the normal limits if the player spins around
What were you expecting and what actually happened?
The yaw should wrap to stay within -180 and 180
If I'm not mistaken, this behavior is intentional because it's mirroring the actual yaw values the client is giving to the server.
I'm also not sure -180 to 180 is the most desirable range. Perhaps 0° ≤ θ < 360° would be more intuitive?
I looked into the code a bit and you're right that the yaw is set to the values received from the client.
The thing that confused me is that the docs for Look
insinuate that the yaw will be between -180 and 180. Same with the in-game F3 menu using -180 to 180 as yaw values.
/// The yaw angle in degrees, where:
/// - `-90` is looking east (towards positive x).
/// - `0` is looking south (towards positive z).
/// - `90` is looking west (towards negative x).
/// - `180` is looking north (towards negative z).
///
/// Values -180 to 180 are also valid.
pub yaw: f32,
I wonder how that is handled in other server implementations like Minestom or Vanilla/Spigot.
In Spigot they use -180 to 180 as well so I would not recommend messing with that convention. Even in Minecraft itself you can see yaw and pitch in the F3 debug menu in the same way.