-
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]"
}To keep your architecture clean and maintainable, you should define your ConfigManager and all of your configuration properties in a single, common class. This acts as your source of truth and prevents duplicate code across different mod loaders.
Create a class named ExampleConfig (or similar) in your 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 your common class is set up, you need to 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());
}
}