Skip to content

Commit 58feb35

Browse files
authored
fix: facingYaw now works for secondary inter-cardinal directions (#23)
1 parent f8a71d5 commit 58feb35

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ Useful for spinning the camera manually, then aligning to the grid.
1919

2020
### Snap to Facing Mode
2121
When clicking the compass, the camera will snap to face the same direction as your character.
22-
Works with all 8 directions (N, NE, E, SE, S, SW, W, NW).
2322

2423
### Shift-Click Option
2524
You can configure how the plugin responds to clicks on the compass:

src/main/java/com/compassCameraControl/CompassCameraControlPlugin.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,9 @@ public class CompassCameraControlPlugin extends Plugin
3838

3939

4040
private static final int NORTH_YAW = 0;
41-
private static final int NORTHWEST_YAW = 256;
4241
private static final int WEST_YAW = 512;
43-
private static final int SOUTHWEST_YAW = 768;
4442
private static final int SOUTH_YAW = 1024;
45-
private static final int SOUTHEAST_YAW= 1280;
4643
private static final int EAST_YAW = 1536;
47-
private static final int NORTHEAST_YAW = 1792;
4844

4945
private static final Map<Character, Integer> directionMap = Map.of(
5046
'N', NORTH_YAW,
@@ -210,11 +206,15 @@ private void facingYaw()
210206
}
211207

212208
int playerOrientation = client.getLocalPlayer().getOrientation();
213-
int direction = playerOrientation / 256;
209+
int targetYaw;
214210

215-
int[] yaws = {SOUTH_YAW, SOUTHWEST_YAW, WEST_YAW, NORTHWEST_YAW, NORTH_YAW, NORTHEAST_YAW, EAST_YAW, SOUTHEAST_YAW};
211+
if (playerOrientation <= 1024) {
212+
targetYaw = 512 * 2 - playerOrientation;
213+
} else {
214+
targetYaw = 1536 * 2 - playerOrientation;
215+
}
216216

217-
client.setCameraYawTarget(yaws[direction]);
217+
client.setCameraYawTarget(targetYaw);
218218
}
219219

220220
private final KeyListener keyListener = new KeyListener() {

0 commit comments

Comments
 (0)