Skip to content

Commit

Permalink
look command: wrap rel yaw values
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jan 3, 2023
1 parent 1349bf6 commit f640c2d
Showing 1 changed file with 6 additions and 2 deletions.
Expand Up @@ -119,7 +119,11 @@ public static void autoExecute(ScriptEntry scriptEntry,
else {
if (entity.isPlayer()) {
Location playerTeleDest = entity.getLocation().clone();
float relYaw = yawRaw - playerTeleDest.getYaw();
float relYaw = (yawRaw - playerTeleDest.getYaw()) % 360;
if (relYaw > 180) {
relYaw -= 360;
}
final float actualRelYaw = relYaw;
float relPitch = pitchRaw - playerTeleDest.getPitch();
playerTeleDest.setYaw(yawRaw);
playerTeleDest.setPitch(pitchRaw);
Expand All @@ -133,7 +137,7 @@ public static void autoExecute(ScriptEntry scriptEntry,
try {
for (int i = 0; i < times; i++) {
Thread.sleep(ms);
NMSHandler.packetHelper.sendRelativeLookPacket(player, relYaw, relPitch);
NMSHandler.packetHelper.sendRelativeLookPacket(player, actualRelYaw, relPitch);
}
}
catch (Throwable ex) {
Expand Down

0 comments on commit f640c2d

Please sign in to comment.