Skip to content

Commit d75b24d

Browse files
committed
add more informative crash when trying to create a slot with invalid index
1 parent 6ab5a76 commit d75b24d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/main/java/com/cleanroommc/modularui/widgets/slot/ModularSlot.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ public class ModularSlot extends SlotItemHandler {
4242
*/
4343
public ModularSlot(IItemHandler itemHandler, int index) {
4444
super(itemHandler, index, Integer.MIN_VALUE, Integer.MIN_VALUE);
45+
if (index < 0 || index >= itemHandler.getSlots()) {
46+
throw new IllegalArgumentException("Tried to create a slot with invalid index " + index + ". Valid index range is [0," + itemHandler.getSlots() + ")");
47+
}
4548
}
4649

4750
@ApiStatus.Internal

0 commit comments

Comments
 (0)