mojira.dev
MC-308426

Setting a movement key bind and the "Debug Modifier" key bind to the same key lets you move while an inventory is open

Description

If a movement key and the Debug Modifier Key are bound to the same physical key, holding that key while an inventory screen is open keeps the player moving. Movement should be ignored whenever a screen is open, but the Debug Modifier Key is exempt from that gate, so the shared key still registers as held.

The movement is real and not visual only. The client sends the movement to the server, so the player actually walks around the world with the screen still open.

Steps to reproduce

  1. Join a world.

  2. Bind "Walk Forwards" and "Debug Modifier Key" to the same key.

  3. Open an inventory screen (survival inventory, chest, etc.).

  4. Hold that key.

  5. The player moves while the screen stays open.

Observed behavior

The shared movement key registers and the player moves while an inventory screen is open.

Expected behavior

Movement keys are ignored while a screen is open, the same as they are when not sharing a key with the Debug Modifier Key.

Cause

In KeyboardHandler.keyPress, key bindings are normally only set when no screen is open. That guard is boolean handlesGameInput = this.minecraft.screen == null. Later the code does:

if (handlesGameInput || key == options.keyDebugModifier.key) {
    ...
    KeyMapping.set(key, true);
    KeyMapping.click(key);
}

The || key == options.keyDebugModifier.key part makes the Debug Modifier Key an exception to the screen-open guard, so the pressed key still gets its binding set to down even with a screen open. KeyMapping.set flips every binding registered to that physical key, so when a movement key shares the key, the movement binding is set down too. KeyboardInput.tick then reads it as held and feeds it into player movement on the next tick. The open screen never gets to suppress the input the way it does on the normal path.

Attachments

Comments 1

Thank you for helping us improve Minecraft! We saved your files:

[media]

Bram

Jonatan

Confirmed

Platform HC

Very Important

Input, Player, UI

26.1.2

26.2 Pre-Release 3

Retrieved