Don't start task with missing items
This commit is contained in:
@@ -106,6 +106,11 @@ public interface ICraftingTask {
|
|||||||
*/
|
*/
|
||||||
boolean isValid();
|
boolean isValid();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return whether this crafting task has missing items
|
||||||
|
*/
|
||||||
|
boolean hasMissing();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link ICraftingTask#calculate()} must be run before this!
|
* {@link ICraftingTask#calculate()} must be run before this!
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -185,11 +185,12 @@ public interface INetworkMaster {
|
|||||||
|
|
||||||
task.calculate();
|
task.calculate();
|
||||||
|
|
||||||
// @TODO: Only schedule when there are no items missing?
|
if (!task.hasMissing()) {
|
||||||
addCraftingTask(task);
|
addCraftingTask(task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a grid update packet with all the items to all clients that are watching a grid connected to this network.
|
* Sends a grid update packet with all the items to all clients that are watching a grid connected to this network.
|
||||||
|
|||||||
@@ -474,6 +474,11 @@ public class CraftingTask implements ICraftingTask {
|
|||||||
return !recurseFound;
|
return !recurseFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasMissing() {
|
||||||
|
return !missing.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ICraftingPreviewElement> getPreviewStacks() {
|
public List<ICraftingPreviewElement> getPreviewStacks() {
|
||||||
if (!isValid()) {
|
if (!isValid()) {
|
||||||
|
|||||||
@@ -145,10 +145,14 @@ public class ItemGridHandler implements IItemGridHandler {
|
|||||||
|
|
||||||
if (stack != null) {
|
if (stack != null) {
|
||||||
ICraftingTask task = new CraftingTask(network, stack, network.getPattern(stack), quantity);
|
ICraftingTask task = new CraftingTask(network, stack, network.getPattern(stack), quantity);
|
||||||
|
|
||||||
task.calculate();
|
task.calculate();
|
||||||
|
|
||||||
|
if (!task.hasMissing()) {
|
||||||
network.addCraftingTask(task);
|
network.addCraftingTask(task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCraftingCancelRequested(int id) {
|
public void onCraftingCancelRequested(int id) {
|
||||||
|
|||||||
Reference in New Issue
Block a user