Added a config option to configure the autocrafting calculation timeout in milliseconds. Fixes #1964
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
### 1.6.6
|
### 1.6.6
|
||||||
- Added new Crafter modes: ignore redstone signal, redstone signal unlocks autocrafting, redstone signal locks autocrafting and redstone pulse inserts next set (replacement for blocking mode) (raoulvdberge)
|
- Added new Crafter modes: ignore redstone signal, redstone signal unlocks autocrafting, redstone signal locks autocrafting and redstone pulse inserts next set (replacement for blocking mode) (raoulvdberge)
|
||||||
|
- Added a config option to configure the autocrafting calculation timeout in milliseconds (raoulvdberge)
|
||||||
- Fixed an autocrafting bug where it crashed when external inventories couldn't be filled (raoulvdberge)
|
- Fixed an autocrafting bug where it crashed when external inventories couldn't be filled (raoulvdberge)
|
||||||
- Fixed a duplication bug with a disconnected Crafting Grid (raoulvdberge)
|
- Fixed a duplication bug with a disconnected Crafting Grid (raoulvdberge)
|
||||||
|
|
||||||
|
|||||||
@@ -119,6 +119,10 @@ public class RSConfig {
|
|||||||
public boolean hideCovers;
|
public boolean hideCovers;
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
//region Autocrafting
|
||||||
|
public int calculationTimeoutMs;
|
||||||
|
//endregion
|
||||||
|
|
||||||
//region Categories
|
//region Categories
|
||||||
private static final String ENERGY = "energy";
|
private static final String ENERGY = "energy";
|
||||||
private static final String CONTROLLER = "controller";
|
private static final String CONTROLLER = "controller";
|
||||||
@@ -131,6 +135,7 @@ public class RSConfig {
|
|||||||
private static final String UPGRADES = "upgrades";
|
private static final String UPGRADES = "upgrades";
|
||||||
private static final String READER_WRITER = "readerWriter";
|
private static final String READER_WRITER = "readerWriter";
|
||||||
private static final String COVERS = "covers";
|
private static final String COVERS = "covers";
|
||||||
|
private static final String AUTOCRAFTING = "autocrafting";
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
public RSConfig(@Nullable RSConfig originalClientVersion, File configFile) {
|
public RSConfig(@Nullable RSConfig originalClientVersion, File configFile) {
|
||||||
@@ -266,6 +271,10 @@ public class RSConfig {
|
|||||||
hideCovers = config.getBoolean("hideCovers", COVERS, false, "Whether to hide covers in the creative mode tabs and JEI");
|
hideCovers = config.getBoolean("hideCovers", COVERS, false, "Whether to hide covers in the creative mode tabs and JEI");
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
//region Autocrafting
|
||||||
|
calculationTimeoutMs = config.getInt("calculationTimeoutMs", AUTOCRAFTING, 5000, 5000, Integer.MAX_VALUE, "The autocrafting calculation timeout in milliseconds, tasks taking longer than this to calculate (NOT execute) are cancelled to avoid server strain");
|
||||||
|
//endregion
|
||||||
|
|
||||||
if (config.hasChanged()) {
|
if (config.hasChanged()) {
|
||||||
config.save();
|
config.save();
|
||||||
}
|
}
|
||||||
@@ -286,6 +295,7 @@ public class RSConfig {
|
|||||||
list.add(new ConfigElement(config.getCategory(PORTABLE_GRID)));
|
list.add(new ConfigElement(config.getCategory(PORTABLE_GRID)));
|
||||||
list.add(new ConfigElement(config.getCategory(READER_WRITER)));
|
list.add(new ConfigElement(config.getCategory(READER_WRITER)));
|
||||||
list.add(new ConfigElement(config.getCategory(COVERS)));
|
list.add(new ConfigElement(config.getCategory(COVERS)));
|
||||||
|
list.add(new ConfigElement(config.getCategory(AUTOCRAFTING)));
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.apiimpl.autocrafting.task;
|
package com.raoulvdberge.refinedstorage.apiimpl.autocrafting.task;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RS;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.*;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.*;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElement;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElement;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElementList;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElementList;
|
||||||
@@ -57,8 +58,6 @@ public class CraftingTask implements ICraftingTask {
|
|||||||
private static final String NBT_PATTERN_STACK = "Stack";
|
private static final String NBT_PATTERN_STACK = "Stack";
|
||||||
private static final String NBT_PATTERN_CONTAINER_POS = "ContainerPos";
|
private static final String NBT_PATTERN_CONTAINER_POS = "ContainerPos";
|
||||||
|
|
||||||
private static final long CALCULATION_TIMEOUT_MS = 5000;
|
|
||||||
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
|
||||||
private INetwork network;
|
private INetwork network;
|
||||||
@@ -283,7 +282,7 @@ public class CraftingTask implements ICraftingTask {
|
|||||||
ICraftingPattern pattern,
|
ICraftingPattern pattern,
|
||||||
boolean root) {
|
boolean root) {
|
||||||
|
|
||||||
if (System.currentTimeMillis() - calculationStarted > CALCULATION_TIMEOUT_MS) {
|
if (System.currentTimeMillis() - calculationStarted > RS.INSTANCE.config.calculationTimeoutMs) {
|
||||||
return new CraftingTaskError(CraftingTaskErrorType.TOO_COMPLEX);
|
return new CraftingTaskError(CraftingTaskErrorType.TOO_COMPLEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user