Class SliderOption

java.lang.Object
net.uku3lig.ukulib.config.option.SliderOption
All Implemented Interfaces:
WidgetCreator

public class SliderOption extends Object implements WidgetCreator
A double option, displayed by a slider.
See Also:
  • Field Details

    • DEFAULT_VALUE_TO_TEXT

      public static final DoubleFunction<net.minecraft.network.chat.Component> DEFAULT_VALUE_TO_TEXT
      Displays a double with 2 decimals of precision.
    • PERCENT_VALUE_TO_TEXT

      public static final DoubleFunction<net.minecraft.network.chat.Component> PERCENT_VALUE_TO_TEXT
      Displays a double as a percentage, with no further precision.
    • INTEGER_VALUE_TO_TEXT

      public static final DoubleFunction<net.minecraft.network.chat.Component> 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.network.chat.Component> valueToText, double min, double max, double step, net.minecraft.client.OptionInstance.TooltipSupplier<@NotNull Double> tooltipSupplier)
      Creates a slider option.
      Parameters:
      key - The translation key
      initialValue - The initial value
      setter - The callback for the modified value
      valueToText - The function that converts the value to human-readable text
      min - The minimum value
      max - The maximum value
      step - The step between each value
      tooltipSupplier - The tooltip supplier
    • SliderOption

      public SliderOption(String key, double initialValue, DoubleConsumer setter, DoubleFunction<net.minecraft.network.chat.Component> valueToText, double min, double max, double step)
      Creates a slider option, with no tooltip.
      Parameters:
      key - The translation key
      initialValue - The initial value
      setter - The callback for the modified value
      valueToText - The function that converts the value to human-readable text
      min - The minimum value
      max - The maximum value
      step - The step between each value
    • SliderOption

      public SliderOption(String key, double initialValue, DoubleConsumer setter, DoubleFunction<net.minecraft.network.chat.Component> valueToText, double min, double max)
      Creates a slider option, with no step or tooltip.
      Parameters:
      key - The translation key
      initialValue - The initial value
      setter - The callback for the modified value
      valueToText - The function that converts the value to human-readable text
      min - The minimum value
      max - The maximum value
    • SliderOption

      public SliderOption(String key, double initialValue, DoubleConsumer setter, DoubleFunction<net.minecraft.network.chat.Component> valueToText)
      Creates a slider option, between 0 (inclusive) and 1 (inclusive), with no step or tooltip.
      Parameters:
      key - The translation key
      initialValue - The initial value
      setter - The callback for the modified value
      valueToText - The function that converts the value to human-readable text
  • Method Details

    • createWidget

      public net.minecraft.client.gui.components.AbstractWidget createWidget(int x, int y, int width, int height)
      Description copied from interface: WidgetCreator
      Creates the widget.
      Specified by:
      createWidget in interface WidgetCreator
      Parameters:
      x - The x position
      y - The y position
      width - The widget width
      height - The widget height
      Returns:
      The created widget