VulkanShader_1.21.10-0.0.4-alpha.jar
Download file
package net.vulkanmod.config.option;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import net.minecraft.class_2561;
import net.minecraft.class_3532;
import net.vulkanmod.config.gui.widget.OptionWidget;
import net.vulkanmod.config.gui.widget.RangeOptionWidget;
public class RangeOption extends Option<Integer> {
int min;
int max;
int step;
public RangeOption(class_2561 name, int min, int max, int step, Function<Integer, class_2561> translator, Consumer<Integer> setter, Supplier<Integer> getter) {
super(name, setter, getter, translator);
this.min = min;
this.max = max;
this.step = step;
}
public RangeOption(class_2561 name, int min, int max, int step, Consumer<Integer> setter, Supplier<Integer> getter) {
this(name, min, max, step, (i) -> class_2561.method_43470(String.valueOf(i)), setter, getter);
}
public OptionWidget<?> createWidget() {
return new RangeOptionWidget(this, this.name);
}
public class_2561 getName() {
String var10000 = this.name.getString();
return class_2561.method_30163(var10000 + ": " + ((Integer)this.getNewValue()).toString());
}
public float getScaledValue() {
float value = (float)(Integer)this.getNewValue();
return (value - (float)this.min) / (float)(this.max - this.min);
}
public void setValue(float f) {
double n = (double)class_3532.method_16439(f, (float)this.min, (float)this.max);
n = (double)((long)this.step * Math.round(n / (double)this.step));
this.setNewValue((int)n);
}
}
Download file