Merge remote-tracking branch 'origin/mc1.10' into mc1.10
This commit is contained in:
@@ -80,20 +80,6 @@ public abstract class CraftingStep implements ICraftingStep {
|
||||
return pattern.getInputs().stream().filter(Objects::nonNull).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canStartProcessing(IItemStackList items, IFluidStackList fluids) {
|
||||
for (ItemStack stack : getToInsert()) {
|
||||
ItemStack actualStack = items.get(stack, IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT | (pattern.isOredict() ? IComparer.COMPARE_OREDICT : 0));
|
||||
|
||||
if (actualStack == null || actualStack.stackSize == 0 || !items.trackedRemove(actualStack, stack.stackSize, true)) {
|
||||
items.undo();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
items.undo();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStartedProcessing() {
|
||||
startedProcessing = true;
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.autocrafting.task;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.RSUtils;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
|
||||
@@ -36,7 +37,8 @@ public class CraftingStepCraft extends CraftingStep {
|
||||
|
||||
if (fluidInItem != null && RSUtils.hasFluidBucket(fluidInItem)) {
|
||||
FluidStack fluidStack = fluids.get(fluidInItem, compare);
|
||||
if (fluidStack != null && fluids.trackedRemove(fluidStack, fluidInItem.amount, true)) {
|
||||
ItemStack bucket = items.get(RSUtils.EMPTY_BUCKET, compare);
|
||||
if (bucket != null && fluidStack != null && fluids.trackedRemove(fluidStack, fluidInItem.amount, true) && items.remove(bucket, 1, true)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -58,6 +60,7 @@ public class CraftingStepCraft extends CraftingStep {
|
||||
FluidStack fluidInItem = RSUtils.getFluidFromStack(insertStack, true);
|
||||
if (fluidInItem != null) {
|
||||
network.extractFluid(fluidInItem, fluidInItem.amount, compare);
|
||||
network.extractItem(RSUtils.EMPTY_BUCKET, 1, compare);
|
||||
actualInputs.add(insertStack.copy());
|
||||
} else {
|
||||
actualInputs.add(network.extractItem(insertStack, insertStack.stackSize, compare));
|
||||
@@ -76,11 +79,15 @@ public class CraftingStepCraft extends CraftingStep {
|
||||
}
|
||||
|
||||
for (ItemStack byproduct : (pattern.isOredict()? pattern.getByproducts(took) : pattern.getByproducts())) {
|
||||
toInsertItems.add(byproduct.copy());
|
||||
if(byproduct != null) {
|
||||
toInsertItems.add(byproduct.copy());
|
||||
}
|
||||
}
|
||||
|
||||
for (ItemStack output : (pattern.isOredict() ? pattern.getOutputs(took) : pattern.getOutputs())) {
|
||||
toInsertItems.add(output.copy());
|
||||
if(output != null) {
|
||||
toInsertItems.add(output.copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -3,6 +3,8 @@ package com.raoulvdberge.refinedstorage.apiimpl.autocrafting.task;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IFluidStackList;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IItemStackList;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -22,12 +24,32 @@ public class CraftingStepProcess extends CraftingStep {
|
||||
super(network);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canStartProcessing(IItemStackList items, IFluidStackList fluids) {
|
||||
IItemHandler inventory = getPattern().getContainer().getFacingInventory();
|
||||
if (inventory != null) {
|
||||
for (ItemStack stack : getToInsert()) {
|
||||
ItemStack actualStack = items.get(stack, IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT | (pattern.isOredict() ? IComparer.COMPARE_OREDICT : 0));
|
||||
|
||||
boolean canInsert = ItemHandlerHelper.insertItem(inventory, ItemHandlerHelper.copyStackWithSize(actualStack, stack.stackSize), true) == null;
|
||||
if (actualStack == null || actualStack.stackSize == 0 || !items.trackedRemove(actualStack, stack.stackSize, true) && canInsert) {
|
||||
items.undo();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
items.undo();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Deque<ItemStack> toInsertItems, Deque<FluidStack> toInsertFluids) {
|
||||
// @TODO: fluid handling
|
||||
IItemHandler inventory = getPattern().getContainer().getFacingInventory();
|
||||
int compare = CraftingTask.DEFAULT_COMPARE | (getPattern().isOredict() ? IComparer.COMPARE_OREDICT : 0);
|
||||
for (ItemStack insertStack : getToInsert()) {
|
||||
ItemStack tookStack = network.extractItem(insertStack, insertStack.stackSize, CraftingTask.DEFAULT_COMPARE | (getPattern().isOredict() ? IComparer.COMPARE_OREDICT : 0));
|
||||
ItemStack tookStack = network.extractItem(insertStack, insertStack.stackSize, compare);
|
||||
ItemHandlerHelper.insertItem(inventory, tookStack, false);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user