mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-30 06:33:56 +01:00
Check for range equality in random lookclose
This commit is contained in:
parent
50218336c5
commit
2a131102df
@ -106,6 +106,10 @@ public class LookClose extends Trait implements Toggleable, CommandConfigurable
|
|||||||
return lookingAt == null;
|
return lookingAt == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isEqual(float[] array) {
|
||||||
|
return Math.abs(array[0] - array[1]) < 0.001;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isPluginVanished(Player player) {
|
private boolean isPluginVanished(Player player) {
|
||||||
for (MetadataValue meta : player.getMetadata("vanished")) {
|
for (MetadataValue meta : player.getMetadata("vanished")) {
|
||||||
if (meta.asBoolean()) {
|
if (meta.asBoolean()) {
|
||||||
@ -134,8 +138,10 @@ public class LookClose extends Trait implements Toggleable, CommandConfigurable
|
|||||||
|
|
||||||
private void randomLook() {
|
private void randomLook() {
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
float pitch = rand.doubles(randomPitchRange[0], randomPitchRange[1]).iterator().next().floatValue(),
|
float pitch = isEqual(randomPitchRange) ? randomPitchRange[0]
|
||||||
yaw = rand.doubles(randomYawRange[0], randomYawRange[1]).iterator().next().floatValue();
|
: rand.doubles(randomPitchRange[0], randomPitchRange[1]).iterator().next().floatValue();
|
||||||
|
float yaw = isEqual(randomYawRange) ? randomYawRange[0]
|
||||||
|
: rand.doubles(randomYawRange[0], randomYawRange[1]).iterator().next().floatValue();
|
||||||
Util.assumePose(npc.getEntity(), yaw, pitch);
|
Util.assumePose(npc.getEntity(), yaw, pitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user