mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-01-13 03:40:39 +01:00
Clamp yaw properly for smoothrotationtrait
This commit is contained in:
parent
4bb3ee8845
commit
0645934c1e
@ -187,12 +187,12 @@ public class SmoothRotationTrait extends Trait {
|
|||||||
|
|
||||||
public float rotateHeadYawTowards(int t, float yaw, float targetYaw) {
|
public float rotateHeadYawTowards(int t, float yaw, float targetYaw) {
|
||||||
float out = rotateTowards(yaw, targetYaw, maxYawPerTick);
|
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) {
|
public float rotatePitchTowards(int t, float pitch, float targetPitch) {
|
||||||
float out = rotateTowards(pitch, targetPitch, maxPitchPerTick);
|
float out = rotateTowards(pitch, targetPitch, maxPitchPerTick);
|
||||||
return clamp(out, pitchRange[0], pitchRange[1]);
|
return Util.clamp(out, pitchRange[0], pitchRange[1], 360);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -78,6 +78,16 @@ public class Util {
|
|||||||
return angle;
|
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) {
|
public static ItemStack createItem(Material mat, String name) {
|
||||||
return createItem(mat, name, null);
|
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 Location AT_LOCATION = new Location(null, 0, 0, 0);
|
||||||
|
|
||||||
private static final Scoreboard DUMMY_SCOREBOARD = Bukkit.getScoreboardManager().getNewScoreboard();
|
private static final Scoreboard DUMMY_SCOREBOARD = Bukkit.getScoreboardManager().getNewScoreboard();
|
||||||
private static String MINECRAFT_REVISION;
|
private static String MINECRAFT_REVISION;
|
||||||
private static Boolean REQUIRES_CHANNEL_METADATA;
|
private static Boolean REQUIRES_CHANNEL_METADATA;
|
||||||
|
Loading…
Reference in New Issue
Block a user