Skip to content

Initialization and Platform Integration

JohnSmith474 edited this page Jun 12, 2026 · 8 revisions

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.

Dependency Management

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]"
}

Fabric Implementation

Path initialization executes within the primary mod entrypoint implementing ModInitializer. The target directory is resolved via FabricLoader.

package com.example.mod;

import net.fabricmc.api.ModInitializer;
import net.fabricmc.loader.api.FabricLoader;

public class ExampleMod implements ModInitializer {
    @Override
    public void onInitialize() {
        ExampleConfig.MANAGER.init(FabricLoader.getInstance().getConfigDir());
    }
}

Graphical interface generation requires a discrete ModMenu implementation using the ModMenuApi endpoint.

package com.example.mod.client;

import com.example.mod.ExampleConfig;
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;

public class ModMenuIntegration implements ModMenuApi {
    @Override
    public ConfigScreenFactory<?> getModConfigScreenFactory() {
        return ExampleConfig.MANAGER::createScreen;
    }
}

Forge Implementation

Path initialization executes within the primary @Mod class constructor. The target directory is resolved via FMLPaths. GUI integration binds to ConfigScreenHandler.ConfigScreenFactory strictly on the client distribution.

package com.example.mod;

import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.ConfigScreenHandler;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.loading.FMLEnvironment;
import net.minecraftforge.fml.loading.FMLPaths;

@Mod(Constants.MOD_ID)
public class ExampleMod {
    public ExampleMod() {
        ExampleConfig.MANAGER.init(FMLPaths.CONFIGDIR.get());

        if (FMLEnvironment.dist == Dist.CLIENT) {
            ModLoadingContext.get().registerExtensionPoint(
                    ConfigScreenHandler.ConfigScreenFactory.class,
                    () -> new ConfigScreenHandler.ConfigScreenFactory((minecraft, parentScreen) ->
                            ExampleConfig.MANAGER.createScreen(parentScreen)
                    )
            );
        }
    }
}

NeoForge Implementation

Path initialization executes within the primary @Mod class constructor. NeoForge utilizes the injected ModContainer to register the IConfigScreenFactory extension point strictly on the client distribution.

package com.example.mod;

import net.neoforged.api.distmarker.Dist;
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.loading.FMLEnvironment;
import net.neoforged.fml.loading.FMLPaths;
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;

@Mod(Constants.MOD_ID)
public class ExampleMod {
    public ExampleMod(ModContainer modContainer) {
        ExampleConfig.MANAGER.init(FMLPaths.CONFIGDIR.get());

        if (FMLEnvironment.dist == Dist.CLIENT) {
            modContainer.registerExtensionPoint(IConfigScreenFactory.class, (minecraft, parentScreen) ->
                    ExampleConfig.MANAGER.createScreen(parentScreen)
            );
        }
    }
}

Clone this wiki locally