[PR #6093] [MERGED] Containers still check the off hand key after Tab moves the focus #6648

Closed
opened 2026-11-03 06:24:20 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6093
Author: @breachato
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: fix/6028-tab-offhand-in-containers


📝 Commits (1)

  • d07fd00 Containers still check the off hand key after Tab moves the focus

📊 Changes

2 files changed (+28 additions, -2 deletions)

View changed files

📝 crates/horizon-client/src/game/key_focus.rs (+23 -0)
📝 crates/horizon-client/src/game/pad_menu.rs (+5 -2)

📄 Description

🤖 Opened by breachato's AI agent (Claude Code, Claude Opus 5.5), not by breachato personally.

What and why

Fixes #6028.

With key.swapOffhand bound to Tab, pressing Tab over a slot in the inventory focused the recipe book button instead of swapping the hovered stack with the off hand.

Vanilla's Screen.keyPressed moves the focus on Tab or an arrow and then returns false (26.3 bytecode: changeFocus(path) then iconst_0; ireturn), so AbstractContainerScreen.keyPressed goes on to checkHotbarKeyPressed on the same press: vanilla both moves the focus and swaps. Horizon's Game::key_focus_key reported the key as used after moving the focus, so the container screen never saw it.

Now, in container screens (Screen::Inventory, Screen::Creative), Tab and the arrows move the focus and then pass the key on, as vanilla does. A press on a focused widget (Enter/Space), a slider toggle or nudge still keep the key. Other Horizon screens are unchanged: they handle Tab and the arrows themselves (pause, death screen), so passing the key on there would act twice.

The decision is a pure function, key_focus::passes_on, with a unit test.

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

  • net.minecraft.client.gui.screens.Screen.keyPressed(KeyEvent): Tab/arrow navigation, changeFocus, returns false.
  • net.minecraft.client.gui.screens.inventory.AbstractContainerScreen.keyPressed(KeyEvent): super.keyPressed first, then keyInventory, then checkHotbarKeyPressed.
  • net.minecraft.client.gui.screens.inventory.AbstractRecipeBookScreen.keyPressed(KeyEvent): the recipe book component, then the above.

Read from the pinned 26.3 client jar with javap -c. No harness: this is client input routing, covered by the unit test containers_still_get_tab_and_arrows_after_the_focus_moves.

Other projects' code

none

Self-check

pr_ready (tools/pr_ready.py --quick --base upstream/main on DESKTOP-G0M27UC, against upstream/main at 6f30860d0, 20 min 0 s)

Check Result
Scope ✅ 2 files, +28 −2
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 527 passed (5 min 33 s)
rustfmt ✅ (49 s)
clippy ✅ (5 min 6 s)
tests: horizon-client ✅ 1721 passed (8 min 18 s)
doc tests ✅ 0 passed (6 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Not checked in game on this machine: the vanilla data isn't prepared here.

🤖 Generated with Claude Code


🔄 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/6093 **Author:** [@breachato](https://github.com/breachato) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/6028-tab-offhand-in-containers` --- ### 📝 Commits (1) - [`d07fd00`](https://github.com/horizon-rust/horizon/commit/d07fd00f9413e93a08d867a70ac0d64968fa6fc9) Containers still check the off hand key after Tab moves the focus ### 📊 Changes **2 files changed** (+28 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/key_focus.rs` (+23 -0) 📝 `crates/horizon-client/src/game/pad_menu.rs` (+5 -2) </details> ### 📄 Description > 🤖 Opened by breachato's AI agent (Claude Code, Claude Opus 5.5), not by breachato personally. ## What and why Fixes #6028. With `key.swapOffhand` bound to Tab, pressing Tab over a slot in the inventory focused the recipe book button instead of swapping the hovered stack with the off hand. Vanilla's `Screen.keyPressed` moves the focus on Tab or an arrow and then **returns false** (26.3 bytecode: `changeFocus(path)` then `iconst_0; ireturn`), so `AbstractContainerScreen.keyPressed` goes on to `checkHotbarKeyPressed` on the same press: vanilla both moves the focus and swaps. Horizon's `Game::key_focus_key` reported the key as used after moving the focus, so the container screen never saw it. Now, in container screens (`Screen::Inventory`, `Screen::Creative`), Tab and the arrows move the focus and then pass the key on, as vanilla does. A press on a focused widget (Enter/Space), a slider toggle or nudge still keep the key. Other Horizon screens are unchanged: they handle Tab and the arrows themselves (pause, death screen), so passing the key on there would act twice. The decision is a pure function, `key_focus::passes_on`, with a unit test. ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [x] bug: a crash or a breakage - [ ] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference - `net.minecraft.client.gui.screens.Screen.keyPressed(KeyEvent)`: Tab/arrow navigation, `changeFocus`, returns false. - `net.minecraft.client.gui.screens.inventory.AbstractContainerScreen.keyPressed(KeyEvent)`: `super.keyPressed` first, then `keyInventory`, then `checkHotbarKeyPressed`. - `net.minecraft.client.gui.screens.inventory.AbstractRecipeBookScreen.keyPressed(KeyEvent)`: the recipe book component, then the above. Read from the pinned 26.3 client jar with `javap -c`. No harness: this is client input routing, covered by the unit test `containers_still_get_tab_and_arrows_after_the_focus_moves`. ## Other projects' code none ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on DESKTOP-G0M27UC, against upstream/main at 6f30860d0, 20 min 0 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +28 −2 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 527 passed (5 min 33 s) | | rustfmt | ✅ (49 s) | | clippy | ✅ (5 min 6 s) | | tests: horizon-client | ✅ 1721 passed (8 min 18 s) | | doc tests | ✅ 0 passed (6 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | Not checked in game on this machine: the vanilla data isn't prepared here. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:24:20 +07:00
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#6648
No description provided.