Fix some bugs

This commit is contained in:
raoulvdberge
2018-05-28 18:32:59 +02:00
parent c73a725d5e
commit bb9fe6db1c
4 changed files with 20 additions and 11 deletions

View File

@@ -34,7 +34,7 @@ public class CraftingPattern implements ICraftingPattern {
this.oredict = ItemPattern.isOredict(stack); this.oredict = ItemPattern.isOredict(stack);
if (processing) { if (processing) {
this.valid = true; this.valid = false; // TODO
for (int i = 0; i < 9; ++i) { for (int i = 0; i < 9; ++i) {
ItemStack input = ItemPattern.getSlot(stack, i); ItemStack input = ItemPattern.getSlot(stack, i);

View File

@@ -4,15 +4,18 @@ import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPattern;
import com.raoulvdberge.refinedstorage.api.network.INetwork; import com.raoulvdberge.refinedstorage.api.network.INetwork;
import com.raoulvdberge.refinedstorage.api.util.IStackList; import com.raoulvdberge.refinedstorage.api.util.IStackList;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
public class CraftingStepCraft implements ICraftingStep { public class CraftingStepCraft implements ICraftingStep {
private INetwork network; private INetwork network;
private IStackList<ItemStack> toExtract; private IStackList<ItemStack> toExtract;
private NonNullList<ItemStack> took;
private ICraftingPattern pattern; private ICraftingPattern pattern;
public CraftingStepCraft(INetwork network, IStackList<ItemStack> toExtract, ICraftingPattern pattern) { public CraftingStepCraft(INetwork network, IStackList<ItemStack> toExtract, NonNullList<ItemStack> took, ICraftingPattern pattern) {
this.network = network; this.network = network;
this.toExtract = toExtract; this.toExtract = toExtract;
this.took = took;
this.pattern = pattern; this.pattern = pattern;
} }
@@ -27,14 +30,18 @@ public class CraftingStepCraft implements ICraftingStep {
} }
for (ItemStack toExtractItem : toExtract.getStacks()) { for (ItemStack toExtractItem : toExtract.getStacks()) {
network.extractItem(toExtractItem, toExtractItem.getCount(), false); ItemStack extracted = network.extractItem(toExtractItem, toExtractItem.getCount(), false);
if (extracted == null) {
throw new IllegalStateException("Did not extract anything");
}
} }
for (ItemStack output : pattern.getOutputs()) { ItemStack output = pattern.getOutput(took);
network.insertItem(output, output.getCount(), false);
}
for (ItemStack byproduct : pattern.getByproducts()) { network.insertItem(output, output.getCount(), false);
for (ItemStack byproduct : pattern.getByproducts(took)) {
network.insertItem(byproduct, byproduct.getCount(), false); network.insertItem(byproduct, byproduct.getCount(), false);
} }

View File

@@ -69,7 +69,7 @@ public class CraftingTask implements ICraftingTask {
ItemStack fromSelf = results.get(possibleInput); ItemStack fromSelf = results.get(possibleInput);
if (fromSelf != null) { if (fromSelf != null) {
results.remove(possibleInput, Math.min(possibleInput.getCount(), fromSelf.getCount())); results.remove(fromSelf, Math.min(possibleInput.getCount(), fromSelf.getCount()));
toExtract -= fromSelf.getCount(); toExtract -= fromSelf.getCount();
} }
@@ -79,7 +79,7 @@ public class CraftingTask implements ICraftingTask {
int fromNetworkCount = fromNetwork == null ? 0 : Math.min(toExtract, fromNetwork.getCount()); int fromNetworkCount = fromNetwork == null ? 0 : Math.min(toExtract, fromNetwork.getCount());
itemsToExtract.add(possibleInput); itemsToExtract.add(possibleInput, toExtract);
if (fromNetworkCount > 0) { if (fromNetworkCount > 0) {
this.toTake.add(possibleInput, fromNetworkCount); this.toTake.add(possibleInput, fromNetworkCount);
@@ -123,7 +123,7 @@ public class CraftingTask implements ICraftingTask {
} }
} }
return new CraftingStepCraft(network, itemsToExtract, pattern); return new CraftingStepCraft(network, itemsToExtract, took, pattern);
} }
private int getQuantityPerCraft(ICraftingPattern pattern, ItemStack requested) { private int getQuantityPerCraft(ICraftingPattern pattern, ItemStack requested) {
@@ -181,6 +181,8 @@ public class CraftingTask implements ICraftingTask {
@Override @Override
public List<ICraftingMonitorElement> getCraftingMonitorElements() { public List<ICraftingMonitorElement> getCraftingMonitorElements() {
// TODO
ICraftingMonitorElementList elements = API.instance().createCraftingMonitorElementList(); ICraftingMonitorElementList elements = API.instance().createCraftingMonitorElementList();
elements.directAdd(new CraftingMonitorElementItemRender(network.getCraftingManager().getTasks().indexOf(this), requested, quantity, 0)); elements.directAdd(new CraftingMonitorElementItemRender(network.getCraftingManager().getTasks().indexOf(this), requested, quantity, 0));

View File

@@ -60,7 +60,7 @@ gui.refinedstorage:crafting_preview.error.2=itself.
gui.refinedstorage:crafting_preview.error.3=You need to remove the pattern or make sure gui.refinedstorage:crafting_preview.error.3=You need to remove the pattern or make sure
gui.refinedstorage:crafting_preview.error.4=the pattern is not used during crafting. gui.refinedstorage:crafting_preview.error.4=the pattern is not used during crafting.
gui.refinedstorage:crafting_preview.error.5=Offending pattern: gui.refinedstorage:crafting_preview.error.5=Offending pattern:
gui.refinedstorage:crafting_preview.force_start=Press CTRL + SHIFT to start anyway gui.refinedstorage:crafting_preview.force_start=Press CTRL + SHIFT to ignore
gui.refinedstorage:reader=Reader gui.refinedstorage:reader=Reader
gui.refinedstorage:writer=Writer gui.refinedstorage:writer=Writer
gui.refinedstorage:security_manager=Security Manager gui.refinedstorage:security_manager=Security Manager