Fixed air appearing in Grid, fixes #1561
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
- Added Funky Locomotion integration (raoulvdberge)
|
- Added Funky Locomotion integration (raoulvdberge)
|
||||||
- Minor fixes to autocrafting (raoulvdberge)
|
- Minor fixes to autocrafting (raoulvdberge)
|
||||||
- Fixed Exporter in Regulator Mode not regulating properly when same item is specified multiple times (raoulvdberge)
|
- Fixed Exporter in Regulator Mode not regulating properly when same item is specified multiple times (raoulvdberge)
|
||||||
|
- Fixed air appearing in Grid (raoulvdberge)
|
||||||
|
|
||||||
### 1.5.25
|
### 1.5.25
|
||||||
- Fixed not being able to autocraft different Storage Drawers' wood drawers (raoulvdberge)
|
- Fixed not being able to autocraft different Storage Drawers' wood drawers (raoulvdberge)
|
||||||
|
|||||||
@@ -7,18 +7,17 @@ import com.raoulvdberge.refinedstorage.apiimpl.API;
|
|||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.*;
|
import java.util.Collection;
|
||||||
import java.util.stream.Collectors;
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class StackListItem implements IStackList<ItemStack> {
|
public class StackListItem implements IStackList<ItemStack> {
|
||||||
private ArrayListMultimap<Item, ItemStack> stacks = ArrayListMultimap.create();
|
private ArrayListMultimap<Item, ItemStack> stacks = ArrayListMultimap.create();
|
||||||
private List<ItemStack> removeTracker = new LinkedList<>();
|
private List<ItemStack> removeTracker = new LinkedList<>();
|
||||||
protected boolean needsCleanup = false;
|
protected boolean needsCleanup = false;
|
||||||
private Set<Item> touchedItems = new HashSet<>();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(@Nonnull ItemStack stack, int size) {
|
public void add(@Nonnull ItemStack stack, int size) {
|
||||||
@@ -49,7 +48,6 @@ public class StackListItem implements IStackList<ItemStack> {
|
|||||||
otherStack.shrink(size);
|
otherStack.shrink(size);
|
||||||
|
|
||||||
if (otherStack.isEmpty()) {
|
if (otherStack.isEmpty()) {
|
||||||
touchedItems.add(stack.getItem());
|
|
||||||
needsCleanup = true;
|
needsCleanup = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +69,6 @@ public class StackListItem implements IStackList<ItemStack> {
|
|||||||
otherStack.shrink(size);
|
otherStack.shrink(size);
|
||||||
|
|
||||||
if (otherStack.isEmpty()) {
|
if (otherStack.isEmpty()) {
|
||||||
touchedItems.add(stack.getItem());
|
|
||||||
needsCleanup = true;
|
needsCleanup = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,14 +126,8 @@ public class StackListItem implements IStackList<ItemStack> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clean() {
|
public void clean() {
|
||||||
List<Pair<Item, ItemStack>> toRemove = touchedItems.stream()
|
stacks.values().removeIf(ItemStack::isEmpty);
|
||||||
.flatMap(item -> stacks.get(item).stream().map(stack -> Pair.of(item, stack)))
|
|
||||||
.filter(pair -> pair.getValue().isEmpty())
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
toRemove.forEach(pair -> stacks.remove(pair.getLeft(), pair.getRight()));
|
|
||||||
|
|
||||||
touchedItems.clear();
|
|
||||||
needsCleanup = false;
|
needsCleanup = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,6 +147,7 @@ public class StackListItem implements IStackList<ItemStack> {
|
|||||||
if (needsCleanup) {
|
if (needsCleanup) {
|
||||||
clean();
|
clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
return stacks.values();
|
return stacks.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user