Skip to content

Commit

Permalink
Fix crash when you pass an invalid slot number
Browse files Browse the repository at this point in the history
java.lang.ArrayIndexOutOfBoundsException: Index -4 out of bounds for length 36
	at java.base/java.util.Arrays$ArrayList.get(Unknown Source)
  • Loading branch information
hellidox authored and Wide-Cat committed Aug 29, 2024
1 parent c67f2b9 commit 70dad7c
Showing 1 changed file with 1 addition and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ private static Value getItem(Starscript ss, int argCount) {
if (argCount != 1) ss.error("player.get_item() requires 1 argument, got %d.", argCount);

int i = (int) ss.popNumber("First argument to player.get_item() needs to be a number.");
if (i < 0 || i > 35) ss.error("First argument to player.get_item() needs to be between 0 and 35 (inclusive).", i);
return mc.player != null ? wrap(mc.player.getInventory().getStack(i)) : Value.null_();
}

Expand Down

0 comments on commit 70dad7c

Please sign in to comment.