You can no longer start a crafting task if it has missing items or fluids.
This commit is contained in:
@@ -103,6 +103,18 @@ public interface ICraftingTask {
|
||||
*/
|
||||
IStackList<ItemStack> getMissing();
|
||||
|
||||
/**
|
||||
* @return the missing fluids
|
||||
*/
|
||||
IStackList<FluidStack> getMissingFluids();
|
||||
|
||||
/**
|
||||
* @return true if any items or fluids are missing, false otherwise
|
||||
*/
|
||||
default boolean hasMissing() {
|
||||
return !getMissing().isEmpty() || !getMissingFluids().isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id of this task
|
||||
*/
|
||||
|
||||
@@ -246,7 +246,7 @@ public class CraftingManager implements ICraftingManager {
|
||||
if (task != null) {
|
||||
ICraftingTaskError error = task.calculate();
|
||||
|
||||
if (error == null && task.getMissing().isEmpty()) {
|
||||
if (error == null && !task.hasMissing()) {
|
||||
this.add(task);
|
||||
|
||||
return task;
|
||||
@@ -282,7 +282,7 @@ public class CraftingManager implements ICraftingManager {
|
||||
if (task != null) {
|
||||
ICraftingTaskError error = task.calculate();
|
||||
|
||||
if (error == null && task.getMissing().isEmpty()) {
|
||||
if (error == null && !task.hasMissing()) {
|
||||
this.add(task);
|
||||
|
||||
return task;
|
||||
|
||||
@@ -788,6 +788,10 @@ public class CraftingTask implements ICraftingTask {
|
||||
|
||||
@Override
|
||||
public boolean update() {
|
||||
if (!missing.isEmpty() || !missingFluids.isEmpty()) {
|
||||
throw new IllegalStateException("Crafting task with missing items or fluids cannot execute");
|
||||
}
|
||||
|
||||
if (executionStarted == -1) {
|
||||
executionStarted = System.currentTimeMillis();
|
||||
}
|
||||
@@ -1191,6 +1195,11 @@ public class CraftingTask implements ICraftingTask {
|
||||
return missing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStackList<FluidStack> getMissingFluids() {
|
||||
return missingFluids;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getId() {
|
||||
return id;
|
||||
|
||||
@@ -153,7 +153,7 @@ public class FluidGridHandler implements IFluidGridHandler {
|
||||
|
||||
if (error != null) {
|
||||
RS.INSTANCE.network.sendTo(new MessageGridCraftingPreviewResponse(Collections.singletonList(new CraftingPreviewElementError(error.getType(), error.getRecursedPattern() == null ? ItemStack.EMPTY : error.getRecursedPattern().getStack())), hash, quantity, true), player);
|
||||
} else if (noPreview && task.getMissing().isEmpty()) {
|
||||
} else if (noPreview && !task.hasMissing()) {
|
||||
network.getCraftingManager().add(task);
|
||||
|
||||
RS.INSTANCE.network.sendTo(new MessageGridCraftingStartResponse(), player);
|
||||
@@ -195,7 +195,7 @@ public class FluidGridHandler implements IFluidGridHandler {
|
||||
}
|
||||
|
||||
ICraftingTaskError error = task.calculate();
|
||||
if (error == null) {
|
||||
if (error == null && !task.hasMissing()) {
|
||||
network.getCraftingManager().add(task);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ public class ItemGridHandler implements IItemGridHandler {
|
||||
|
||||
if (error != null) {
|
||||
RS.INSTANCE.network.sendTo(new MessageGridCraftingPreviewResponse(Collections.singletonList(new CraftingPreviewElementError(error.getType(), error.getRecursedPattern() == null ? ItemStack.EMPTY : error.getRecursedPattern().getStack())), hash, quantity, false), player);
|
||||
} else if (noPreview && task.getMissing().isEmpty()) {
|
||||
} else if (noPreview && !task.hasMissing()) {
|
||||
network.getCraftingManager().add(task);
|
||||
|
||||
RS.INSTANCE.network.sendTo(new MessageGridCraftingStartResponse(), player);
|
||||
@@ -239,7 +239,7 @@ public class ItemGridHandler implements IItemGridHandler {
|
||||
}
|
||||
|
||||
ICraftingTaskError error = task.calculate();
|
||||
if (error == null) {
|
||||
if (error == null && !task.hasMissing()) {
|
||||
network.getCraftingManager().add(task);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,10 +95,6 @@ public class GuiCraftingPreview extends GuiBase {
|
||||
scrollbar.setEnabled(getRows() > VISIBLE_ROWS);
|
||||
scrollbar.setMaxOffset(getRows() - VISIBLE_ROWS);
|
||||
}
|
||||
|
||||
if (startButton != null && !startButton.enabled && isCtrlKeyDown() && isShiftKeyDown() && getErrorType() == null) {
|
||||
startButton.enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -210,10 +206,6 @@ public class GuiCraftingPreview extends GuiBase {
|
||||
|
||||
slot++;
|
||||
}
|
||||
|
||||
if (!startButton.enabled && inBounds(startButton.x - guiLeft, startButton.y - guiTop, startButton.width, startButton.height, mouseX, mouseY)) {
|
||||
drawTooltip(mouseX, mouseY, t("gui.refinedstorage:crafting_preview.force_start"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user