diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java index 17e6b9214f..3f4fc5f8e6 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java @@ -279,7 +279,20 @@ private void onMouseClick(MouseClickEvent event) { private void onAction(boolean isKey, int value, int modifiers, boolean isPress) { if (mc.gui.screen() != null || Input.isKeyPressed(InputConstants.KEY_F3)) return; + // A bind with modifiers takes precedence over one without, so pressing Ctrl + G does not + // also toggle a module bound to plain G. + boolean modifierBindMatched = false; + + for (Module module : moduleInstances.values()) { + if (module.keybind.hasMods() && module.keybind.matches(isKey, value, modifiers)) { + modifierBindMatched = true; + break; + } + } + for (Module module : moduleInstances.values()) { + if (modifierBindMatched && !module.keybind.hasMods()) continue; + if (module.keybind.matches(isKey, value, modifiers) && (isPress || (module.toggleOnBindRelease && module.isActive()))) { module.toggle(); module.sendToggledMsg(); diff --git a/src/main/java/meteordevelopment/meteorclient/utils/misc/Keybind.java b/src/main/java/meteordevelopment/meteorclient/utils/misc/Keybind.java index daf7b59f7f..43dfc4f227 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/misc/Keybind.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/misc/Keybind.java @@ -149,8 +149,10 @@ public boolean canBindTo(boolean isKey, int value, int modifiers) { public boolean matches(InputConstants.Key key, Set modifiers) { if (!isSet() || !this.key.equals(key)) return false; - if (!hasMods()) return modifiers.stream().noneMatch(m -> m == Modifier.SHIFT || m == Modifier.CONTROL || m == Modifier.ALT || m == Modifier.SUPER); - return this.modifiers.equals(modifiers); + // Modifiers held for other reasons (sneaking, sprinting, or the bound key being a modifier + // itself, which sets its own bit on press) must not stop a bind without modifiers from + // matching. Binds that do have modifiers take precedence, see Modules#onAction. + return !hasMods() || this.modifiers.equals(modifiers); } public boolean matches(boolean isKey, int value, int modifiers) {