Package net.uku3lig.ukulib.config.option
Class SliderOption
java.lang.Object
net.uku3lig.ukulib.config.option.SliderOption
- All Implemented Interfaces:
WidgetCreator
A
double option, displayed by a slider.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DoubleFunction<net.minecraft.text.Text>Displays a double with 2 decimals of precision.static final DoubleFunction<net.minecraft.text.Text>Displays a double as a rounded integer.static final DoubleFunction<net.minecraft.text.Text>Displays a double as a percentage, with no further precision. -
Constructor Summary
ConstructorsConstructorDescriptionSliderOption(String key, double initialValue, DoubleConsumer setter, DoubleFunction<net.minecraft.text.Text> valueToText) Creates a slider option, between 0 (inclusive) and 1 (inclusive), with no step or tooltip.SliderOption(String key, double initialValue, DoubleConsumer setter, DoubleFunction<net.minecraft.text.Text> valueToText, double min, double max) Creates a slider option, with no step or tooltip.SliderOption(String key, double initialValue, DoubleConsumer setter, DoubleFunction<net.minecraft.text.Text> valueToText, double min, double max, double step) Creates a slider option, with no tooltip.SliderOption(String key, double initialValue, DoubleConsumer setter, DoubleFunction<net.minecraft.text.Text> valueToText, double min, double max, double step, net.minecraft.client.option.SimpleOption.TooltipFactory<Double> tooltipFactory) Creates a slider option. -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.client.gui.widget.ClickableWidgetcreateWidget(int x, int y, int width, int height) Creates the widget.
-
Field Details
-
DEFAULT_VALUE_TO_TEXT
Displays a double with 2 decimals of precision. -
PERCENT_VALUE_TO_TEXT
Displays a double as a percentage, with no further precision. -
INTEGER_VALUE_TO_TEXT
Displays a double as a rounded integer.
-
-
Constructor Details
-
SliderOption
public SliderOption(String key, double initialValue, DoubleConsumer setter, DoubleFunction<net.minecraft.text.Text> valueToText, double min, double max, double step, net.minecraft.client.option.SimpleOption.TooltipFactory<Double> tooltipFactory) Creates a slider option.- Parameters:
key- The translation keyinitialValue- The initial valuesetter- The callback for the modified valuevalueToText- The function that converts the value to human-readable textmin- The minimum valuemax- The maximum valuestep- The step between each valuetooltipFactory- The tooltip factory
-
SliderOption
public SliderOption(String key, double initialValue, DoubleConsumer setter, DoubleFunction<net.minecraft.text.Text> valueToText, double min, double max, double step) Creates a slider option, with no tooltip.- Parameters:
key- The translation keyinitialValue- The initial valuesetter- The callback for the modified valuevalueToText- The function that converts the value to human-readable textmin- The minimum valuemax- The maximum valuestep- The step between each value
-
SliderOption
public SliderOption(String key, double initialValue, DoubleConsumer setter, DoubleFunction<net.minecraft.text.Text> valueToText, double min, double max) Creates a slider option, with no step or tooltip.- Parameters:
key- The translation keyinitialValue- The initial valuesetter- The callback for the modified valuevalueToText- The function that converts the value to human-readable textmin- The minimum valuemax- The maximum value
-
SliderOption
public SliderOption(String key, double initialValue, DoubleConsumer setter, DoubleFunction<net.minecraft.text.Text> valueToText) Creates a slider option, between 0 (inclusive) and 1 (inclusive), with no step or tooltip.- Parameters:
key- The translation keyinitialValue- The initial valuesetter- The callback for the modified valuevalueToText- The function that converts the value to human-readable text
-
-
Method Details
-
createWidget
public net.minecraft.client.gui.widget.ClickableWidget createWidget(int x, int y, int width, int height) Description copied from interface:WidgetCreatorCreates the widget.- Specified by:
createWidgetin interfaceWidgetCreator- Parameters:
x- The x positiony- The y positionwidth- The widget widthheight- The widget height- Returns:
- The created widget
-