Skip to content

Commit

Permalink
fixes dupe from refinedmods#3669
Browse files Browse the repository at this point in the history
  • Loading branch information
mahjerion authored Dec 13, 2024
1 parent 975abec commit f77809b
Showing 1 changed file with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,30 @@ public ItemStack extract(@Nonnull ItemStack stack, int size, int flags, Action a

ItemStack received = ItemStack.EMPTY;

for (int i = 0; i < handler.getSlots(); ++i) {
ItemStack slot = handler.getStackInSlot(i);
while(remaining > 0) {
for (int i = 0; i < handler.getSlots(); ++i) {
ItemStack slot = handler.getStackInSlot(i);

if (!slot.isEmpty() && API.instance().getComparer().isEqual(slot, stack, flags)) {
//Check if the requested amount of 64 isn't found in the slot
if(slot.getCount() < remaining) {
remaining = slot.getCount();
}

if (!slot.isEmpty() && API.instance().getComparer().isEqual(slot, stack, flags)) {
ItemStack got = handler.extractItem(i, remaining, action == Action.SIMULATE);
ItemStack got = handler.extractItem(i, Math.min(remaining, stack.getMaxStackSize()), action == Action.SIMULATE);

if (!got.isEmpty()) {
if (received.isEmpty()) {
received = got.copy();
} else {
received.grow(got.getCount());
}
if (!got.isEmpty()) {
if (received.isEmpty()) {
received = got.copy();
} else {
received.grow(got.getCount());
}

remaining -= got.getCount();
remaining -= got.getCount();

if (remaining == 0) {
break;
if (remaining == 0) {
break;
}
}
}
}
Expand Down

0 comments on commit f77809b

Please sign in to comment.