Skip to content

Commit

Permalink
Fix trying to extract empty item resource
Browse files Browse the repository at this point in the history
  • Loading branch information
Su5eD committed Nov 11, 2023
1 parent 142e25a commit 51502a0
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,14 @@ public int getSlots() {
public @NotNull ItemStack extractItem(int slot, int amount, boolean simulate) {
try (Transaction transaction = Transaction.openOuter()) {
ItemVariant resource = slots.get(slot).getResource();
int extracted = (int) storage.extract(resource, amount, transaction);
if (!simulate) {
transaction.commit();
}
return resource.toStack(extracted);
if (!resource.isBlank()) {
int extracted = (int) storage.extract(resource, amount, transaction);
if (!simulate && extracted > 0) {
transaction.commit();
}
return resource.toStack(extracted);
}
return ItemStack.EMPTY;
}
}

Expand Down

0 comments on commit 51502a0

Please sign in to comment.