Skip to content

Commit

Permalink
Fix armory cabinet inventory voiding items
Browse files Browse the repository at this point in the history
Fix #222
  • Loading branch information
Matyrobbrt committed Jul 17, 2024
1 parent 17e077a commit 4d0b70e
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ public ItemStack getStackInSlot(int slot) {
@Override
public ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate) {
if (isValid(slot, stack)) {
if (!simulate){
this.stackList.set(slot, stack);
if (!simulate) {
this.stackList.set(slot, stack.copyWithCount(1));
onChange();
}
return ItemStack.EMPTY;

return stack.getCount() > 1 ? stack.copyWithCount(stack.getCount() - 1) : ItemStack.EMPTY;
}
return stack;
}
Expand All @@ -53,12 +54,13 @@ public ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate
@NotNull
@Override
public ItemStack extractItem(int slot, int amount, boolean simulate) {
if (!simulate){
ItemStack stack = this.stackList.set(slot, ItemStack.EMPTY);
var inSlot = this.stackList.get(slot).copy();
if (amount == 0 || inSlot.isEmpty()) return inSlot;
if (!simulate) {
stackList.set(slot, ItemStack.EMPTY);
onChange();
return stack;
}
return this.stackList.get(slot);
return inSlot;
}

@Override
Expand Down

0 comments on commit 4d0b70e

Please sign in to comment.