Add Connector compatibility mode

This commit is contained in:
kltyton
2026-07-02 13:21:48 +08:00
parent b782f264cf
commit ca0eb25f47
4 changed files with 29 additions and 1 deletions
@@ -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;
}