Skip to content

UI Helpers

Emil edited this page Sep 27, 2026 · 2 revisions

Elib provides small pieces for a config screen. Your mod still owns the screen layout and decides when to save.

Numeric slider

DoubleSliderWidget supports a minimum, maximum, optional step size, label, optional tooltip, and change callback:

DoubleSliderWidget slider = new DoubleSliderWidget(
    x, y, 150, 20,
    0.1, 5.0, 0.1,
    ExampleConfigManager.get().speed,
    value -> Component.literal("Speed: " + value),
    null,
    value -> ExampleConfigManager.get().speed = value
);
addRenderableWidget(slider);

Call slider.syncFromValue(newValue) after an external reset. This updates the displayed value without firing the change callback. A step of 0 makes the slider continuous.

Boolean option

ConfigWidgets.booleanOption(...) creates a Minecraft OptionInstance<Boolean> from your translation keys, current value, and change callback. Add the resulting option to your own options screen; it does not create or lay out a screen for you.

Reset notification

After a successful reset and save, you may call ElibConfigNotifications.reset(). It shows a Minecraft system toast only when the player has enabled Config Notifications in Elib's settings. The old saved(...) methods are deprecated no-ops; saving intentionally has no notification.

ExampleConfig config = ExampleConfigManager.get();
config.enabled = true;
config.speed = 1.0;
if (ExampleConfigManager.save()) {
    ElibConfigNotifications.reset();
}

Clone this wiki locally