Skip to content

Commit 34e5d4b

Browse files
committed
Add random util method
help generates uniform random non-zero offsets within a radius
1 parent f6c056d commit 34e5d4b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/main/java/doggytalents/common/util/RandomUtil.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,9 @@ public static float nextFloatRemapped(RandomSource random) {
88
return random.nextFloat() * 2 - 1;
99
}
1010

11+
public static int randomOffsetNonZero(RandomSource random, int radius) {
12+
int ret = random.nextInt(radius * 2) - radius;
13+
return ret >= 0 ? ret + 1 : ret;
14+
}
15+
1116
}

0 commit comments

Comments
 (0)