-
Notifications
You must be signed in to change notification settings - Fork 0
Initialization and Platform Integration
Config Overhauled requires explicit path resolution during the primary boot sequence of the host environment. Client-side graphical interface generation mandates platform-specific screen factory registration.
Add the Modrinth Maven repository and the library dependency to build.gradle. Replace [VERSION] with the target release version.
repositories {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
}
dependencies {
modImplementation "maven.modrinth:configoverhauled:[VERSION]"
}This project depends on NightConfig. In order for fabric projects to resolve NightConfig, add the following two dependencies:
dependencies {
// ...
// Explicitly add Night Config for the development environment runtime
implementation "com.electronwill.night-config:toml:3.8.3"
implementation "com.electronwill.night-config:core:3.8.3"
}This dependency exclusively resolves NightConfig within the local build environment and does not bundle the library into the compiled modification.
To keep the architecture clean and maintainable, define the ConfigManager and all configuration properties in a single, common class. This acts as the single source of truth and prevents duplicate code across different mod loaders.
Create a class named ExampleConfig (or similar) in the common codebase:
package com.example.mod.config;
import johnsmith.configoverhauled.api.ConfigManager;
import johnsmith.configoverhauled.api.registry.ConfigRegistry;
import org.slf4j.LoggerFactory;
public class ExampleConfig {
// Instantiate the manager once for your entire mod
public static final ConfigManager CONFIG = ConfigRegistry.getOrCreateManager("example_mod");
}Once the common class is set up, call ConfigManager::init and pass it the platform's default configuration directory.
import com.example.mod.config.ExampleConfig;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.loader.api.FabricLoader;
public class MyModFabric implements ModInitializer {
@Override
public void onInitialize() {
// Initialize the directory and load Client/Global scopes
ExampleConfig.CONFIG.init(FabricLoader.getInstance().getConfigDir());
}
}import com.example.mod.config.ExampleConfig;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.loading.FMLPaths;
@Mod(Constants.MOD_ID)
public class ExampleMod {
public ExampleMod() {
// Initialize the directory and load Client/Global scopes
ExampleConfig.MANAGER.init(FMLPaths.CONFIGDIR.get());
}
}import com.example.mod.config.ExampleConfig;
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.loading.FMLPaths;
@Mod(Constants.MOD_ID)
public class ExampleMod {
public ExampleMod(ModContainer modContainer) {
// Initialize the directory and load Client/Global scopes
ExampleConfig.MANAGER.init(FMLPaths.CONFIGDIR.get());
}
}