Skip to content

Commit

Permalink
remove stack key if int set is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
ghzdude committed Jan 10, 2025
1 parent 1c677c1 commit 0ab25b2
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ private boolean simulateExtractItem(ItemStack itemStack, int count) {
// cache is not correct
if (slotStack.isEmpty() || !this.strategy.equals(slotStack, itemStack)) {
slotItr.remove();
if (!slotItr.hasNext()) stackLookupMap.remove(itemStack);
slot = handleCacheMiss(itemStack);
if (slot == -1) return false;
slotStack = availableHandlers.getStackInSlot(slot);
Expand Down Expand Up @@ -389,10 +390,10 @@ public int handleCacheMiss(ItemStack stack) {
if (curStack.isEmpty()) continue;

Set<Integer> slots;
if (stackLookupMap.containsKey(stack))
slots = stackLookupMap.get(stack);
else {
stackLookupMap.put(stack.copy(), slots = new IntArraySet());
if (stackLookupMap.containsKey(curStack)) {
slots = stackLookupMap.get(curStack);
} else {
stackLookupMap.put(curStack.copy(), slots = new IntArraySet());
}
slots.add(i);

Expand Down

0 comments on commit 0ab25b2

Please sign in to comment.