[PR #7741] container: settle hotbar keys from the raw key, not the translated one #7798

Open
opened 2026-11-03 07:24:17 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7741
Author: @oxi-does-dev
Created: 11/2/2026
Status: 🔄 Open

Base: main ← Head: fix/container-hotbar-rebind-double-translation


📝 Commits (1)

  • 7372955 container: settle hotbar keys from the raw key, not the translated one

📊 Changes

6 files changed (+38 additions, -20 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+26 -8)
📝 crates/horizon-client/src/game/agent.rs (+2 -2)
📝 crates/horizon-client/src/game/control.rs (+5 -5)
📝 crates/horizon-client/src/game/pad.rs (+3 -3)
📝 crates/horizon-client/src/game/pad_menu.rs (+1 -1)
📝 crates/horizon-client/src/game/split.rs (+1 -1)

📄 Description

A key bound to key.swapOffhand with the vanilla default taken by another
mapping (reported in #7707: key.hotbar.7 on F, key.swapOffhand on Left
Alt) swapped the hovered item into hotbar slot 7 while a container was open.

Cause

mapped_key_event translated the physical key into the vanilla default of
each mapping it is bound to before key_pressed ran, and the container arm
then asked container_hotbar_key about that default again. A translated
default can itself be another mapping's rebound key: the Left Alt press
arrived inside the container as KeyF, which is exactly what the player
bound key.hotbar.7 to, so the hotbar lookup answered Digit7 and the item
went to slot 7. Outside a container the KeyCode::KeyF … Screen::Playing
arm matched first, which is why the same key worked in the world.

Fix

Work in the keyspace vanilla hands the screen: AbstractContainerScreen. checkHotbarKeyPressed sees the raw key of Screen.keyPressed, so the
off-hand and hotbar lookups settle from the physical key once, not from a
default that may re-resolve into a second mapping.

  • mapped_key_event carries the raw key into mapped_key, and mapped_key
    into key_pressed.
  • The container arm calls container_hotbar_key(raw) instead of re-resolving
    the translated default.
  • Every other key_pressed caller (pad menus, the agent, the control socket,
    the mouse-translated arm) passes the key itself as raw, so their behavior
    is unchanged; the control socket's key command passes its physical key,
    which also fixes the same double translation there.

Vanilla followed

  • Screen.keyPressed / AbstractContainerScreen.keyPressed and
    AbstractContainerScreen.checkHotbarKeyPressed: the screen acts in raw
    keycodes.
  • Minecraft.handleKeybinds / KeyMapping.set: the translation into a
    mapping's default is what the in-world paths need, and stops there.

Testing

  • container_hotkeys_follow_the_bound_keys in horizon-client-input
    already covers the raw keyspace; the game-side caller now feeds it that.
  • cargo check --workspace --all-targets (with --no-default-features on
    this Android/Termux host: no libudev/libasound here).
  • cargo fmt --check.

No vanilla harness is affected: no gameplay rule changes, only which key
code reaches the existing container lookup.

Fixes #7707


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/7741 **Author:** [@oxi-does-dev](https://github.com/oxi-does-dev) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/container-hotbar-rebind-double-translation` --- ### 📝 Commits (1) - [`7372955`](https://github.com/horizon-rust/horizon/commit/73729552ef26aed287cbaab71d50cab7be4e7c73) container: settle hotbar keys from the raw key, not the translated one ### 📊 Changes **6 files changed** (+38 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+26 -8) 📝 `crates/horizon-client/src/game/agent.rs` (+2 -2) 📝 `crates/horizon-client/src/game/control.rs` (+5 -5) 📝 `crates/horizon-client/src/game/pad.rs` (+3 -3) 📝 `crates/horizon-client/src/game/pad_menu.rs` (+1 -1) 📝 `crates/horizon-client/src/game/split.rs` (+1 -1) </details> ### 📄 Description A key bound to `key.swapOffhand` with the vanilla default taken by another mapping (reported in #7707: `key.hotbar.7` on F, `key.swapOffhand` on Left Alt) swapped the hovered item into hotbar slot 7 while a container was open. ## Cause `mapped_key_event` translated the physical key into the vanilla default of each mapping it is bound to before `key_pressed` ran, and the container arm then asked `container_hotbar_key` about that default **again**. A translated default can itself be another mapping's rebound key: the Left Alt press arrived inside the container as `KeyF`, which is exactly what the player bound `key.hotbar.7` to, so the hotbar lookup answered `Digit7` and the item went to slot 7. Outside a container the `KeyCode::KeyF … Screen::Playing` arm matched first, which is why the same key worked in the world. ## Fix Work in the keyspace vanilla hands the screen: `AbstractContainerScreen. checkHotbarKeyPressed` sees the raw key of `Screen.keyPressed`, so the off-hand and hotbar lookups settle from the physical key once, not from a default that may re-resolve into a second mapping. - `mapped_key_event` carries the raw key into `mapped_key`, and `mapped_key` into `key_pressed`. - The container arm calls `container_hotbar_key(raw)` instead of re-resolving the translated default. - Every other `key_pressed` caller (pad menus, the agent, the control socket, the mouse-translated arm) passes the key itself as `raw`, so their behavior is unchanged; the control socket's `key` command passes its physical key, which also fixes the same double translation there. ## Vanilla followed - `Screen.keyPressed` / `AbstractContainerScreen.keyPressed` and `AbstractContainerScreen.checkHotbarKeyPressed`: the screen acts in raw keycodes. - `Minecraft.handleKeybinds` / `KeyMapping.set`: the translation into a mapping's default is what the in-world paths need, and stops there. ## Testing - `container_hotkeys_follow_the_bound_keys` in `horizon-client-input` already covers the raw keyspace; the game-side caller now feeds it that. - `cargo check --workspace --all-targets` (with `--no-default-features` on this Android/Termux host: no libudev/libasound here). - `cargo fmt --check`. No vanilla harness is affected: no gameplay rule changes, only which key code reaches the existing container lookup. Fixes #7707 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#7798
No description provided.