diff --git a/src/main/java/org/cyclops/integratedtunnels/GeneralConfig.java b/src/main/java/org/cyclops/integratedtunnels/GeneralConfig.java index df2841be..523e0956 100644 --- a/src/main/java/org/cyclops/integratedtunnels/GeneralConfig.java +++ b/src/main/java/org/cyclops/integratedtunnels/GeneralConfig.java @@ -19,6 +19,8 @@ public class GeneralConfig extends DummyConfig { @ConfigurableProperty(category = "core", comment = "If the version checker should be enabled.") public static boolean versionChecker = true; + @ConfigurableProperty(category = "core", comment = "For how many ticks importers/exporters should fail to process before they can start sleeping.", configLocation = ModConfig.Type.SERVER) + public static int inventoryUnchangedTickCount = 3; @ConfigurableProperty(category = "core", comment = "How many ticks importers/exporters should sleep until checking targets again when they were previously unchanged.", configLocation = ModConfig.Type.SERVER) public static int inventoryUnchangedTickTimeout = 10; diff --git a/src/main/java/org/cyclops/integratedtunnels/core/ExtendedFakePlayer.java b/src/main/java/org/cyclops/integratedtunnels/core/ExtendedFakePlayer.java index 823658e4..dc1528ae 100644 --- a/src/main/java/org/cyclops/integratedtunnels/core/ExtendedFakePlayer.java +++ b/src/main/java/org/cyclops/integratedtunnels/core/ExtendedFakePlayer.java @@ -91,6 +91,6 @@ public void updateActiveHandSimulated() { @Override public void startSleeping(BlockPos blockPos) { - // Dp nothing + // Do nothing } } diff --git a/src/main/java/org/cyclops/integratedtunnels/core/TunnelHelpers.java b/src/main/java/org/cyclops/integratedtunnels/core/TunnelHelpers.java index 6b207561..bf29bea1 100644 --- a/src/main/java/org/cyclops/integratedtunnels/core/TunnelHelpers.java +++ b/src/main/java/org/cyclops/integratedtunnels/core/TunnelHelpers.java @@ -45,8 +45,8 @@ */ public class TunnelHelpers { - private static final Cache CACHE_INV_CHECKS = CacheBuilder.newBuilder() - .expireAfterWrite(GeneralConfig.inventoryUnchangedTickTimeout * (1000 / MinecraftHelpers.SECOND_IN_TICKS), + private static final Cache CACHE_INV_CHECKS = CacheBuilder.newBuilder() + .expireAfterWrite((GeneralConfig.inventoryUnchangedTickCount + GeneralConfig.inventoryUnchangedTickTimeout) * (1000 / MinecraftHelpers.SECOND_IN_TICKS), TimeUnit.MILLISECONDS).build(); /** @@ -149,7 +149,8 @@ public static T moveSingleStateOptimized(INetwork network, IPositionedAdd } // Don't do anything if we are sleeping for this connection - if (CACHE_INV_CHECKS.getIfPresent(connection) != null) { + Integer sleepCheck = CACHE_INV_CHECKS.getIfPresent(connection); + if (sleepCheck != null && sleepCheck >= GeneralConfig.inventoryUnchangedTickCount) { return matcher.getEmptyInstance(); } @@ -157,7 +158,9 @@ public static T moveSingleStateOptimized(INetwork network, IPositionedAdd T moved = moveSingle(source, sourceSlot, destination, destinationSlot, ingredientPredicate, movementPosition, false); if (matcher.isEmpty(moved)) { // Mark this connection as 'sleeping' if nothing was moved - CACHE_INV_CHECKS.put(connection, true); + CACHE_INV_CHECKS.put(connection, sleepCheck == null ? 1 : sleepCheck + 1); + } else if (sleepCheck != null) { + CACHE_INV_CHECKS.invalidate(connection); } // Schedule a new observation for the network, as its contents may have changed