fixes for autocrafting related to the ore dict

This commit is contained in:
way2muchnoise
2016-10-17 20:57:57 +02:00
parent 5480640c49
commit bc98808ad2
2 changed files with 8 additions and 8 deletions

View File

@@ -26,6 +26,8 @@ import java.util.*;
import java.util.stream.Collectors;
public class CraftingTask implements ICraftingTask {
private static final int defaultCompare = IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT;
private INetworkMaster network;
private ItemStack requested;
private ICraftingPattern pattern;
@@ -38,7 +40,6 @@ public class CraftingTask implements ICraftingTask {
private Set<ICraftingPattern> usedPatterns = new HashSet<>();
private boolean recurseFound = false;
private Deque<ItemStack> toInsert = new ArrayDeque<>();
private int compare = IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT;
private List<ItemStack> took = new ArrayList<>();
private List<FluidStack> tookFluids = new ArrayList<>();
@@ -47,10 +48,6 @@ public class CraftingTask implements ICraftingTask {
this.requested = requested;
this.pattern = pattern;
this.quantity = quantity;
if (pattern.isOredict()) {
this.compare |= IComparer.COMPARE_OREDICT;
}
}
@Override
@@ -78,6 +75,7 @@ public class CraftingTask implements ICraftingTask {
return;
}
int compare = defaultCompare | (pattern.isOredict() ? IComparer.COMPARE_OREDICT : 0);
ItemStack[] took = new ItemStack[9];
if (pattern.isProcessing()) {
@@ -214,7 +212,7 @@ public class CraftingTask implements ICraftingTask {
IItemHandler inventory = processable.getPattern().getContainer().getFacingInventory();
if (inventory != null && !processable.getToInsert().isEmpty()) {
ItemStack toInsert = network.extractItem(processable.getToInsert().peek(), 1, compare);
ItemStack toInsert = network.extractItem(processable.getToInsert().peek(), 1, defaultCompare | (pattern.isOredict() ? IComparer.COMPARE_OREDICT : 0));
if (ItemHandlerHelper.insertItem(inventory, toInsert, true) == null) {
ItemHandlerHelper.insertItem(inventory, toInsert, false);
@@ -225,7 +223,7 @@ public class CraftingTask implements ICraftingTask {
}
for (ItemStack stack : toTake.getStacks()) {
ItemStack stackExtracted = network.extractItem(stack, 1, compare);
ItemStack stackExtracted = network.extractItem(stack, 1);
if (stackExtracted != null) {
toTake.remove(stack, 1, true);

View File

@@ -3,6 +3,7 @@ package refinedstorage.apiimpl.util;
import com.google.common.collect.ArrayListMultimap;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import refinedstorage.api.util.IComparer;
import refinedstorage.api.util.IItemStackList;
import refinedstorage.apiimpl.API;
@@ -46,7 +47,8 @@ public class ItemStackList implements IItemStackList {
@Override
@Nullable
public ItemStack get(@Nonnull ItemStack stack, int flags) {
for (ItemStack otherStack : stacks.get(stack.getItem())) {
// When the oreDict flag is set all stacks need to be checked not just the ones matching the Item
for (ItemStack otherStack : (flags & IComparer.COMPARE_OREDICT) == IComparer.COMPARE_OREDICT ? stacks.values() : stacks.get(stack.getItem())) {
if (API.instance().getComparer().isEqual(otherStack, stack, flags)) {
return otherStack;
}