Archived Legacy DynamicHUD
  • Dynamic HUD
  • Import using Gradle
  • Widgets
    • Adding Widgets
      • TextWidget
      • ItemWidget
      • ArmorWidget
    • Creating your own Widget class
    • Widget class
    • WidgetManager
    • WidgetBox
  • Saving and Loading
    • Saving and Loading
    • Changing save file name and directory
  • Moveable Screen
    • AbstractMoveableScreen
    • Default Moveable Screen
    • Using the default Moveable Screen
    • Creating and using your own MoveableScreen class
  • ContextMenu
    • ContextMenu class
    • ContextMenuOptionsProvider interface
    • DoubleInputScreen
    • DataInputScreen
  • Slider Widget
    • Slider
  • SliderWidgetBuilder
  • ColorPicker
    • ColorGradientPicker
      • ColorPickerButton
      • GradientBox
      • GradientSlider
  • Helpers
    • ColorHelper
    • DrawHelper
    • TextureHelper
Powered by GitBook
On this page
  • SliderWidgetBuilder
  • Fields
  • Constructors
  • Methods

SliderWidgetBuilder

This page talks about SliderWidgetBuilder class

PreviousSliderNextColorGradientPicker

SliderWidgetBuilder

The class provides a builder pattern for creating SliderWidget objects.

Fields

  • client: The MinecraftClient instance.

  • x: The x position of the widget.

  • y: The y position of the widget.

  • width: The width of the widget.

  • height: The height of the widget.

  • label: The label displayed above the slider.

  • value: The initial value of the slider.

  • minValue: The minimum value of the slider.

  • maxValue: The maximum value of the slider.

  • selectedWidget: The widget that this slider is associated with.

Constructors

SliderWidgetBuilder(MinecraftClient client)

Constructs a SliderWidgetBuilder object with the given client instance.

Methods

setX(int x)

Sets the x position of the widget.

setY(int y)

Sets the y position of the widget.

setWidth(int width)

Sets the width of the widget.

setHeight(int height)

Sets the height of the widget.

setLabel(String label)

Sets the label displayed above the slider.

setValue(float value)

Sets the initial value of the slider.

setMinValue(float minValue)

Sets the minimum value of the slider.

setMaxValue(float maxValue)

Sets the maximum value of the slider.

setSelectedWidget(Widget selectedWidget)

Sets the widget that this slider is associated with.

build()

Builds and returns a new SliderWidget object with the values specified by this builder.

Here's an example of how to use a SliderWidgetBuilder to create a new SliderWidget in your Minecraft Fabric mod:

// Create a new SliderWidgetBuilder
SliderWidgetBuilder builder = new SliderWidgetBuilder(client);

// Set values for the builder
builder.setX(10)
       .setY(10)
       .setWidth(100)
       .setHeight(20)
       .setLabel("My Slider")
       .setValue(0.5f)
       .setMinValue(0.0f)
       .setMaxValue(1.0f);

// Build a new SliderWidget
SliderWidget slider = builder.build();

You can also do it like:

 SliderWidget Slider = new SliderWidgetBuilder(client)
                    .setX(x)
                    .setY(y)
                    .setWidth(105)
                    .setHeight(15)
                    .setLabel(text)
                    .setValue(value)
                    .setMinValue(5f)
                    .setMaxValue(25.0f)
                    .setSelectedWidget(selectedWidget)
                    .build();

In this example, we create a new SliderWidgetBuilder and use its setter methods to specify values for its fields. We then call its build method to create a new SliderWidget with these values.

SliderWidgetBuilder