Skip to content

Commit

Permalink
Added config for timeout length for slower systems
Browse files Browse the repository at this point in the history
  • Loading branch information
jediminer543 committed Aug 16, 2020
1 parent a20938c commit 96821c7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'

version = '0.12.22'
version = '0.12.23'
group = 'org.jmt.mcmt' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'jmt_mcmt-1.16.1'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static void chunkLoadDrive(ServerChunkProvider.ChunkExecutor executor, Bo
break;
}
// Nothing more to execute
if (failcount++ < 5000) {
if (failcount++ < GeneralConfig.timeoutCount) {
Thread.yield();
LockSupport.parkNanos("THE END IS ~~NEVER~~ LOADING", 100000L);
} else {
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/org/jmt/mcmt/config/GeneralConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.common.ForgeConfigSpec.BooleanValue;
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
import net.minecraftforge.common.ForgeConfigSpec.IntValue;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.config.ModConfig;
Expand Down Expand Up @@ -56,6 +57,7 @@ public class GeneralConfig {
public static boolean disableChunkProvider;
public static boolean enableChunkTimeout;
public static boolean enableTimeoutRegen;
public static int timeoutCount;

public static final GeneralConfigTemplate GENERAL;
public static final ForgeConfigSpec GENERAL_SPEC;
Expand Down Expand Up @@ -87,6 +89,7 @@ public static void bakeConfig() {

enableChunkTimeout = GENERAL.enableChunkTimeout.get();
enableTimeoutRegen = GENERAL.enableTimeoutRegen.get();
timeoutCount = GENERAL.timeoutCount.get();

teWhiteList = ConcurrentHashMap.newKeySet();//new HashSet<Class<?>>();
teUnfoundWhiteList = new ArrayList<String>();
Expand Down Expand Up @@ -124,6 +127,7 @@ public static void saveConfig() {

GENERAL.enableChunkTimeout.set(enableChunkTimeout);
GENERAL.enableTimeoutRegen.set(enableTimeoutRegen);
GENERAL.timeoutCount.set(timeoutCount);

GENERAL.teWhiteList.get().clear();
GENERAL.teWhiteList.get().addAll(teUnfoundWhiteList);
Expand Down Expand Up @@ -154,6 +158,7 @@ public static class GeneralConfigTemplate {
public final BooleanValue disableChunkProvider;
public final BooleanValue enableChunkTimeout;
public final BooleanValue enableTimeoutRegen;
public final IntValue timeoutCount;

public GeneralConfigTemplate(ForgeConfigSpec.Builder builder) {
disabled = builder
Expand Down Expand Up @@ -203,6 +208,10 @@ public GeneralConfigTemplate(ForgeConfigSpec.Builder builder) {
enableTimeoutRegen = builder
.comment("Attempts to re-load timed out chunks; Seems to work")
.define("enableTimeoutReload", false);
timeoutCount = builder
.comment("Ammount of workless iterations to wait before declaring a chunk load attempt as timed out\n"
+"This is in ~100us itterations (plus minus yield time) so timeout >= timeoutCount*100us")
.defineInRange("timeoutCount", 5000, 500, 500000);
}

}
Expand Down

0 comments on commit 96821c7

Please sign in to comment.