Skip to content

Fix several intertwined input bugs #5480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.client.util.InputUtil;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.gen.Invoker;

import java.util.Map;

Expand All @@ -17,6 +18,9 @@ public interface KeyBindingAccessor {
@Accessor("CATEGORY_ORDER_MAP")
static Map<String, Integer> getCategoryOrderMap() { return null; }

@Accessor("KEYS_BY_ID")
static Map<String, KeyBinding> getKeysById() { return null; }

@Accessor("boundKey")
InputUtil.Key getKey();

Expand All @@ -25,4 +29,7 @@ public interface KeyBindingAccessor {

@Accessor("timesPressed")
void meteor$setTimesPressed(int timesPressed);

@Invoker("reset")
void invokeReset();
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
import meteordevelopment.meteorclient.MeteorClient;
import meteordevelopment.meteorclient.events.entity.player.ItemUseCrosshairTargetEvent;
Expand All @@ -21,6 +23,7 @@
import meteordevelopment.meteorclient.renderer.MeteorRenderPipelines;
import meteordevelopment.meteorclient.systems.config.Config;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.movement.GUIMove;
import meteordevelopment.meteorclient.systems.modules.player.FastUse;
import meteordevelopment.meteorclient.systems.modules.player.Multitask;
import meteordevelopment.meteorclient.systems.modules.render.ESP;
Expand All @@ -37,6 +40,7 @@
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.network.ClientPlayerInteractionManager;
import net.minecraft.client.option.GameOptions;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.Window;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity;
Expand Down Expand Up @@ -149,6 +153,33 @@ private void onSetScreen(Screen screen, CallbackInfo info) {
if (event.isCancelled()) info.cancel();
}

@WrapOperation(method = "setScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/KeyBinding;unpressAll()V"))
private void onSetScreenKeyBindingUnpressAll(Operation<Void> op) {
Modules modules = Modules.get();
if (modules == null) {
op.call();
return;
}

GUIMove guimove = modules.get(GUIMove.class);
if (guimove == null || !guimove.isActive() || guimove.skip()) {
op.call();
return;
}

GameOptions options = MeteorClient.mc.options;
for (KeyBinding kb : KeyBindingAccessor.getKeysById().values()) {
if (kb == options.forwardKey) continue;
if (kb == options.leftKey) continue;
if (kb == options.rightKey) continue;
if (kb == options.backKey) continue;
if (guimove.sneak.get() && kb == options.sneakKey) continue;
if (guimove.sprint.get() && kb == options.sprintKey) continue;
if (guimove.jump.get() && kb == options.jumpKey) continue;
((KeyBindingAccessor) kb).invokeReset();
}
}

@Inject(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;isItemEnabled(Lnet/minecraft/resource/featuretoggle/FeatureSet;)Z"))
private void onDoItemUseHand(CallbackInfo ci, @Local ItemStack itemStack) {
FastUse fastUse = Modules.get().get(FastUse.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,17 @@
import meteordevelopment.meteorclient.mixininterface.IVec3d;
import meteordevelopment.meteorclient.pathing.NopPathManager;
import meteordevelopment.meteorclient.pathing.PathManagers;
import meteordevelopment.meteorclient.settings.*;
import meteordevelopment.meteorclient.settings.BoolSetting;
import meteordevelopment.meteorclient.settings.EnumSetting;
import meteordevelopment.meteorclient.settings.Setting;
import meteordevelopment.meteorclient.settings.SettingGroup;
import meteordevelopment.meteorclient.systems.modules.Categories;
import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.movement.GUIMove;
import meteordevelopment.meteorclient.utils.Utils;
import meteordevelopment.meteorclient.utils.misc.input.Input;
import meteordevelopment.meteorclient.utils.misc.input.KeyAction;
import meteordevelopment.orbit.EventHandler;
import meteordevelopment.orbit.EventPriority;
import net.minecraft.client.option.KeyBinding;

public class AutoWalk extends Module {
private final SettingGroup sgGeneral = settings.getDefaultGroup();
Expand Down Expand Up @@ -105,10 +103,10 @@ private void onTick(TickEvent.Pre event) {
}

switch (direction.get()) {
case Forwards -> setPressed(mc.options.forwardKey, true);
case Backwards -> setPressed(mc.options.backKey, true);
case Left -> setPressed(mc.options.leftKey, true);
case Right -> setPressed(mc.options.rightKey, true);
case Forwards -> mc.options.forwardKey.setPressed(true);
case Backwards -> mc.options.backKey.setPressed(true);
case Left -> mc.options.leftKey.setPressed(true);
case Right -> mc.options.rightKey.setPressed(true);
}
} else {
if (PathManagers.get() instanceof NopPathManager) {
Expand Down Expand Up @@ -150,15 +148,10 @@ private void onPlayerMove(PlayerMoveEvent event) {
}

private void unpress() {
setPressed(mc.options.forwardKey, false);
setPressed(mc.options.backKey, false);
setPressed(mc.options.leftKey, false);
setPressed(mc.options.rightKey, false);
}

private void setPressed(KeyBinding key, boolean pressed) {
key.setPressed(pressed);
Input.setKeyState(key, pressed);
mc.options.forwardKey.setPressed(false);
mc.options.backKey.setPressed(false);
mc.options.leftKey.setPressed(false);
mc.options.rightKey.setPressed(false);
}

private boolean isMovementKey(int key) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,24 @@

package meteordevelopment.meteorclient.systems.modules.movement;

import meteordevelopment.meteorclient.MeteorClient;
import meteordevelopment.meteorclient.events.entity.player.PlayerTickMovementEvent;
import meteordevelopment.meteorclient.events.game.OpenScreenEvent;
import meteordevelopment.meteorclient.events.meteor.KeyEvent;
import meteordevelopment.meteorclient.events.meteor.MouseButtonEvent;
import meteordevelopment.meteorclient.events.render.Render3DEvent;
import meteordevelopment.meteorclient.gui.WidgetScreen;
import meteordevelopment.meteorclient.mixin.CreativeInventoryScreenAccessor;
import meteordevelopment.meteorclient.mixin.KeyBindingAccessor;
import meteordevelopment.meteorclient.settings.*;
import meteordevelopment.meteorclient.systems.modules.Categories;
import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.render.Freecam;
import meteordevelopment.meteorclient.utils.misc.input.Input;
import meteordevelopment.meteorclient.utils.misc.input.KeyAction;
import meteordevelopment.orbit.EventHandler;
import meteordevelopment.orbit.EventPriority;
import net.minecraft.client.gui.screen.ChatScreen;
import net.minecraft.client.gui.screen.ingame.*;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import net.minecraft.item.ItemGroups;
import net.minecraft.util.math.MathHelper;

Expand All @@ -43,22 +44,22 @@ public enum Screens {
.build()
);

private final Setting<Boolean> jump = sgGeneral.add(new BoolSetting.Builder()
public final Setting<Boolean> jump = sgGeneral.add(new BoolSetting.Builder()
.name("jump")
.description("Allows you to jump while in GUIs.")
.defaultValue(true)
.onChanged(aBoolean -> {
if (isActive() && !aBoolean) set(mc.options.jumpKey, false);
if (isActive() && !aBoolean) mc.options.jumpKey.setPressed(false);
})
.build()
);

private final Setting<Boolean> sneak = sgGeneral.add(new BoolSetting.Builder()
public final Setting<Boolean> sneak = sgGeneral.add(new BoolSetting.Builder()
.name("sneak")
.description("Allows you to sneak while in GUIs.")
.defaultValue(true)
.onChanged(aBoolean -> {
if (isActive() && !aBoolean) set(mc.options.sneakKey, false);
if (isActive() && !aBoolean) mc.options.sneakKey.setPressed(false);
})
.build()
);
Expand All @@ -68,7 +69,7 @@ public enum Screens {
.description("Allows you to sprint while in GUIs.")
.defaultValue(true)
.onChanged(aBoolean -> {
if (isActive() && !aBoolean) set(mc.options.sprintKey, false);
if (isActive() && !aBoolean) mc.options.sprintKey.setPressed(false);
})
.build()
);
Expand All @@ -94,14 +95,14 @@ public GUIMove() {

@Override
public void onDeactivate() {
set(mc.options.forwardKey, false);
set(mc.options.backKey, false);
set(mc.options.leftKey, false);
set(mc.options.rightKey, false);

if (jump.get()) set(mc.options.jumpKey, false);
if (sneak.get()) set(mc.options.sneakKey, false);
if (sprint.get()) set(mc.options.sprintKey, false);
mc.options.forwardKey.setPressed(false);
mc.options.backKey.setPressed(false);
mc.options.leftKey.setPressed(false);
mc.options.rightKey.setPressed(false);

if (jump.get()) mc.options.jumpKey.setPressed(false);
if (sneak.get()) mc.options.sneakKey.setPressed(false);
if (sprint.get()) mc.options.sprintKey.setPressed(false);
}

public boolean disableSpace() {
Expand All @@ -111,20 +112,29 @@ public boolean disableArrows() {
return isActive() && arrowsRotate.get();
}

@EventHandler
private void onPlayerMoveEvent(PlayerTickMovementEvent event) {
private void onInput(int key, KeyAction action, boolean mouse) {
if (skip()) return;
if (screens.get() == Screens.GUI && !(mc.currentScreen instanceof WidgetScreen)) return;
if (screens.get() == Screens.Inventory && mc.currentScreen instanceof WidgetScreen) return;

set(mc.options.forwardKey, Input.isPressed(mc.options.forwardKey));
set(mc.options.backKey, Input.isPressed(mc.options.backKey));
set(mc.options.leftKey, Input.isPressed(mc.options.leftKey));
set(mc.options.rightKey, Input.isPressed(mc.options.rightKey));
pass(mc.options.forwardKey, key, action, mouse);
pass(mc.options.backKey, key, action, mouse);
pass(mc.options.leftKey, key, action, mouse);
pass(mc.options.rightKey, key, action, mouse);

if (jump.get()) pass(mc.options.jumpKey, key, action, mouse);
if (sneak.get()) pass(mc.options.sneakKey, key, action, mouse);
if (sprint.get()) pass(mc.options.sprintKey, key, action, mouse);
}

if (jump.get()) set(mc.options.jumpKey, Input.isPressed(mc.options.jumpKey));
if (sneak.get()) set(mc.options.sneakKey, Input.isPressed(mc.options.sneakKey));
if (sprint.get()) set(mc.options.sprintKey, Input.isPressed(mc.options.sprintKey));
@EventHandler
private void onKey(KeyEvent event) {
onInput(event.key, event.action, false);
}

@EventHandler
private void onButton(MouseButtonEvent event) {
onInput(event.button, event.action, true);
}

@EventHandler
Expand All @@ -135,31 +145,40 @@ private void onRender3D(Render3DEvent event) {

float rotationDelta = Math.min((float) (rotateSpeed.get() * event.frameTime * 20f), 100);

Freecam freecam = Modules.get().get(Freecam.class);

if (arrowsRotate.get()) {
float yaw = mc.player.getYaw();
float pitch = mc.player.getPitch();
if (!freecam.isActive()) {
float yaw = mc.player.getYaw();
float pitch = mc.player.getPitch();

if (Input.isKeyPressed(GLFW_KEY_LEFT)) yaw -= rotationDelta;
if (Input.isKeyPressed(GLFW_KEY_RIGHT)) yaw += rotationDelta;
if (Input.isKeyPressed(GLFW_KEY_UP)) pitch -= rotationDelta;
if (Input.isKeyPressed(GLFW_KEY_DOWN)) pitch += rotationDelta;

if (Input.isKeyPressed(GLFW_KEY_LEFT)) yaw -= rotationDelta;
if (Input.isKeyPressed(GLFW_KEY_RIGHT)) yaw += rotationDelta;
if (Input.isKeyPressed(GLFW_KEY_UP)) pitch -= rotationDelta;
if (Input.isKeyPressed(GLFW_KEY_DOWN)) pitch += rotationDelta;
pitch = MathHelper.clamp(pitch, -90, 90);

mc.player.setYaw(yaw);
mc.player.setPitch(pitch);
} else {
double dy = 0, dx = 0;

pitch = MathHelper.clamp(pitch, -90, 90);
if (Input.isKeyPressed(GLFW_KEY_LEFT)) dy = -rotationDelta;
if (Input.isKeyPressed(GLFW_KEY_RIGHT)) dy = rotationDelta;
if (Input.isKeyPressed(GLFW_KEY_UP)) dx = -rotationDelta;
if (Input.isKeyPressed(GLFW_KEY_DOWN)) dx = rotationDelta;

mc.player.setYaw(yaw);
mc.player.setPitch(pitch);
freecam.changeLookDirection(dy, dx);
}
}
}

private void set(KeyBinding bind, boolean pressed) {
boolean wasPressed = bind.isPressed();
bind.setPressed(pressed);

InputUtil.Key key = ((KeyBindingAccessor) bind).getKey();
if (wasPressed != pressed && key.getCategory() == InputUtil.Type.KEYSYM) {
MeteorClient.EVENT_BUS.post(KeyEvent.get(key.getCode(), 0, pressed ? KeyAction.Press : KeyAction.Release));
}
private void pass(KeyBinding bind, int key, KeyAction action, boolean mouse) {
if (!mouse && !bind.matchesKey(key, 0)) return;
if (mouse && !bind.matchesMouse(key)) return;
if (action == KeyAction.Press) bind.setPressed(true);
if (action == KeyAction.Release) bind.setPressed(false);
}

public boolean skip() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
import meteordevelopment.meteorclient.events.packets.PacketEvent;
import meteordevelopment.meteorclient.systems.modules.movement.elytrafly.ElytraFlightMode;
import meteordevelopment.meteorclient.systems.modules.movement.elytrafly.ElytraFlightModes;
import meteordevelopment.meteorclient.utils.misc.input.Input;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.effect.StatusEffects;
Expand Down Expand Up @@ -43,8 +41,8 @@ public void onTick() {
if (checkConditions(mc.player)) {
if (!rubberbanded) {
if (prevFov != 0 && !elytraFly.sprint.get()) mc.options.getFovEffectScale().setValue(0.0); // This stops the FOV effects from constantly going on and off.
if (elytraFly.autoJump.get()) setPressed(mc.options.jumpKey, true);
setPressed(mc.options.forwardKey, true);
if (elytraFly.autoJump.get()) mc.options.jumpKey.setPressed(true);
mc.options.forwardKey.setPressed(true);
mc.player.setYaw(getYawDirection());
if (elytraFly.lockPitch.get()) mc.player.setPitch(elytraFly.pitch.get().floatValue());
}
Expand Down Expand Up @@ -76,8 +74,8 @@ public void onPreTick() {
}

private void unpress() {
setPressed(mc.options.forwardKey, false);
if (elytraFly.autoJump.get()) setPressed(mc.options.jumpKey, false);
mc.options.forwardKey.setPressed(false);
if (elytraFly.autoJump.get()) mc.options.jumpKey.setPressed(false);
}

@Override
Expand All @@ -95,12 +93,6 @@ public void onPacketSend(PacketEvent.Send event) {
}
}


private void setPressed(KeyBinding key, boolean pressed) {
key.setPressed(pressed);
Input.setKeyState(key, pressed);
}

public static boolean recastElytra(ClientPlayerEntity player) {
if (checkConditions(player) && ignoreGround(player)) {
player.networkHandler.sendPacket(new ClientCommandC2SPacket(player, ClientCommandC2SPacket.Mode.START_FALL_FLYING));
Expand Down
Loading