diff --git a/loader/src/main/java/net/neoforged/fml/config/ModConfig.java b/loader/src/main/java/net/neoforged/fml/config/ModConfig.java index bcb08c051..5e92ef7e4 100644 --- a/loader/src/main/java/net/neoforged/fml/config/ModConfig.java +++ b/loader/src/main/java/net/neoforged/fml/config/ModConfig.java @@ -5,6 +5,7 @@ package net.neoforged.fml.config; +import com.electronwill.nightconfig.core.CommentedConfig; import java.nio.file.Path; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; @@ -51,6 +52,15 @@ public String getModId() { return container.getModId(); } + /** + * Retrieve the currently loaded config, for direct manipulation of the underlying {@link CommentedConfig}. + * Note that the config will change on reloads, and will be {@code null} when the config is not loaded. + */ + @Nullable + public IConfigSpec.ILoadedConfig getLoadedConfig() { + return loadedConfig; + } + // TODO: remove from public API? public Path getFullPath() { if (this.loadedConfig != null && loadedConfig.path() != null) { diff --git a/loader/src/main/java/net/neoforged/fml/config/ModConfigs.java b/loader/src/main/java/net/neoforged/fml/config/ModConfigs.java index 30b40c49c..f0d7afffd 100644 --- a/loader/src/main/java/net/neoforged/fml/config/ModConfigs.java +++ b/loader/src/main/java/net/neoforged/fml/config/ModConfigs.java @@ -17,6 +17,10 @@ * Configs are registered via {@link ModContainer#registerConfig(ModConfig.Type, IConfigSpec)}. */ public final class ModConfigs { + public static List getModConfigs(String modId) { + return Collections.unmodifiableList(ConfigTracker.INSTANCE.configsByMod.getOrDefault(modId, List.of())); + } + public static List getConfigFileNames(String modId, ModConfig.Type type) { var config = ConfigTracker.INSTANCE.configsByMod.getOrDefault(modId, List.of()); synchronized (config) { // Synchronized list: requires explicit synchronization for stream