From 1520f668ee6baa3a54f672831af2f3f791791755 Mon Sep 17 00:00:00 2001 From: Ennui Langeweile <85590273+EnnuiL@users.noreply.github.com> Date: Sat, 11 Dec 2021 14:02:27 -0300 Subject: [PATCH] Remove "Middle Click to Unbind" Because Vanilla actually has a way to unbind keys: "Select and Press Esc to Unbind" --- .../mixin/client/ClickableWidgetAccessor.java | 31 ------------------- .../mixin/client/KeyBindingEntryMixin.java | 19 ------------ .../resources/quilt_key_bindings.mixins.json | 1 - 3 files changed, 51 deletions(-) delete mode 100644 library/gui/key_bindings/src/main/java/org/quiltmc/qsl/key/bindings/mixin/client/ClickableWidgetAccessor.java diff --git a/library/gui/key_bindings/src/main/java/org/quiltmc/qsl/key/bindings/mixin/client/ClickableWidgetAccessor.java b/library/gui/key_bindings/src/main/java/org/quiltmc/qsl/key/bindings/mixin/client/ClickableWidgetAccessor.java deleted file mode 100644 index dc050aa10e..0000000000 --- a/library/gui/key_bindings/src/main/java/org/quiltmc/qsl/key/bindings/mixin/client/ClickableWidgetAccessor.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2021 QuiltMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.quiltmc.qsl.key.bindings.mixin.client; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Invoker; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; - -import net.minecraft.client.gui.widget.ClickableWidget; - -@Environment(EnvType.CLIENT) -@Mixin(ClickableWidget.class) -public interface ClickableWidgetAccessor { - @Invoker - boolean callClicked(double mouseX, double mouseY); -} diff --git a/library/gui/key_bindings/src/main/java/org/quiltmc/qsl/key/bindings/mixin/client/KeyBindingEntryMixin.java b/library/gui/key_bindings/src/main/java/org/quiltmc/qsl/key/bindings/mixin/client/KeyBindingEntryMixin.java index 68b796afe7..33af521154 100644 --- a/library/gui/key_bindings/src/main/java/org/quiltmc/qsl/key/bindings/mixin/client/KeyBindingEntryMixin.java +++ b/library/gui/key_bindings/src/main/java/org/quiltmc/qsl/key/bindings/mixin/client/KeyBindingEntryMixin.java @@ -19,7 +19,6 @@ import java.util.ArrayList; import java.util.List; -import org.lwjgl.glfw.GLFW; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -28,12 +27,10 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.widget.option.KeyBindingListWidget; import net.minecraft.client.gui.widget.option.KeyBindingListWidget.KeyBindingEntry; @@ -130,20 +127,4 @@ private Text addConflictIndicator(Text originalText) { public List getConflictTooltips() { return this.quilt$conflictTooltips; } - - @Inject(method = "mouseClicked", at = @At("HEAD"), cancellable = true) - private void addMiddleButtonBehavior(double mouseX, double mouseY, int button, CallbackInfoReturnable cir) { - if (button == GLFW.GLFW_MOUSE_BUTTON_MIDDLE) { - if (this.bindButton.active && this.bindButton.visible) { - if (((ClickableWidgetAccessor) this.bindButton).callClicked(mouseX, mouseY)) { - MinecraftClient client = ((EntryListWidgetAccessor) (Object) field_2742).getClient(); - this.bindButton.playDownSound(client.getSoundManager()); - this.binding.setBoundKey(InputUtil.UNKNOWN_KEY); - KeyBinding.updateKeysByCode(); - - cir.setReturnValue(true); - } - } - } - } } diff --git a/library/gui/key_bindings/src/main/resources/quilt_key_bindings.mixins.json b/library/gui/key_bindings/src/main/resources/quilt_key_bindings.mixins.json index 0a1299051c..4949cb8c13 100644 --- a/library/gui/key_bindings/src/main/resources/quilt_key_bindings.mixins.json +++ b/library/gui/key_bindings/src/main/resources/quilt_key_bindings.mixins.json @@ -3,7 +3,6 @@ "package": "org.quiltmc.qsl.key.bindings.mixin", "compatibilityLevel": "JAVA_17", "client": [ - "client.ClickableWidgetAccessor", "client.EntryListWidgetAccessor", "client.GameOptionsAccessor", "client.GameOptionsMixin",