-
Notifications
You must be signed in to change notification settings - Fork 0
Better Config System
Anoop Singh edited this page Nov 10, 2025
·
4 revisions
BetterLib provides an easy-to-use and dynamic configuration system for Minecraft mods built with NeoForge or Forge. It allows developers to define config fields using annotations, automatically generate GUI screens, and handle file saving/loading — all with minimal boilerplate code.
- 🧱 Annotation-based config definition
Use
@Configand@ConfigEntryto mark config classes and fields. - ⚙️ Automatic file saving/loading Config data is automatically serialized to and from JSON.
- 🪟 In-game GUI editor A full customizable GUI screen lets players easily modify config values.
- 🔄 Live updates Changes are saved instantly and can trigger callbacks if needed.
package com.reggarf.mods.better_lib.example;
import com.reggarf.mods.better_lib.config.annotation.Config;
import com.reggarf.mods.better_lib.config.annotation.ConfigEntry;
@Config(fileName = "Demo_config")
public class DemoConfig {
@ConfigEntry(category = "general", name = "Enable Feature")
public boolean enableFeature = true;
@ConfigEntry(category = "visual", name = "Render Distance")
public int renderDistance = 12;
@ConfigEntry(category = "performance", name = "Max FPS")
public int maxFps = 120;
}This defines your mod’s config fields. Each field will automatically appear in the config GUI with proper labels and categories.
@Mod(Demo.MODID)
public class Demo {
public static final String MODID = "Demo";
public static DemoConfig CONFIG;
public Better_lib(IEventBus modEventBus, ModContainer modContainer) {
NeoForge.EVENT_BUS.register(this);
// Register your config
CONFIG = BetterConfigManager.register(DemoConfig.class);
// Register config GUI
modEventBus.addListener(this::onClientSetup);
}
//config screen register
@EventBusSubscriber(modid = MODID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public static class ClientModEvents {
@SubscribeEvent
public static void onClientSetup(FMLClientSetupEvent event) {
event.enqueueWork(() -> {
ConfigScreenHandler.register("better_lib", parent ->
BetterConfigScreenFactory.from(DemoConfig.class, CONFIG, parent)
);
});
}
}
}✅ This automatically:
- Loads
Demo_config.jsonfrom the config folder. - Registers an editable GUI screen accessible via ModMenu or your own buttons.
You can open the config GUI manually anywhere in your mod:
Minecraft.getInstance().setScreen(
BetterConfigScreenFactory.from(ExampleConfig.class, Better_lib.CONFIG, Minecraft.getInstance().screen)
);.minecraft/config/Demo_config.json
Demo generated JSON:
{
"enableFeature": true,
"renderDistance": 12,
"maxFps": 120
}- You can group config entries with the
categoryvalue. - Nested classes are supported for better organization.
- Supports booleans, numbers, strings, enums, and lists.
- Default value reset buttons
- Tooltips per entry
- Server/client sync
- Config versioning and migration