-
Notifications
You must be signed in to change notification settings - Fork 0
Better Config System
BetterLib provides an easy-to-use and dynamic configuration system for Minecraft mods built with Forge, NeoForge, and Fabric.
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 fully customizable GUI screen lets players easily modify config values.π Live updates
Changes are saved instantly and can trigger callbacks if needed.π Multi-loader support
Works on Forge, NeoForge, and Fabric with the same config classes.
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;
}
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 Demo(IEventBus modEventBus, ModContainer modContainer) {
CONFIG = BetterConfigManager.register(DemoConfig.class);
}
@Mod.EventBusSubscriber(
modid = MODID,
bus = Mod.EventBusSubscriber.Bus.MOD,
value = Dist.CLIENT
)
public static class ClientModEvents {
@SubscribeEvent
public static void onClientSetup(FMLClientSetupEvent event) {
event.enqueueWork(() -> {
ConfigScreenHandler.register(
MODID,
parent -> BetterConfigScreenFactory.from(
DemoConfig.class,
CONFIG,
parent
)
);
});
}
}
}
Loads
Demo_config.jsonSaves changes automatically
Registers a GUI config screen
Adds a Config button in the Mods menu
On Fabric, config screens are integrated via Mod Menu.
No ClientModInitializer or manual registration is required.
modImplementation "com.terraformersmc:modmenu:${modmenu_version}"
public class DemoFabric implements ModInitializer {
public static DemoConfig CONFIG;
@Override
public void onInitialize() {
CONFIG = BetterConfigManager.register(DemoConfig.class);
}
}
package com.reggarf.mods.demo.fabric;
import com.reggarf.mods.demo.DemoFabric;
import com.reggarf.mods.better_lib.config.DemoConfig;
import com.reggarf.mods.better_lib.config.gui.BetterConfigScreenFactory;
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
@Environment(EnvType.CLIENT)
public class DemoMenuIntegration implements ModMenuApi {
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return parent ->
BetterConfigScreenFactory.from(
DemoConfig.class,
DemoFabric.CONFIG,
parent
);
}
}
{
"entrypoints": {
"main": [
"com.reggarf.mods.demo.DemoFabric"
],
"modmenu": [
"com.reggarf.mods.demo.fabric.DemoMenuIntegration"
]
},
"depends": {
"modmenu": "*"
}
}
β
The Config button appears automatically in Mod Menu
β
Runs client-only
β
Safe on dedicated servers
You can open the config GUI anywhere in your code:
Minecraft.getInstance().setScreen(
BetterConfigScreenFactory.from(
DemoConfig.class,
DemoFabric.CONFIG,
Minecraft.getInstance().screen
)
);
.minecraft/config/Demo_config.json
Example generated file:
{
"enableFeature": true,
"renderDistance": 12,
"maxFps": 120
}
Use
categoryto group optionsNested config classes are supported
Supports booleans, numbers, strings, enums, and lists
Same config classes work across all loaders
| Feature | Forge / NeoForge | Fabric |
|---|---|---|
| Config registration | Event-based | Common init |
| Config GUI | Extension point | Mod Menu |
| Client setup | Required | β Not required |
| Server safe | β | β |
Reset-to-default buttons
Tooltips per entry
Server/client config sync
Config versioning & migration
If Mod Menu is not installed on Fabric, the config GUI will simply not appear β configs will still load and save correctly.