2023-03-11 13:45:46 +01:00
|
|
|
package com.ccr4ft3r.lightspeed;
|
|
|
|
|
|
|
|
|
|
import com.ccr4ft3r.lightspeed.cache.GlobalCache;
|
2026-07-01 21:25:53 +08:00
|
|
|
import com.ccr4ft3r.lightspeed.config.LightspeedConfig;
|
|
|
|
|
import net.minecraftforge.eventbus.api.IEventBus;
|
|
|
|
|
import net.minecraftforge.fml.ModLoadingContext;
|
2023-03-11 13:45:46 +01:00
|
|
|
import net.minecraftforge.fml.ModList;
|
|
|
|
|
import net.minecraftforge.fml.common.Mod;
|
2026-07-01 21:25:53 +08:00
|
|
|
import net.minecraftforge.fml.config.ModConfig;
|
|
|
|
|
import net.minecraftforge.fml.event.config.ModConfigEvent;
|
|
|
|
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
2025-11-21 12:14:49 +08:00
|
|
|
|
2023-03-11 13:45:46 +01:00
|
|
|
@Mod(ModConstants.MOD_ID)
|
|
|
|
|
public class Main {
|
|
|
|
|
|
|
|
|
|
public Main() {
|
2026-07-01 21:25:53 +08:00
|
|
|
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
|
|
|
|
modEventBus.addListener(this::onConfigEvent);
|
|
|
|
|
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, LightspeedConfig.SPEC);
|
2023-03-11 13:45:46 +01:00
|
|
|
updateCacheFlags();
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-01 21:25:53 +08:00
|
|
|
private void onConfigEvent(ModConfigEvent event) {
|
|
|
|
|
if (event.getConfig().getSpec() == LightspeedConfig.SPEC) {
|
|
|
|
|
updateCacheFlags();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-11 13:45:46 +01:00
|
|
|
private void updateCacheFlags() {
|
2026-07-01 21:25:53 +08:00
|
|
|
try {
|
|
|
|
|
GlobalCache.shouldAsyncPreloadPacks = LightspeedConfig.COMMON.asyncPreloadPacks.get();
|
|
|
|
|
GlobalCache.shouldParallelizeResourcePackLookup = LightspeedConfig.COMMON.parallelResourceLookup.get();
|
2026-07-02 05:34:51 +08:00
|
|
|
GlobalCache.parallelLookupMinPacks = LightspeedConfig.COMMON.parallelLookupMinPacks.get();
|
|
|
|
|
GlobalCache.shouldCacheResourceExistence = LightspeedConfig.COMMON.cacheResourceExistence.get();
|
2026-07-01 21:25:53 +08:00
|
|
|
GlobalCache.shouldIsolateModdedResourceReloadFailures = LightspeedConfig.COMMON.isolateModdedResourceReloadFailures.get();
|
|
|
|
|
GlobalCache.isolatedResourceReloadListenerPatterns = LightspeedConfig.COMMON.isolatedResourceReloadListenerPatterns.get()
|
|
|
|
|
.stream()
|
|
|
|
|
.map(String::valueOf)
|
|
|
|
|
.toList();
|
|
|
|
|
} catch (IllegalStateException ignored) {
|
|
|
|
|
// Forge has not attached the TOML yet; keep the default-on startup flags.
|
|
|
|
|
GlobalCache.isolatedResourceReloadListenerPatterns = List.of("*");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ModList.get().isLoaded(ModConstants.SOPHISTICATED_STORAGE_ID) && ModList.get().isLoaded(ModConstants.JSON_THINGS_ID)) {
|
|
|
|
|
GlobalCache.shouldCacheWalkedPaths = false;
|
|
|
|
|
}
|
2025-11-29 17:14:13 +08:00
|
|
|
if (ModList.get().isLoaded(ModConstants.MULTIBLOCKED_ID)) {
|
2023-05-11 18:38:45 +02:00
|
|
|
GlobalCache.shouldCacheMaterials = false;
|
2025-11-21 12:14:49 +08:00
|
|
|
}
|
2023-03-11 13:45:46 +01:00
|
|
|
}
|
2026-07-01 21:25:53 +08:00
|
|
|
}
|