diff --git a/main/src/main/java/net/citizensnpcs/trait/SmoothRotationTrait.java b/main/src/main/java/net/citizensnpcs/trait/SmoothRotationTrait.java index 018a714a4..0d0e344db 100644 --- a/main/src/main/java/net/citizensnpcs/trait/SmoothRotationTrait.java +++ b/main/src/main/java/net/citizensnpcs/trait/SmoothRotationTrait.java @@ -187,12 +187,12 @@ public class SmoothRotationTrait extends Trait { public float rotateHeadYawTowards(int t, float yaw, float targetYaw) { float out = rotateTowards(yaw, targetYaw, maxYawPerTick); - return clamp(out, yawRange[0], yawRange[1]); + return Util.clamp(out, yawRange[0], yawRange[1], 360); } public float rotatePitchTowards(int t, float pitch, float targetPitch) { float out = rotateTowards(pitch, targetPitch, maxPitchPerTick); - return clamp(out, pitchRange[0], pitchRange[1]); + return Util.clamp(out, pitchRange[0], pitchRange[1], 360); } /* diff --git a/main/src/main/java/net/citizensnpcs/util/Util.java b/main/src/main/java/net/citizensnpcs/util/Util.java index 7d90ab9e3..a66726a05 100644 --- a/main/src/main/java/net/citizensnpcs/util/Util.java +++ b/main/src/main/java/net/citizensnpcs/util/Util.java @@ -78,6 +78,16 @@ public class Util { return angle; } + public static float clamp(float angle, float min, float max, float d) { + while (angle < min) { + angle += d; + } + while (angle >= max) { + angle -= d; + } + return angle; + } + public static ItemStack createItem(Material mat, String name) { return createItem(mat, name, null); } @@ -357,7 +367,6 @@ public class Util { } private static final Location AT_LOCATION = new Location(null, 0, 0, 0); - private static final Scoreboard DUMMY_SCOREBOARD = Bukkit.getScoreboardManager().getNewScoreboard(); private static String MINECRAFT_REVISION; private static Boolean REQUIRES_CHANNEL_METADATA;