Minor fixes

This commit is contained in:
Raoul Van den Berge
2016-10-19 15:42:39 +02:00
parent d27fd6af0e
commit 81c099f63c
4 changed files with 30 additions and 7 deletions

View File

@@ -20,6 +20,10 @@ public interface IProcessable {
*/
Deque<ItemStack> getToInsert();
void setStartedProcessing();
boolean isStartedProcessing();
/**
* @return true if we received all outputs, false otherwise
*/

View File

@@ -77,7 +77,7 @@ public class CraftingTaskFactory implements ICraftingTaskFactory {
}
}
return new CraftingTask(network, stack, pattern, quantity, toProcess, toTake, toTakeFluids, new ArrayDeque<ItemStack>(toInsert), took, tookFluids);
return new CraftingTask(network, stack, pattern, quantity, toProcess, toTake, toTakeFluids, new ArrayDeque<>(toInsert), took, tookFluids);
}
return new CraftingTask(network, stack, pattern, quantity);

View File

@@ -99,12 +99,9 @@ public class CraftingTask implements ICraftingTask {
int compare = DEFAULT_COMPARE | (pattern.isOredict() ? IComparer.COMPARE_OREDICT : 0);
ItemStack[] took = new ItemStack[9];
if (pattern.isProcessing()) {
toProcess.add(new Processable(pattern));
}
IItemStackList inputs = API.instance().createItemStackList();
IItemStackList actualInputs = API.instance().createItemStackList();
for (ItemStack input : pattern.getInputs()) {
if (input != null) {
inputs.add(input.copy());
@@ -131,6 +128,7 @@ public class CraftingTask implements ICraftingTask {
networkList.remove(inputStack, true);
} else {
ICraftingPattern inputPattern = network.getPattern(input, compare);
if (inputPattern != null) {
int craftQuantity = Math.min(inputPattern.getQuantityPerRequest(input, compare), input.stackSize);
ItemStack inputCrafted = ItemHandlerHelper.copyStackWithSize(input, craftQuantity);
@@ -152,6 +150,10 @@ public class CraftingTask implements ICraftingTask {
}
}
if (pattern.isProcessing()) {
toProcess.add(new Processable(pattern));
}
if (missing.isEmpty()) {
for (int i = 0; i < pattern.getInputs().size(); i++) {
ItemStack input = pattern.getInputs().get(i);
@@ -235,6 +237,8 @@ public class CraftingTask implements ICraftingTask {
IItemHandler inventory = processable.getPattern().getContainer().getFacingInventory();
if (inventory != null && !processable.getToInsert().isEmpty() && canProcess(processable)) {
processable.setStartedProcessing();
ItemStack toInsert = network.extractItem(processable.getToInsert().peek(), 1, DEFAULT_COMPARE | (pattern.isOredict() ? IComparer.COMPARE_OREDICT : 0));
if (ItemHandlerHelper.insertItem(inventory, toInsert, true) == null) {
@@ -298,7 +302,7 @@ public class CraftingTask implements ICraftingTask {
private boolean canProcess(IProcessable processable) {
for (ICraftingTask otherTask : network.getCraftingTasks()) {
for (IProcessable otherProcessable : otherTask.getToProcess()) {
if (otherProcessable != processable) {
if (otherProcessable != processable && !otherProcessable.hasReceivedOutputs() && otherProcessable.isStartedProcessing()) {
if (!isPatternsEqual(processable.getPattern(), otherProcessable.getPattern())) {
if (processable.getPattern().getContainer().getFacingTile().getPos().equals(otherProcessable.getPattern().getContainer().getFacingTile().getPos())) {
return false;
@@ -428,10 +432,14 @@ public class CraftingTask implements ICraftingTask {
);
}
if (!hasProcessedItems()) {
if (toTake.isEmpty() && !hasProcessedItems()) {
elements.add(new CraftingMonitorElementText("gui.refinedstorage:crafting_monitor.items_processing", 16));
for (IProcessable processable : toProcess) {
if (processable.hasReceivedOutputs()) {
continue;
}
for (int i = 0; i < processable.getPattern().getOutputs().size(); ++i) {
if (!processable.hasReceivedOutput(i)) {
elements.add(new CraftingMonitorElementItemRender(

View File

@@ -20,6 +20,7 @@ public class Processable implements IProcessable {
private ICraftingPattern pattern;
private Deque<ItemStack> toInsert = new ArrayDeque<>();
private boolean satisfied[];
private boolean startedProcessing;
public Processable(ICraftingPattern pattern) {
this.pattern = pattern;
@@ -69,6 +70,16 @@ public class Processable implements IProcessable {
return toInsert;
}
@Override
public void setStartedProcessing() {
startedProcessing = true;
}
@Override
public boolean isStartedProcessing() {
return startedProcessing;
}
@Override
public boolean hasReceivedOutputs() {
for (boolean item : satisfied) {