1
0
mirror of https://github.com/GeyserMC/Geyser.git synced 2025-12-19 14:59:27 +00:00

Fix simulated position calculation for azimuth waypoints (#6060)

* Fix simulated position calculation for azimuth waypoints

* Add comment describing position calculation
This commit is contained in:
Jacob Hofer
2025-12-17 13:40:24 -07:00
committed by GitHub
parent 9a1d42584e
commit d35667a7ec

View File

@@ -68,8 +68,9 @@ public class AzimuthWaypoint extends GeyserWaypoint implements TickingWaypoint {
private void updatePosition() { private void updatePosition() {
Vector3f playerPosition = session.getPlayerEntity().position(); Vector3f playerPosition = session.getPlayerEntity().position();
// Unit circle math! // Unit circle math!
float dx = (float) (Math.cos(angle) * WAYPOINT_DISTANCE); // Unintuitively, the delta x corresponds to the sin of the angle, and delta z to the cos
float dz = (float) -(Math.sin(angle) * WAYPOINT_DISTANCE); float dx = (float) -(Math.sin(angle) * WAYPOINT_DISTANCE);
float dz = (float) (Math.cos(angle) * WAYPOINT_DISTANCE);
// Set Y to the player's Y since this waypoint always appears in the centre of the bar on Java // Set Y to the player's Y since this waypoint always appears in the centre of the bar on Java
position = Vector3f.from(playerPosition.getX() + dx, playerPosition.getY(), playerPosition.getZ() + dz); position = Vector3f.from(playerPosition.getX() + dx, playerPosition.getY(), playerPosition.getZ() + dz);
} }