Allow a rand number of identical numbers.

This doesn't really make any sense but it keeps being reported as a bug so, heres a fix.
This commit is contained in:
Brianna 2021-06-01 12:06:57 -05:00
parent 8e4a6c8b1b
commit ea43620adb

View File

@ -44,12 +44,16 @@ public class SpawnOptionEntity implements SpawnOption {
location.add(.5, .5, .5);
if (location.getWorld() == null) return;
String[] randomLowHigh = Settings.RANDOM_LOW_HIGH.getString().split(":");
String highLow = Settings.RANDOM_LOW_HIGH.getString();
String[] randomLowHigh = highLow.split(":");
boolean isSame = randomLowHigh.length == 1 || randomLowHigh[0].equals(randomLowHigh[1]);
// Get the amount of entities to spawn per spawner in the stack.
int spawnCount = 0;
for (int i = 0; i < stack.getStackSize(); i++) {
int randomAmt = ThreadLocalRandom.current().nextInt(Integer.parseInt(randomLowHigh[0]), Integer.parseInt(randomLowHigh[1]));
int randomAmt = isSame ? Integer.parseInt(randomLowHigh[0]) :
ThreadLocalRandom.current().nextInt(Integer.parseInt(randomLowHigh[0]),
Integer.parseInt(randomLowHigh[1]));
String equation = Settings.SPAWNER_SPAWN_EQUATION.getString();
equation = equation.replace("{RAND}", Integer.toString(randomAmt));