Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yaw exceeding limits #618

Open
Alvsch opened this issue May 23, 2024 · 4 comments
Open

Yaw exceeding limits #618

Alvsch opened this issue May 23, 2024 · 4 comments
Labels
bug Something isn't working triage Bug has not been confirmed as real issue yet

Comments

@Alvsch
Copy link

Alvsch commented May 23, 2024

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

@Alvsch Alvsch added bug Something isn't working triage Bug has not been confirmed as real issue yet labels May 23, 2024
@Alvsch Alvsch changed the title yaw not clamping Yaw not clamping May 23, 2024
@Alvsch Alvsch changed the title Yaw not clamping Yaw exceeding limits May 23, 2024
@rj00a
Copy link
Member

rj00a commented May 24, 2024

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?

@Alvsch
Copy link
Author

Alvsch commented May 24, 2024

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,

@DasLixou
Copy link
Contributor

I wonder how that is handled in other server implementations like Minestom or Vanilla/Spigot.

@earomc
Copy link

earomc commented May 25, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage Bug has not been confirmed as real issue yet
Projects
None yet
Development

No branches or pull requests

4 participants