mirror of
https://github.com/chylex/Better-Controls.git
synced 2025-08-18 01:31:48 +02:00
Compare commits
22 Commits
fabric/1.1
...
fabric/1.1
Author | SHA1 | Date | |
---|---|---|---|
d416883dbb | |||
681fd75997 | |||
04408ddfb1 | |||
15e314eb73 | |||
b292a3b621 | |||
4248293230 | |||
9634c33ca2 | |||
54a6b4ea56 | |||
9437932b97 | |||
50c035bb91 | |||
81e135469e | |||
188f66b4d3 | |||
ab4fa452f7 | |||
116bbe241d | |||
9baa7c4460 | |||
7f258966de | |||
9af10ad04c | |||
6e316eff89 | |||
21ee424cef | |||
c7c5b67c3b | |||
06b2782372 | |||
83b2dfdfa5 |
@@ -2,13 +2,14 @@
|
||||
org.gradle.jvmargs=-Xmx1G
|
||||
|
||||
# Fabric Properties
|
||||
minecraft_version=1.16.4
|
||||
yarn_mappings=1.16.4+build.1
|
||||
loader_version=0.10.6+build.214
|
||||
minecraft_version=1.15.2
|
||||
yarn_mappings=1.15.2+build.17
|
||||
loader_version=0.10.2+build.210
|
||||
|
||||
# Mod Properties
|
||||
mod_version=1.2.0
|
||||
maven_group=chylex.bettercontrols
|
||||
archives_base_name=BetterControls-1.16.2+
|
||||
archives_base_name=BetterControls-1.15.x
|
||||
|
||||
# https://modmuss50.me/fabric.html
|
||||
# https://fabricmc.net/use
|
||||
# https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
|
||||
|
@@ -4,6 +4,11 @@ import io.github.prospector.modmenu.api.ConfigScreenFactory;
|
||||
import io.github.prospector.modmenu.api.ModMenuApi;
|
||||
|
||||
public class ModMenuSupport implements ModMenuApi{
|
||||
@Override
|
||||
public String getModId(){
|
||||
return "bettercontrols";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigScreenFactory<?> getModConfigScreenFactory(){
|
||||
return BetterControlsScreen::new;
|
||||
|
@@ -14,11 +14,11 @@ import chylex.bettercontrols.util.Key;
|
||||
import chylex.bettercontrols.util.LiteralText;
|
||||
import net.minecraft.client.gui.Element;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.ScreenTexts;
|
||||
import net.minecraft.client.gui.screen.options.GameOptionsScreen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.options.KeyBinding;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.resource.language.I18n;
|
||||
import net.minecraft.client.util.InputUtil;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -246,8 +246,8 @@ public class BetterControlsScreen extends GameOptionsScreen{
|
||||
elements.add(new TextWidget(0, y, ROW_WIDTH, ROW_HEIGHT, text("Miscellaneous"), CENTER));
|
||||
y = generateMiscellaneousOptions(y + ROW_HEIGHT, elements) + TITLE_MARGIN_TOP;
|
||||
|
||||
addButton(new ButtonWidget(width / 2 - 99, height - 29, 200, 20, ScreenTexts.DONE, btn -> client.openScreen(parent)));
|
||||
addChild(optionsWidget = new OptionListWidget(21, height - 32, width, height, elements, y - TITLE_MARGIN_TOP + BOTTOM_PADDING));
|
||||
addButton(new ButtonWidget(width / 2 - 99, height - 29, 200, 20, I18n.translate("gui.done"), btn -> minecraft.openScreen(parent)));
|
||||
children.add(optionsWidget = new OptionListWidget(21, height - 32, width, height, elements, y - TITLE_MARGIN_TOP + BOTTOM_PADDING));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -256,11 +256,11 @@ public class BetterControlsScreen extends GameOptionsScreen{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(final MatrixStack matrices, final int mouseX, final int mouseY, final float delta){
|
||||
renderBackground(matrices);
|
||||
optionsWidget.render(matrices, mouseX, mouseY, delta);
|
||||
drawCenteredText(matrices, textRenderer, title, width / 2, 8, (255 << 16) | (255 << 8) | 255);
|
||||
super.render(matrices, mouseX, mouseY, delta);
|
||||
public void render(final int mouseX, final int mouseY, final float delta){
|
||||
renderBackground();
|
||||
optionsWidget.render(mouseX, mouseY, delta);
|
||||
drawCenteredString(font, title.asFormattedString(), width / 2, 8, (255 << 16) | (255 << 8) | 255);
|
||||
super.render(mouseX, mouseY, delta);
|
||||
}
|
||||
|
||||
private void startEditingKeyBinding(final KeyBindingWidget widget){
|
||||
|
@@ -4,7 +4,6 @@ import net.minecraft.client.gui.Drawable;
|
||||
import net.minecraft.client.gui.Element;
|
||||
import net.minecraft.client.gui.widget.AbstractButtonWidget;
|
||||
import net.minecraft.client.gui.widget.ElementListWidget;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -63,7 +62,7 @@ public final class OptionListWidget extends ElementListWidget<Entry>{
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowLeft(){
|
||||
protected int getRowLeft(){
|
||||
return super.getRowLeft() - ROW_PADDING;
|
||||
}
|
||||
|
||||
@@ -73,7 +72,7 @@ public final class OptionListWidget extends ElementListWidget<Entry>{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getScrollbarPositionX(){
|
||||
protected int getScrollbarPosition(){
|
||||
return (width + ROW_WIDTH) / 2 + 4;
|
||||
}
|
||||
|
||||
@@ -92,7 +91,7 @@ public final class OptionListWidget extends ElementListWidget<Entry>{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(final MatrixStack matrices, final int index, final int y, final int x, final int entryWidth, final int entryHeight, final int mouseX, final int mouseY, final boolean hovered, final float tickDelta){
|
||||
public void render(final int index, final int y, final int x, final int entryWidth, final int entryHeight, final int mouseX, final int mouseY, final boolean hovered, final float tickDelta){
|
||||
for(final Element element : elements){
|
||||
final Offset offset = offsets.get(element);
|
||||
|
||||
@@ -108,7 +107,7 @@ public final class OptionListWidget extends ElementListWidget<Entry>{
|
||||
}
|
||||
|
||||
if (element instanceof Drawable){
|
||||
((Drawable)element).render(matrices, mouseX, mouseY, tickDelta);
|
||||
((Drawable)element).render(mouseX, mouseY, tickDelta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,9 @@
|
||||
package chylex.bettercontrols.gui;
|
||||
import chylex.bettercontrols.mixin.AccessOptionButtonWidgetOption;
|
||||
import chylex.bettercontrols.mixin.AccessScreenButtons;
|
||||
import net.minecraft.client.gui.Element;
|
||||
import net.minecraft.client.gui.ParentElement;
|
||||
import net.minecraft.client.gui.screen.options.AccessibilityOptionsScreen;
|
||||
import net.minecraft.client.gui.screen.options.AccessibilityScreen;
|
||||
import net.minecraft.client.gui.screen.options.ControlsOptionsScreen;
|
||||
import net.minecraft.client.gui.widget.AbstractButtonWidget;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
@@ -23,7 +24,7 @@ public final class ScreenPatcher{
|
||||
|
||||
final AbstractButtonWidget autoJump = buttons
|
||||
.stream()
|
||||
.filter(it -> it instanceof OptionButtonWidget && ((OptionButtonWidget)it).getOption() == Option.AUTO_JUMP)
|
||||
.filter(it -> it instanceof OptionButtonWidget && ((AccessOptionButtonWidgetOption)it).getOption() == Option.AUTO_JUMP)
|
||||
.findAny()
|
||||
.orElse(null);
|
||||
|
||||
@@ -31,17 +32,17 @@ public final class ScreenPatcher{
|
||||
children.remove(autoJump);
|
||||
buttons.remove(autoJump);
|
||||
|
||||
accessor.callAddButton(new ButtonWidget(autoJump.x, autoJump.y, autoJump.getWidth(), autoJump.getHeight(), BetterControlsScreen.TITLE.copy().append("..."), btn -> {
|
||||
accessor.callAddButton(new ButtonWidget(autoJump.x, autoJump.y, autoJump.getWidth(), 20, BetterControlsScreen.TITLE.copy().append("...").asFormattedString(), btn -> {
|
||||
MINECRAFT.openScreen(new BetterControlsScreen(screen));
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
public static void onAccessibilityScreenOpened(final AccessibilityOptionsScreen screen){
|
||||
public static void onAccessibilityScreenOpened(final AccessibilityScreen screen){
|
||||
walkChildren(screen.children(), it -> {
|
||||
if (it instanceof OptionButtonWidget){
|
||||
final OptionButtonWidget button = (OptionButtonWidget)it;
|
||||
final Option option = button.getOption();
|
||||
final Option option = ((AccessOptionButtonWidgetOption)button).getOption();
|
||||
|
||||
if (option == Option.SPRINT_TOGGLED || option == Option.SNEAK_TOGGLED){
|
||||
button.active = false;
|
||||
|
@@ -1,14 +1,14 @@
|
||||
package chylex.bettercontrols.gui.elements;
|
||||
import it.unimi.dsi.fastutil.booleans.BooleanConsumer;
|
||||
import net.minecraft.client.gui.screen.ScreenTexts;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.resource.language.I18n;
|
||||
|
||||
public final class BooleanValueWidget extends ButtonWidget{
|
||||
private final BooleanConsumer onChanged;
|
||||
private boolean value;
|
||||
|
||||
public BooleanValueWidget(final int x, final int y, final int width, final int height, final boolean currentValue, final BooleanConsumer onChanged){
|
||||
super(x, y, width, height, currentValue ? ScreenTexts.ON : ScreenTexts.OFF, ignore -> {});
|
||||
super(x, y, width, height, I18n.translate(currentValue ? "options.on" : "options.off"), ignore -> {});
|
||||
this.value = currentValue;
|
||||
this.onChanged = onChanged;
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public final class BooleanValueWidget extends ButtonWidget{
|
||||
public void onPress(){
|
||||
super.onPress();
|
||||
value = !value;
|
||||
setMessage(value ? ScreenTexts.ON : ScreenTexts.OFF);
|
||||
setMessage(I18n.translate(value ? "options.on" : "options.off"));
|
||||
onChanged.accept(value);
|
||||
}
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@ public class CycleButtonWidget<T> extends ButtonWidget{
|
||||
private T selectedValue;
|
||||
|
||||
public CycleButtonWidget(final int x, final int y, final int width, final int height, final List<Option<T>> options, final T selectedValue, final Consumer<T> onChanged){
|
||||
super(x, y, width, height, Option.find(options, selectedValue).getText(), btn -> {});
|
||||
super(x, y, width, height, Option.find(options, selectedValue).getText().asFormattedString(), btn -> {});
|
||||
this.options = options;
|
||||
this.selectedValue = selectedValue;
|
||||
this.onChanged = onChanged;
|
||||
@@ -31,6 +31,6 @@ public class CycleButtonWidget<T> extends ButtonWidget{
|
||||
|
||||
selectedValue = newSelectedOption.getValue();
|
||||
onChanged.accept(selectedValue);
|
||||
setMessage(newSelectedOption.getText());
|
||||
setMessage(newSelectedOption.getText().asFormattedString());
|
||||
}
|
||||
}
|
||||
|
@@ -10,10 +10,11 @@ public final class DiscreteValueSliderWidget<T> extends SliderWidget{
|
||||
private T selectedValue;
|
||||
|
||||
public DiscreteValueSliderWidget(final int x, final int y, final int width, final int height, final List<Option<T>> options, final T selectedValue, final Consumer<T> onChanged){
|
||||
super(x, y, width, height, Option.find(options, selectedValue).getText(), options.indexOf(Option.find(options, selectedValue)) / (options.size() - 1.0));
|
||||
super(x, y, width, height, options.indexOf(Option.find(options, selectedValue)) / (options.size() - 1.0));
|
||||
this.options = options;
|
||||
this.selectedValue = selectedValue;
|
||||
this.onChanged = onChanged;
|
||||
updateMessage();
|
||||
}
|
||||
|
||||
public DiscreteValueSliderWidget(final int x, final int y, final int width, final List<Option<T>> options, final T selectedValue, final Consumer<T> onChanged){
|
||||
@@ -26,7 +27,7 @@ public final class DiscreteValueSliderWidget<T> extends SliderWidget{
|
||||
|
||||
@Override
|
||||
protected void updateMessage(){
|
||||
setMessage(getSelectedOption().getText());
|
||||
setMessage(getSelectedOption().getText().asFormattedString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -3,11 +3,8 @@ import chylex.bettercontrols.util.Key;
|
||||
import net.minecraft.client.gui.widget.AbstractButtonWidget;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.options.KeyBinding;
|
||||
import net.minecraft.client.resource.language.I18n;
|
||||
import net.minecraft.client.util.InputUtil;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.MutableText;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.Formatting;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -16,7 +13,7 @@ import static chylex.bettercontrols.util.Statics.OPTIONS;
|
||||
|
||||
public final class KeyBindingWidget extends ButtonWidget{
|
||||
private final KeyBinding binding;
|
||||
private final Text bindingName;
|
||||
private final String bindingName;
|
||||
|
||||
private final List<AbstractButtonWidget> linkedButtons = new ArrayList<>(1);
|
||||
|
||||
@@ -24,9 +21,9 @@ public final class KeyBindingWidget extends ButtonWidget{
|
||||
private boolean isEditing;
|
||||
|
||||
public KeyBindingWidget(final int x, final int y, final int width, final int height, final KeyBinding binding, final Consumer<KeyBindingWidget> onEditingStarted){
|
||||
super(x, y, width, height, LiteralText.EMPTY, btn -> {});
|
||||
super(x, y, width, height, "", btn -> {});
|
||||
this.binding = binding;
|
||||
this.bindingName = new TranslatableText(binding.getTranslationKey());
|
||||
this.bindingName = I18n.translate(binding.getId());
|
||||
this.onEditingStarted = onEditingStarted;
|
||||
updateKeyBindingText();
|
||||
}
|
||||
@@ -41,8 +38,8 @@ public final class KeyBindingWidget extends ButtonWidget{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MutableText getNarrationMessage(){
|
||||
return Key.isUnbound(binding) ? new TranslatableText("narrator.controls.unbound", bindingName) : new TranslatableText("narrator.controls.bound", bindingName, super.getNarrationMessage());
|
||||
protected String getNarrationMessage(){
|
||||
return Key.isUnbound(binding) ? I18n.translate("narrator.controls.unbound", bindingName) : I18n.translate("narrator.controls.bound", bindingName, super.getNarrationMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -52,7 +49,7 @@ public final class KeyBindingWidget extends ButtonWidget{
|
||||
updateKeyBindingText();
|
||||
}
|
||||
|
||||
public void bindAndStopEditing(final InputUtil.Key key){
|
||||
public void bindAndStopEditing(final InputUtil.KeyCode key){
|
||||
Key.bind(binding, key);
|
||||
stopEditing();
|
||||
|
||||
@@ -79,13 +76,13 @@ public final class KeyBindingWidget extends ButtonWidget{
|
||||
}
|
||||
|
||||
if (isEditing){
|
||||
setMessage((new LiteralText("> ")).append(Key.getBoundKeyText(binding).copy().formatted(Formatting.YELLOW)).append(" <").formatted(Formatting.YELLOW));
|
||||
setMessage(Formatting.WHITE + "> " + Formatting.YELLOW + binding.getLocalizedName() + Formatting.WHITE + " <");
|
||||
}
|
||||
else if (hasConflict){
|
||||
setMessage(Key.getBoundKeyText(binding).copy().formatted(Formatting.RED));
|
||||
setMessage(Formatting.RED + Key.getBoundKeyText(binding));
|
||||
}
|
||||
else{
|
||||
setMessage(Key.isUnbound(binding) ? Text.of("(No Binding)") : Key.getBoundKeyText(binding));
|
||||
setMessage(Key.isUnbound(binding) ? "(No Binding)" : Key.getBoundKeyText(binding));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,12 +1,10 @@
|
||||
package chylex.bettercontrols.gui.elements;
|
||||
import chylex.bettercontrols.gui.OptionListWidget.Widget;
|
||||
import chylex.bettercontrols.util.LiteralText;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.OrderedText;
|
||||
import java.util.List;
|
||||
import static chylex.bettercontrols.util.Statics.MINECRAFT;
|
||||
|
||||
public final class TextWidget extends DrawableHelper implements Widget{
|
||||
public static final int LEFT = 0;
|
||||
@@ -57,17 +55,17 @@ public final class TextWidget extends DrawableHelper implements Widget{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(final MatrixStack matrices, final int mouseX, final int mouseY, final float delta){
|
||||
final TextRenderer textRenderer = MINECRAFT.textRenderer;
|
||||
final List<OrderedText> lines = textRenderer.wrapLines(text, width);
|
||||
public void render(final int mouseX, final int mouseY, final float delta){
|
||||
final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
|
||||
final List<String> lines = textRenderer.wrapStringToWidthAsList(text.asFormattedString(), width);
|
||||
final int lineHeight = textRenderer.fontHeight + 1;
|
||||
|
||||
final int finalX = align == CENTER ? x + (width / 2) - (lines.stream().mapToInt(textRenderer::getWidth).max().orElse(0) / 2) : x;
|
||||
final int finalX = align == CENTER ? x + (width / 2) - (lines.stream().mapToInt(textRenderer::getStringWidth).max().orElse(0) / 2) : x;
|
||||
final int finalY = y + (height / 2) - (lineHeight * lines.size() / 2) + 1;
|
||||
|
||||
for(int i = 0; i < lines.size(); i++){
|
||||
final OrderedText line = lines.get(i);
|
||||
textRenderer.drawWithShadow(matrices, line, finalX, finalY + (i * lineHeight), (255 << 16) | (255 << 8) | 255);
|
||||
final String line = lines.get(i);
|
||||
textRenderer.drawWithShadow(line, finalX, finalY + (i * lineHeight), (255 << 16) | (255 << 8) | 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,15 +1,14 @@
|
||||
package chylex.bettercontrols.input;
|
||||
import net.minecraft.client.options.KeyBinding;
|
||||
import net.minecraft.client.resource.language.I18n;
|
||||
import net.minecraft.client.util.InputUtil.Type;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class KeyBindingWithModifier extends KeyBinding{
|
||||
public static final String CATEGORY = "key.categories.bettercontrols";
|
||||
|
||||
public static boolean checkCategoryMatches(final Text text){
|
||||
return text instanceof TranslatableText && CATEGORY.equals(((TranslatableText)text).getKey());
|
||||
public static boolean checkCategoryMatches(final String name){
|
||||
return I18n.translate(CATEGORY).equals(name);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@@ -5,6 +5,6 @@ import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(ClientPlayerEntity.class)
|
||||
public interface AccessClientPlayerFields{
|
||||
@Accessor
|
||||
@Accessor("field_3935")
|
||||
void setTicksLeftToDoubleTapSprint(int value);
|
||||
}
|
||||
|
@@ -1,11 +1,10 @@
|
||||
package chylex.bettercontrols.mixin;
|
||||
import net.minecraft.client.gui.screen.options.ControlsListWidget.CategoryEntry;
|
||||
import net.minecraft.text.Text;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(CategoryEntry.class)
|
||||
public interface AccessControlsListCategory{
|
||||
@Accessor
|
||||
Text getText();
|
||||
String getName();
|
||||
}
|
||||
|
@@ -0,0 +1,11 @@
|
||||
package chylex.bettercontrols.mixin;
|
||||
import net.minecraft.client.gui.widget.OptionButtonWidget;
|
||||
import net.minecraft.client.options.Option;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(OptionButtonWidget.class)
|
||||
public interface AccessOptionButtonWidgetOption{
|
||||
@Accessor
|
||||
Option getOption();
|
||||
}
|
@@ -5,6 +5,6 @@ import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(PlayerEntity.class)
|
||||
public interface AccessPlayerFields{
|
||||
@Accessor("abilityResyncCountdown")
|
||||
@Accessor("field_7489")
|
||||
void setTicksLeftToDoubleTapFlight(int value);
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@ public abstract class HookControlsListWidget extends ElementListWidget<Entry>{
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
public void init(final ControlsOptionsScreen parent, final MinecraftClient client, final CallbackInfo ci){
|
||||
children().removeIf(it -> {
|
||||
if (it instanceof CategoryEntry && KeyBindingWithModifier.checkCategoryMatches(((AccessControlsListCategory)it).getText())){
|
||||
if (it instanceof CategoryEntry && KeyBindingWithModifier.checkCategoryMatches(((AccessControlsListCategory)it).getName())){
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -2,7 +2,7 @@ package chylex.bettercontrols.mixin;
|
||||
import chylex.bettercontrols.gui.ScreenPatcher;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.options.AccessibilityOptionsScreen;
|
||||
import net.minecraft.client.gui.screen.options.AccessibilityScreen;
|
||||
import net.minecraft.client.gui.screen.options.ControlsOptionsScreen;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -20,8 +20,8 @@ public abstract class HookOpenScreen{
|
||||
if (screen.getClass() == ControlsOptionsScreen.class){
|
||||
ScreenPatcher.onControlsScreenOpened((ControlsOptionsScreen)screen);
|
||||
}
|
||||
else if (screen.getClass() == AccessibilityOptionsScreen.class){
|
||||
ScreenPatcher.onAccessibilityScreenOpened((AccessibilityOptionsScreen)screen);
|
||||
else if (screen.getClass() == AccessibilityScreen.class){
|
||||
ScreenPatcher.onAccessibilityScreenOpened((AccessibilityScreen)screen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -76,7 +76,7 @@ public final class PlayerTicker{
|
||||
|
||||
public void atHead(final ClientPlayerEntity player){
|
||||
if (FlightHelper.shouldFlyOnGround(player)){
|
||||
player.setOnGround(false);
|
||||
player.onGround = false;
|
||||
}
|
||||
|
||||
if (!cfg().doubleTapForwardToSprint){
|
||||
@@ -210,7 +210,7 @@ public final class PlayerTicker{
|
||||
public void afterSuperCall(final ClientPlayerEntity player){
|
||||
if (FlightHelper.shouldFlyOnGround(player)){
|
||||
final boolean isSneaking = player.isSneaking();
|
||||
final boolean isOnGround = player.isOnGround();
|
||||
final boolean isOnGround = player.onGround;
|
||||
|
||||
if (!isSneaking){
|
||||
wasSneakingBeforeTouchingGround = false;
|
||||
@@ -237,7 +237,7 @@ public final class PlayerTicker{
|
||||
}
|
||||
|
||||
if (cancelLanding){
|
||||
player.setOnGround(false);
|
||||
player.onGround = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -276,7 +276,7 @@ public final class PlayerTicker{
|
||||
}
|
||||
else{
|
||||
--temporaryFlyOnGroundTimer;
|
||||
player.setOnGround(false);
|
||||
player.onGround = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,15 +1,14 @@
|
||||
package chylex.bettercontrols.util;
|
||||
import net.minecraft.client.options.KeyBinding;
|
||||
import net.minecraft.client.util.InputUtil;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public final class Key{
|
||||
private Key(){}
|
||||
|
||||
public static final InputUtil.Key INVALID = InputUtil.UNKNOWN_KEY;
|
||||
public static final InputUtil.KeyCode INVALID = InputUtil.UNKNOWN_KEYCODE;
|
||||
|
||||
public static boolean isUnbound(final KeyBinding binding){
|
||||
return binding.isUnbound();
|
||||
return binding.isNotBound();
|
||||
}
|
||||
|
||||
public static boolean isPressed(final KeyBinding binding){
|
||||
@@ -20,31 +19,27 @@ public final class Key{
|
||||
return binding.wasPressed();
|
||||
}
|
||||
|
||||
public static Text getBoundKeyText(final KeyBinding binding){
|
||||
return binding.getBoundKeyLocalizedText();
|
||||
public static String getBoundKeyText(final KeyBinding binding){
|
||||
return binding.getLocalizedName();
|
||||
}
|
||||
|
||||
public static void bind(final KeyBinding binding, final InputUtil.Key input){
|
||||
binding.setBoundKey(input);
|
||||
public static void bind(final KeyBinding binding, final InputUtil.KeyCode input){
|
||||
binding.setKeyCode(input);
|
||||
}
|
||||
|
||||
public static String writeBinding(final KeyBinding binding){
|
||||
return binding.getBoundKeyTranslationKey();
|
||||
return binding.getName();
|
||||
}
|
||||
|
||||
public static void readBinding(final KeyBinding binding, final String serialized){
|
||||
try{
|
||||
bind(binding, InputUtil.fromTranslationKey(serialized));
|
||||
}catch(final IllegalArgumentException e){
|
||||
e.printStackTrace(); // let's not crash if the config file has garbage, okay?
|
||||
}
|
||||
bind(binding, InputUtil.fromName(serialized));
|
||||
}
|
||||
|
||||
public static InputUtil.Key inputFromMouse(final int button){
|
||||
public static InputUtil.KeyCode inputFromMouse(final int button){
|
||||
return InputUtil.Type.MOUSE.createFromCode(button);
|
||||
}
|
||||
|
||||
public static InputUtil.Key inputFromKeyboard(final int keyCode, final int scanCode){
|
||||
return InputUtil.fromKeyCode(keyCode, scanCode);
|
||||
public static InputUtil.KeyCode inputFromKeyboard(final int keyCode, final int scanCode){
|
||||
return InputUtil.getKeyCode(keyCode, scanCode);
|
||||
}
|
||||
}
|
||||
|
@@ -4,6 +4,8 @@ import java.util.Map;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public interface ModMenuApi{
|
||||
String getModId();
|
||||
|
||||
default ConfigScreenFactory<?> getModConfigScreenFactory(){
|
||||
return ignore -> null;
|
||||
}
|
||||
|
@@ -10,6 +10,7 @@
|
||||
"AccessControlsListKeyBinding",
|
||||
"AccessGameRendererFields",
|
||||
"AccessKeyBindingFields",
|
||||
"AccessOptionButtonWidgetOption",
|
||||
"AccessPlayerFields",
|
||||
"AccessScreenButtons",
|
||||
"AccessStickyKeyBindingStateGetter",
|
||||
|
@@ -28,6 +28,6 @@
|
||||
|
||||
"depends": {
|
||||
"fabricloader": ">=0.7.4",
|
||||
"minecraft": ">=1.16.2"
|
||||
"minecraft": "1.15.x"
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user