Minor fixes
This commit is contained in:
@@ -20,6 +20,10 @@ public interface IProcessable {
|
|||||||
*/
|
*/
|
||||||
Deque<ItemStack> getToInsert();
|
Deque<ItemStack> getToInsert();
|
||||||
|
|
||||||
|
void setStartedProcessing();
|
||||||
|
|
||||||
|
boolean isStartedProcessing();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if we received all outputs, false otherwise
|
* @return true if we received all outputs, false otherwise
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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);
|
return new CraftingTask(network, stack, pattern, quantity);
|
||||||
|
|||||||
@@ -99,12 +99,9 @@ public class CraftingTask implements ICraftingTask {
|
|||||||
int compare = DEFAULT_COMPARE | (pattern.isOredict() ? IComparer.COMPARE_OREDICT : 0);
|
int compare = DEFAULT_COMPARE | (pattern.isOredict() ? IComparer.COMPARE_OREDICT : 0);
|
||||||
ItemStack[] took = new ItemStack[9];
|
ItemStack[] took = new ItemStack[9];
|
||||||
|
|
||||||
if (pattern.isProcessing()) {
|
|
||||||
toProcess.add(new Processable(pattern));
|
|
||||||
}
|
|
||||||
|
|
||||||
IItemStackList inputs = API.instance().createItemStackList();
|
IItemStackList inputs = API.instance().createItemStackList();
|
||||||
IItemStackList actualInputs = API.instance().createItemStackList();
|
IItemStackList actualInputs = API.instance().createItemStackList();
|
||||||
|
|
||||||
for (ItemStack input : pattern.getInputs()) {
|
for (ItemStack input : pattern.getInputs()) {
|
||||||
if (input != null) {
|
if (input != null) {
|
||||||
inputs.add(input.copy());
|
inputs.add(input.copy());
|
||||||
@@ -131,6 +128,7 @@ public class CraftingTask implements ICraftingTask {
|
|||||||
networkList.remove(inputStack, true);
|
networkList.remove(inputStack, true);
|
||||||
} else {
|
} else {
|
||||||
ICraftingPattern inputPattern = network.getPattern(input, compare);
|
ICraftingPattern inputPattern = network.getPattern(input, compare);
|
||||||
|
|
||||||
if (inputPattern != null) {
|
if (inputPattern != null) {
|
||||||
int craftQuantity = Math.min(inputPattern.getQuantityPerRequest(input, compare), input.stackSize);
|
int craftQuantity = Math.min(inputPattern.getQuantityPerRequest(input, compare), input.stackSize);
|
||||||
ItemStack inputCrafted = ItemHandlerHelper.copyStackWithSize(input, craftQuantity);
|
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()) {
|
if (missing.isEmpty()) {
|
||||||
for (int i = 0; i < pattern.getInputs().size(); i++) {
|
for (int i = 0; i < pattern.getInputs().size(); i++) {
|
||||||
ItemStack input = pattern.getInputs().get(i);
|
ItemStack input = pattern.getInputs().get(i);
|
||||||
@@ -235,6 +237,8 @@ public class CraftingTask implements ICraftingTask {
|
|||||||
IItemHandler inventory = processable.getPattern().getContainer().getFacingInventory();
|
IItemHandler inventory = processable.getPattern().getContainer().getFacingInventory();
|
||||||
|
|
||||||
if (inventory != null && !processable.getToInsert().isEmpty() && canProcess(processable)) {
|
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));
|
ItemStack toInsert = network.extractItem(processable.getToInsert().peek(), 1, DEFAULT_COMPARE | (pattern.isOredict() ? IComparer.COMPARE_OREDICT : 0));
|
||||||
|
|
||||||
if (ItemHandlerHelper.insertItem(inventory, toInsert, true) == null) {
|
if (ItemHandlerHelper.insertItem(inventory, toInsert, true) == null) {
|
||||||
@@ -298,7 +302,7 @@ public class CraftingTask implements ICraftingTask {
|
|||||||
private boolean canProcess(IProcessable processable) {
|
private boolean canProcess(IProcessable processable) {
|
||||||
for (ICraftingTask otherTask : network.getCraftingTasks()) {
|
for (ICraftingTask otherTask : network.getCraftingTasks()) {
|
||||||
for (IProcessable otherProcessable : otherTask.getToProcess()) {
|
for (IProcessable otherProcessable : otherTask.getToProcess()) {
|
||||||
if (otherProcessable != processable) {
|
if (otherProcessable != processable && !otherProcessable.hasReceivedOutputs() && otherProcessable.isStartedProcessing()) {
|
||||||
if (!isPatternsEqual(processable.getPattern(), otherProcessable.getPattern())) {
|
if (!isPatternsEqual(processable.getPattern(), otherProcessable.getPattern())) {
|
||||||
if (processable.getPattern().getContainer().getFacingTile().getPos().equals(otherProcessable.getPattern().getContainer().getFacingTile().getPos())) {
|
if (processable.getPattern().getContainer().getFacingTile().getPos().equals(otherProcessable.getPattern().getContainer().getFacingTile().getPos())) {
|
||||||
return false;
|
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));
|
elements.add(new CraftingMonitorElementText("gui.refinedstorage:crafting_monitor.items_processing", 16));
|
||||||
|
|
||||||
for (IProcessable processable : toProcess) {
|
for (IProcessable processable : toProcess) {
|
||||||
|
if (processable.hasReceivedOutputs()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < processable.getPattern().getOutputs().size(); ++i) {
|
for (int i = 0; i < processable.getPattern().getOutputs().size(); ++i) {
|
||||||
if (!processable.hasReceivedOutput(i)) {
|
if (!processable.hasReceivedOutput(i)) {
|
||||||
elements.add(new CraftingMonitorElementItemRender(
|
elements.add(new CraftingMonitorElementItemRender(
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ public class Processable implements IProcessable {
|
|||||||
private ICraftingPattern pattern;
|
private ICraftingPattern pattern;
|
||||||
private Deque<ItemStack> toInsert = new ArrayDeque<>();
|
private Deque<ItemStack> toInsert = new ArrayDeque<>();
|
||||||
private boolean satisfied[];
|
private boolean satisfied[];
|
||||||
|
private boolean startedProcessing;
|
||||||
|
|
||||||
public Processable(ICraftingPattern pattern) {
|
public Processable(ICraftingPattern pattern) {
|
||||||
this.pattern = pattern;
|
this.pattern = pattern;
|
||||||
@@ -69,6 +70,16 @@ public class Processable implements IProcessable {
|
|||||||
return toInsert;
|
return toInsert;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setStartedProcessing() {
|
||||||
|
startedProcessing = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isStartedProcessing() {
|
||||||
|
return startedProcessing;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasReceivedOutputs() {
|
public boolean hasReceivedOutputs() {
|
||||||
for (boolean item : satisfied) {
|
for (boolean item : satisfied) {
|
||||||
|
|||||||
Reference in New Issue
Block a user