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