ArnicaLib

ArnicaLib

203k Downloads

[Bug] RandomUtils percentageChance method validation always fails

WakelessSloth56 opened this issue ยท 1 comments

commented
Caused by: java.lang.IllegalArgumentException: The left bound must be less than the right bound
        at org.apache.commons.lang3.Validate.isTrue(Validate.java:158) ~[commons-lang3-3.12.0.jar%2318!/:3.12.0]
        at org.auioc.mods.arnicalib.utils.java.Validate.isBoundedInterval(Validate.java:143) ~[%2381!/:?]
        at org.auioc.mods.arnicalib.utils.java.Validate.isInCloseInterval(Validate.java:181) ~[%2381!/:?]
        at org.auioc.mods.arnicalib.utils.java.RandomUtils.percentageChance(RandomUtils.java:73) ~[%2381!/:?]
commented

public static boolean percentageChance(int chance) {
Validate.isInCloseInterval(chance, 0, 100);
return nextInt(0, 100) < chance;
}
public static boolean percentageChance(int chance, Random random) {
Validate.isInCloseInterval(chance, 0, 100);
return random.nextInt(100) < chance;
}

public static void isInCloseInterval(long left, long right, long value) {

isInCloseInterval method parameter order should be left bound, right bound, value.