mirror of
https://github.com/chylex/Better-Controls.git
synced 2026-02-14 12:06:12 +01:00
Compare commits
2 Commits
1c7c5402ad
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
a8cc4e115b
|
|||
|
13fc85ff1c
|
@@ -3,7 +3,7 @@ modId=bettercontrols
|
|||||||
modName=Better Controls
|
modName=Better Controls
|
||||||
modDescription=Adds many powerful key bindings and options to control your movement.\\n\\nThe features complement vanilla mechanics without giving unfair advantages, so server use should be fine.
|
modDescription=Adds many powerful key bindings and options to control your movement.\\n\\nThe features complement vanilla mechanics without giving unfair advantages, so server use should be fine.
|
||||||
modAuthor=chylex
|
modAuthor=chylex
|
||||||
modVersion=1.6.3
|
modVersion=1.6.4
|
||||||
modLicense=MPL-2.0
|
modLicense=MPL-2.0
|
||||||
modSourcesURL=https://github.com/chylex/Better-Controls
|
modSourcesURL=https://github.com/chylex/Better-Controls
|
||||||
modIssuesURL=https://github.com/chylex/Better-Controls/issues
|
modIssuesURL=https://github.com/chylex/Better-Controls/issues
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import net.minecraft.client.gui.components.AbstractSliderButton;
|
|||||||
import net.minecraft.client.input.KeyEvent;
|
import net.minecraft.client.input.KeyEvent;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.MutableComponent;
|
import net.minecraft.network.chat.MutableComponent;
|
||||||
import net.minecraft.util.Mth;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
@@ -32,7 +31,7 @@ public final class DiscreteValueSliderWidget<T> extends AbstractSliderButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int getSelectedOptionIndex() {
|
private int getSelectedOptionIndex() {
|
||||||
return Mth.floor(Mth.clampedLerp(0.0, options.size() - 1.0, value));
|
return getOptionIndex(value, options.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -79,6 +78,18 @@ public final class DiscreteValueSliderWidget<T> extends AbstractSliderButton {
|
|||||||
return Component.translatable("gui.narrate.slider", narration.plainCopy().append(" ").append(getMessage()));
|
return Component.translatable("gui.narrate.slider", narration.plainCopy().append(" ").append(getMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getOptionIndex(double value, int optionCount) {
|
||||||
|
if (value < 0.0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (value > 1.0) {
|
||||||
|
return optionCount - 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return (int) (value * (optionCount - 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static <T> double getOptionValue(ImmutableList<Option<T>> options, int optionIndex) {
|
private static <T> double getOptionValue(ImmutableList<Option<T>> options, int optionIndex) {
|
||||||
return optionIndex / (options.size() - 1.0);
|
return optionIndex / (options.size() - 1.0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user