Skip to content

Commit

Permalink
correct negative stack size to 1
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Aug 6, 2024
1 parent 1b2554f commit 2a89adb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,16 @@ public void handleItem(ItemStack itemStack, ItemLegality legality) {
if (handling == IllegalHandling.PREVENT_USE_ONLY) return; // We are cancelling the action in the super class

switch (legality) {
case ILLEGAL -> itemStack.setAmount(itemStack.getMaxStackSize());
case ILLEGAL -> {
if (itemStack.getAmount() < 1) {
itemStack.setAmount(1);
return;
}

if (itemStack.getAmount() > itemStack.getMaxStackSize()) {
itemStack.setAmount(itemStack.getMaxStackSize());
}
}
case CONTAINS_ILLEGAL -> itemStack.setAmount(0);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,15 @@ public void handleItem(ItemStack itemStack, ItemLegality legality) {

switch (legality) {
case ILLEGAL:
itemStack.setAmount(itemStack.getMaxStackSize());
break;
if (itemStack.getAmount() < 1) {
itemStack.setAmount(1);
return;
}

if (itemStack.getAmount() > itemStack.getMaxStackSize()) {
itemStack.setAmount(itemStack.getMaxStackSize());
}
return;
case CONTAINS_ILLEGAL:
itemStack.setAmount(0);
}
Expand Down

0 comments on commit 2a89adb

Please sign in to comment.