From 90f0c0722175466856b82ef65ada129eb972c425 Mon Sep 17 00:00:00 2001 From: Arslaan Pathan Date: Wed, 8 Oct 2025 22:44:10 +1300 Subject: finish clickgui, add more hacks, add settings, add mixins, add packet event buses and packet events, what the cook why did i put so much shit in one commit --- .../modules/settings/NumberSetting.java | 66 ++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/main/java/net/justlearning/arslaan3102/arslaansmagichax/modules/settings/NumberSetting.java (limited to 'src/main/java/net/justlearning/arslaan3102/arslaansmagichax/modules/settings/NumberSetting.java') diff --git a/src/main/java/net/justlearning/arslaan3102/arslaansmagichax/modules/settings/NumberSetting.java b/src/main/java/net/justlearning/arslaan3102/arslaansmagichax/modules/settings/NumberSetting.java new file mode 100644 index 0000000..d0f2bee --- /dev/null +++ b/src/main/java/net/justlearning/arslaan3102/arslaansmagichax/modules/settings/NumberSetting.java @@ -0,0 +1,66 @@ +package net.justlearning.arslaan3102.arslaansmagichax.modules.settings; + +public class NumberSetting extends Setting { + + private double min, max, increment; + private double value; + + public NumberSetting(String name, double min, double max, double defaultValue, double increment) { + super(name); + this.min = min; + this.max = max; + this.value = defaultValue; + this.increment = increment; + } + + public static double clamp(double value, double min, double max) { + value = Math.max(min, value); + value = Math.min(max, value); + return value; + } + + public double getValue() { + return value; + } + + public float getValueFloat() { + return (float) value; + } + + public int getValueInt() { + return (int) value; + } + + public double getIncrement() { + return increment; + } + + public double getMin() { + return min; + } + + public double getMax() { + return max; + } + + public void setValue(double value) { + value = clamp(value, this.min, this.max); + value = Math.round(value * (1.0 / this.increment)) / (1.0 / this.increment); + this.value = value; + } + + public void increment(boolean positive) { + if (positive) setValue(getValue() + getIncrement()); + else setValue(getValue() - getIncrement()); + } + + @Override + public String getValueAsString() { + return String.valueOf(value); + } + + @Override + public void setValueFromString(String value) { + setValue(Double.parseDouble(value)); + } +} -- cgit v1.2.3