From 314b6eff74fab3c0e21e4a958776d6484a7e1b7f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 15 Jan 2026 03:52:27 +0000 Subject: [PATCH 1/5] Initial plan From 7993ffada2fb047accf302890188926259d67599 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 15 Jan 2026 04:00:27 +0000 Subject: [PATCH 2/5] Fix pitch and yaw wrapping in lookAt method Co-authored-by: EastArctica <32211444+EastArctica@users.noreply.github.com> --- .../entity/ClientPlayerEntityHelper.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/com/jsmacrosce/jsmacros/client/api/helper/world/entity/ClientPlayerEntityHelper.java b/common/src/main/java/com/jsmacrosce/jsmacros/client/api/helper/world/entity/ClientPlayerEntityHelper.java index 9bcfc9b90..150add4f1 100644 --- a/common/src/main/java/com/jsmacrosce/jsmacros/client/api/helper/world/entity/ClientPlayerEntityHelper.java +++ b/common/src/main/java/com/jsmacrosce/jsmacros/client/api/helper/world/entity/ClientPlayerEntityHelper.java @@ -195,6 +195,19 @@ public ClientPlayerEntityHelper lookAt(String direction) { return lookAt(yaw, pitch); } + /** + * Wraps {@code targetYaw} into an equivalent angle that is + * closest to {@code lastYaw}, preventing large packet deltas. + * + * @param lastYaw the yaw last sent to the server + * @param targetYaw the desired logical yaw + * @return a yaw value safe to send this tick + */ + private static float safeWrapDegrees(float lastYaw, float targetYaw) { + float delta = Mth.wrapDegrees(targetYaw - lastYaw); + return lastYaw + delta; + } + /** * @param yaw (was pitch prior to 1.2.6) * @param pitch (was yaw prior to 1.2.6) @@ -202,11 +215,14 @@ public ClientPlayerEntityHelper lookAt(String direction) { * @since 1.0.3 */ public ClientPlayerEntityHelper lookAt(double yaw, double pitch) { - pitch = Mth.clamp(pitch, -90.0F, 90.0F); base.xRotO = base.getXRot(); base.yRotO = base.getYRot(); - base.setXRot((float) pitch); - base.setYRot(Mth.wrapDegrees((float) yaw)); + + float safeYaw = safeWrapDegrees(base.yRotO, (float) yaw); + float safePitch = Mth.clamp(safeWrapDegrees(base.xRotO, (float) pitch), -90.0F, 90.0F); + + base.setXRot(safePitch); + base.setYRot(safeYaw); if (base.getVehicle() != null) { base.getVehicle().onPassengerTurned(base); } From 5eb23089a93a65419acd73b71bed1fd0df424c0a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 15 Jan 2026 04:01:22 +0000 Subject: [PATCH 3/5] Update safeWrapDegrees documentation to be more generic Co-authored-by: EastArctica <32211444+EastArctica@users.noreply.github.com> --- .../world/entity/ClientPlayerEntityHelper.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/common/src/main/java/com/jsmacrosce/jsmacros/client/api/helper/world/entity/ClientPlayerEntityHelper.java b/common/src/main/java/com/jsmacrosce/jsmacros/client/api/helper/world/entity/ClientPlayerEntityHelper.java index 150add4f1..9b092ba6d 100644 --- a/common/src/main/java/com/jsmacrosce/jsmacros/client/api/helper/world/entity/ClientPlayerEntityHelper.java +++ b/common/src/main/java/com/jsmacrosce/jsmacros/client/api/helper/world/entity/ClientPlayerEntityHelper.java @@ -196,16 +196,16 @@ public ClientPlayerEntityHelper lookAt(String direction) { } /** - * Wraps {@code targetYaw} into an equivalent angle that is - * closest to {@code lastYaw}, preventing large packet deltas. + * Wraps {@code targetAngle} into an equivalent angle that is + * closest to {@code lastAngle}, preventing large packet deltas. * - * @param lastYaw the yaw last sent to the server - * @param targetYaw the desired logical yaw - * @return a yaw value safe to send this tick + * @param lastAngle the angle last sent to the server + * @param targetAngle the desired logical angle + * @return an angle value safe to send this tick */ - private static float safeWrapDegrees(float lastYaw, float targetYaw) { - float delta = Mth.wrapDegrees(targetYaw - lastYaw); - return lastYaw + delta; + private static float safeWrapDegrees(float lastAngle, float targetAngle) { + float delta = Mth.wrapDegrees(targetAngle - lastAngle); + return lastAngle + delta; } /** From b81c94edb503de1bc108b9db0b6976ec2ecaee0f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 15 Jan 2026 04:02:40 +0000 Subject: [PATCH 4/5] Address code review feedback with improved documentation Co-authored-by: EastArctica <32211444+EastArctica@users.noreply.github.com> --- .../api/helper/world/entity/ClientPlayerEntityHelper.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/com/jsmacrosce/jsmacros/client/api/helper/world/entity/ClientPlayerEntityHelper.java b/common/src/main/java/com/jsmacrosce/jsmacros/client/api/helper/world/entity/ClientPlayerEntityHelper.java index 9b092ba6d..14bd9b262 100644 --- a/common/src/main/java/com/jsmacrosce/jsmacros/client/api/helper/world/entity/ClientPlayerEntityHelper.java +++ b/common/src/main/java/com/jsmacrosce/jsmacros/client/api/helper/world/entity/ClientPlayerEntityHelper.java @@ -199,7 +199,7 @@ public ClientPlayerEntityHelper lookAt(String direction) { * Wraps {@code targetAngle} into an equivalent angle that is * closest to {@code lastAngle}, preventing large packet deltas. * - * @param lastAngle the angle last sent to the server + * @param lastAngle the previous rotation value * @param targetAngle the desired logical angle * @return an angle value safe to send this tick */ @@ -219,6 +219,7 @@ public ClientPlayerEntityHelper lookAt(double yaw, double pitch) { base.yRotO = base.getYRot(); float safeYaw = safeWrapDegrees(base.yRotO, (float) yaw); + // Pitch is wrapped relative to previous pitch, then clamped to valid range [-90, 90] float safePitch = Mth.clamp(safeWrapDegrees(base.xRotO, (float) pitch), -90.0F, 90.0F); base.setXRot(safePitch); From ef6756ac3eb7f37dab0225dcb222114229d55073 Mon Sep 17 00:00:00 2001 From: Jack Manning Date: Mon, 19 Jan 2026 17:45:35 -0500 Subject: [PATCH 5/5] Fix pitch wrapping --- .../api/helper/world/entity/ClientPlayerEntityHelper.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/common/src/main/java/com/jsmacrosce/jsmacros/client/api/helper/world/entity/ClientPlayerEntityHelper.java b/common/src/main/java/com/jsmacrosce/jsmacros/client/api/helper/world/entity/ClientPlayerEntityHelper.java index 14bd9b262..43fb611e6 100644 --- a/common/src/main/java/com/jsmacrosce/jsmacros/client/api/helper/world/entity/ClientPlayerEntityHelper.java +++ b/common/src/main/java/com/jsmacrosce/jsmacros/client/api/helper/world/entity/ClientPlayerEntityHelper.java @@ -219,8 +219,7 @@ public ClientPlayerEntityHelper lookAt(double yaw, double pitch) { base.yRotO = base.getYRot(); float safeYaw = safeWrapDegrees(base.yRotO, (float) yaw); - // Pitch is wrapped relative to previous pitch, then clamped to valid range [-90, 90] - float safePitch = Mth.clamp(safeWrapDegrees(base.xRotO, (float) pitch), -90.0F, 90.0F); + float safePitch = Mth.clamp((float) pitch, -90.0F, 90.0F); base.setXRot(safePitch); base.setYRot(safeYaw);