From 89e754245ddfa347a1b528847c98e137e0bc40a8 Mon Sep 17 00:00:00 2001 From: Julian Krings Date: Sun, 21 Jul 2024 16:00:02 +0200 Subject: [PATCH] add maxTries to IrisLootTable to prevent crash --- .../java/com/volmit/iris/engine/object/IrisLootTable.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/volmit/iris/engine/object/IrisLootTable.java b/core/src/main/java/com/volmit/iris/engine/object/IrisLootTable.java index 089ec86fd..38964c72a 100644 --- a/core/src/main/java/com/volmit/iris/engine/object/IrisLootTable.java +++ b/core/src/main/java/com/volmit/iris/engine/object/IrisLootTable.java @@ -59,6 +59,10 @@ public class IrisLootTable extends IrisRegistrant { @Desc("The minimum amount of loot that can be picked in this table at a time.") private int minPicked = 1; + @MinNumber(1) + @Desc("The maximum amount of tries to generate loot") + private int maxTries = 10; + @Desc("The loot in this table") @ArrayType(min = 1, type = IrisLoot.class) private KList loot = new KList<>(); @@ -67,9 +71,10 @@ public class IrisLootTable extends IrisRegistrant { KList lootf = new KList<>(); int m = 0; + int c = 0; int mx = rng.i(getMinPicked(), getMaxPicked()); - while (m < mx) { + while (m < mx && c++ < getMaxTries()) { int num = rng.i(loot.size()); IrisLoot l = loot.get(num);