# SliderWidgetBuilder

## SliderWidgetBuilder

The [`SliderWidgetBuilder`](https://github.com/V-Fast/DynamicHUD/blob/master/src/main/java/com/tanishisherewith/dynamichud/widget/slider/SliderWidgetBuilder.java) 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:

{% code overflow="wrap" lineNumbers="true" %}

```java
// 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();
```

{% endcode %}

You can also do it like:

{% code overflow="wrap" lineNumbers="true" %}

```java
 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();
```

{% endcode %}

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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tanishisherewith.gitbook.io/archived-legacy-dynamichud/sliderwidgetbuilder.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
