-
Notifications
You must be signed in to change notification settings - Fork 0
UI Helpers
Elib provides small pieces for a config screen. Your mod still owns the screen layout and decides when to save.
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.
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.
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();
}