Add Connector compatibility mode
This commit is contained in:
@@ -2,6 +2,7 @@ package com.ccr4ft3r.lightspeed;
|
||||
|
||||
import com.ccr4ft3r.lightspeed.cache.GlobalCache;
|
||||
import com.ccr4ft3r.lightspeed.config.LightspeedConfig;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
@@ -9,11 +10,14 @@ import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
import net.minecraftforge.fml.event.config.ModConfigEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mod(ModConstants.MOD_ID)
|
||||
public class Main {
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
private static boolean loggedConnectorCompatibilityMode;
|
||||
|
||||
public Main() {
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
@@ -29,12 +33,17 @@ public class Main {
|
||||
}
|
||||
|
||||
private void updateCacheFlags() {
|
||||
GlobalCache.shouldCacheWalkedPaths = true;
|
||||
GlobalCache.shouldCacheEmptyNamespaces = true;
|
||||
GlobalCache.shouldCacheMaterials = true;
|
||||
|
||||
try {
|
||||
GlobalCache.shouldAsyncPreloadPacks = LightspeedConfig.COMMON.asyncPreloadPacks.get();
|
||||
GlobalCache.shouldParallelizeResourcePackLookup = LightspeedConfig.COMMON.parallelResourceLookup.get();
|
||||
GlobalCache.parallelLookupMinPacks = LightspeedConfig.COMMON.parallelLookupMinPacks.get();
|
||||
GlobalCache.shouldCacheResourceExistence = LightspeedConfig.COMMON.cacheResourceExistence.get();
|
||||
GlobalCache.shouldIsolateModdedResourceReloadFailures = LightspeedConfig.COMMON.isolateModdedResourceReloadFailures.get();
|
||||
GlobalCache.shouldUseConnectorCompatibilityMode = LightspeedConfig.COMMON.connectorCompatibilityMode.get();
|
||||
GlobalCache.isolatedResourceReloadListenerPatterns = LightspeedConfig.COMMON.isolatedResourceReloadListenerPatterns.get()
|
||||
.stream()
|
||||
.map(String::valueOf)
|
||||
@@ -44,6 +53,19 @@ public class Main {
|
||||
GlobalCache.isolatedResourceReloadListenerPatterns = List.of("*");
|
||||
}
|
||||
|
||||
if (GlobalCache.shouldUseConnectorCompatibilityMode && ModList.get().isLoaded(ModConstants.CONNECTOR_ID)) {
|
||||
GlobalCache.shouldAsyncPreloadPacks = false;
|
||||
GlobalCache.shouldParallelizeResourcePackLookup = false;
|
||||
GlobalCache.shouldCacheWalkedPaths = false;
|
||||
GlobalCache.shouldCacheEmptyNamespaces = false;
|
||||
GlobalCache.shouldCacheResourceExistence = false;
|
||||
GlobalCache.shouldIsolateModdedResourceReloadFailures = false;
|
||||
if (!loggedConnectorCompatibilityMode) {
|
||||
LOGGER.warn("Lightspeed Sinytra Connector compatibility mode is active; resource-pack parallelism, path caches, and reload failure isolation are disabled");
|
||||
loggedConnectorCompatibilityMode = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (ModList.get().isLoaded(ModConstants.SOPHISTICATED_STORAGE_ID) && ModList.get().isLoaded(ModConstants.JSON_THINGS_ID)) {
|
||||
GlobalCache.shouldCacheWalkedPaths = false;
|
||||
}
|
||||
|
||||
@@ -7,4 +7,5 @@ public class ModConstants {
|
||||
public static final String SOPHISTICATED_STORAGE_ID = "sophisticatedstorage";
|
||||
public static final String MULTIBLOCKED_ID = "multiblocked";
|
||||
public static final String CREATE_ID = "create";
|
||||
}
|
||||
public static final String CONNECTOR_ID = "connectormod";
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ public class GlobalCache {
|
||||
public static volatile boolean shouldParallelizeResourcePackLookup = true;
|
||||
public static volatile int parallelLookupMinPacks = 4;
|
||||
public static volatile boolean shouldIsolateModdedResourceReloadFailures = true;
|
||||
public static volatile boolean shouldUseConnectorCompatibilityMode = true;
|
||||
public static volatile List<String> isolatedResourceReloadListenerPatterns = List.of("*");
|
||||
public static final Map<CharSequence, List<String>> SPLITTED_STRINGS_BY_SEQUENCE = Maps.newConcurrentMap();
|
||||
public static final Map<String, String> CANONICAL_PATH_PER_FILE = Maps.newConcurrentMap();
|
||||
|
||||
@@ -25,6 +25,7 @@ public final class LightspeedConfig {
|
||||
public final ForgeConfigSpec.BooleanValue cacheResourceExistence;
|
||||
public final ForgeConfigSpec.BooleanValue isolateModdedResourceReloadFailures;
|
||||
public final ForgeConfigSpec.ConfigValue<List<? extends String>> isolatedResourceReloadListenerPatterns;
|
||||
public final ForgeConfigSpec.BooleanValue connectorCompatibilityMode;
|
||||
|
||||
private Common(ForgeConfigSpec.Builder builder) {
|
||||
builder.push("startup");
|
||||
@@ -49,6 +50,9 @@ public final class LightspeedConfig {
|
||||
isolatedResourceReloadListenerPatterns = builder
|
||||
.comment("Class-name prefixes that may be isolated when resource reload fails. Use * for all non-core mod listeners.")
|
||||
.defineList("isolatedResourceReloadListenerPatterns", List.of("*"), value -> value instanceof String string && !string.isBlank());
|
||||
connectorCompatibilityMode = builder
|
||||
.comment("When Sinytra Connector is installed, avoid startup/resource optimizations that change Fabric resource reload or renderer lookup timing.")
|
||||
.define("connectorCompatibilityMode", true);
|
||||
builder.pop();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user