Skip to content

Config Screen

ssbaxys edited this page Oct 26, 2026 · 1 revision

A ready settings screen from a simple description.

ConfigSpec spec = ConfigSpec.builder("mymod/client.toml")
        .header("MyMod settings")
        .category("hud", "Interface").icon("minecraft:compass")
        .bool("showMinimap", "Minimap", true).comment("Show in the corner of the screen")
        .integer("minimapSize", "Size", 96, 48, 192).step(8)
        .number("opacity", "Opacity", 0.85f, 0.2f, 1f).step(0.05f)
        .key("zoomKey", "Zoom", Keys.Z)
        .category("look", "Look")
        .choice("quality", "Quality", Quality.MEDIUM, Quality.values()).labels(q -> ...)
        .color("accent", "Accent", 0xFF5B8CFF).alpha(false)
        .string("greeting", "Greeting", "Hello!").maxLength(24)
        .build();
spec.load();                                   // Platform.readFile
boolean on = spec.bool("showMinimap").peek();  // values are signals
new ConfigScreen(spec).title("MyMod").autoSave(true);

No reflection: every value is described explicitly and stored in a Signal. set coerces the value to a valid one (range, length, option, no alpha). ConfigScreen builds side navigation by category and rows: Toggle, SliderField, TextField, Select, ColorField, KeyBindField, each with a reset-to-default button; search looks through names, keys, comments and categories; Reset all, Save and auto-save. The file is simple TOML: [category] sections, key = value, comments with the label and range; unknown and broken lines are skipped when reading.


← Languages · English home · Accessibility and Sounds →

Clone this wiki locally