diff options
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java index e07be56..f4ef1eb 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java @@ -170,8 +170,11 @@ public abstract class WAbstractSlider extends WWidget { } public void setValue(int value) { - this.value = value; - onValueChanged(value); + int previous = this.value; + this.value = MathHelper.clamp(value, min, max); + if (previous != this.value) { + onValueChanged(this.value); + } } @Nullable |