[PR #5511] [MERGED] Release the item use when a keybind opens a screen #6330

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5511
Author: @posok124521
Created: 10/31/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: fix/item-use-screen


📝 Commits (3)

  • b2ab3d0 Release the item use when a keybind opens a screen
  • 5288309 Merge remote-tracking branch 'upstream/main' into fix/item-use-screen
  • 66dcd82 e2e: cover the item use a keybind screen releases

📊 Changes

7 files changed (+204 additions, -32 deletions)

View changed files

📝 crates/horizon-client-input/src/interaction_input.rs (+13 -0)
📝 crates/horizon-client/examples/probe/interaction_input_fixture.rs (+18 -8)
📝 crates/horizon-client/src/game.rs (+6 -1)
📝 crates/horizon-client/src/game/remote.rs (+48 -18)
📝 mods/horizon/src/test/java/dev/horizonlab/parity/VanillaInteractionInputOracle.java (+12 -0)
📝 tools/agent_control_e2e.py (+94 -4)
📝 tools/test_interaction_input_parity.py (+13 -1)

📄 Description

🤖 Opened by posok124521's AI agent (DeepSeek 4.1 Flash), not by posok124521 personally.

What and why

Opening the inventory while an item was in use left the use running: the window's key handling set self.screen, and the input tick that runs Minecraft.handleKeybinds' release sentence is skipped while a screen is open (remote_handle_input returns early when screen != Screen::Playing). The serving side therefore kept counting and ate the food behind the GUI (a golden apple went 64 → 63 with its effects applied while the inventory was open).

Vanilla releases in the same tick the key opens the screen: Minecraft.handleKeybinds opens it itself (while (keyInventory.consumeClick()) gui.setScreen(...); chat and advancements open from its Gui.handleKeybinds call), Gui.setScreen runs KeyMapping.releaseAll() (KeyMapping.release() does clickCount = 0; setDown(false)), and the same handleKeybinds invocation then reaches if (player.isUsingItem()) { if (!keyUse.isDown()) gameMode.releaseUsingItem(player); }. MultiPlayerGameMode.releaseUsingItem sends ServerboundPlayerActionPacket.Action.RELEASE_USE_ITEM and calls player.releaseUsingItem(); handleKeybinds runs before level.tickEntities, so the food is not completed.

This adds interaction_input::release_on_screen_open, the release sentence of handleKeybinds, and calls it from the three screen opens that come from the keybinds: inventory/creative (E), chat (T, /, Enter) and advancements (L). Pause, server containers, mount inventories and dialogs are untouched: vanilla releases those on the first tick after closing (pause, MC-306147) or not at all (the mount inventory, MC-309593).

Fixes #4472

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

  • Minecraft.handleKeybinds: Gui.handleKeybinds() (chat T//, advancements L) and the while (keyInventory.consumeClick()) loop open screens before the if (player.isUsingItem()) { if (!keyUse.isDown()) gameMode.releaseUsingItem(player); } block, with no return between them.
  • Gui.setScreen (open branch): mouseHandler.releaseMouse(); KeyMapping.releaseAll(); screen.init(...) — the screen setter has no use release of its own.
  • KeyMapping.releaseAll / KeyMapping.release: clickCount = 0; setDown(false);; Options.keyUse is a ToggleKeyMapping (its release() resets the held state).
  • Minecraft.tick: calls handleKeybinds() only when gui.overlay() == null && gui.screen() == null, and before level.tickEntities().
  • MultiPlayerGameMode.releaseUsingItem (exactly one caller, Minecraft.handleKeybinds): RELEASE_USE_ITEM packet, then LocalPlayer.releaseUsingItem.
  • LivingEntity.releaseUsingItem → ItemStack.releaseUsing → stopUsingItem.
  • ServerGamePacketListenerImpl.handlePlayerAction RELEASE_USE_ITEM → ServerPlayer.releaseUsingItem.
  • KeyboardHandler.keyPress opens the pause menu outside handleKeybinds, so it is not released in that tick (MC-306147).
  • Tracker corroboration: MC-306119 (Open, affects 26.3; expected "stop using items when your inventory is opened", and its queued-click corner is the one case that still starts a use with a screen open), MC-309593 (the normal inventory interrupts the eat; a mount's inventory does not), MC-306147 (pause on servers).

Harness: tools/test_interaction_input_parity.py (extended) still runs the shipped Minecraft.handleKeybinds in VanillaInteractionInputOracle with real KeyMapping click counters; new rows open a screen from a keybind (Gui.setScreen → KeyMapping.releaseAll) while the use key is still held, and compare the release with interaction_input_fixture, which calls the same release_on_screen_open. The harness covers the release sentence and its ordering; it does not cover the bin's key wiring (the E/T/L call sites), which the live horizon-ctl test below covers.

Verification

Live, horizon-ctl on the default server-thread path (no --in-frame), survival, a stack of 64 golden apples, the inventory opened about 0.7 s into the 1.6 s use and kept open - before and after this change:

                                        before                                    after
open+0        screen inventory, using {slot:0,ticks:8}, 64 apples    screen inventory, using null, 64 apples
open+0.4      using {slot:0,ticks:20}, 64 apples                    using null, 64 apples
open+1.1      using null, 63 apples, Regeneration II + Absorption   using null, 64 apples
open+1.9      using null, 63 apples, effects ticking                using null, 64 apples
closed        playing, 63 apples                                     playing, 64 apples
control eat   (no GUI) 63 -> 62, effects applied                    (no GUI) 64 -> 63, effects applied

The same test after the change for the other keybind screens:

  • chat (T) opened while eating: screen "chat", using null, 64 apples; and still 64 after 0.6 s with chat open.
  • pause (Esc): using {slot:0, ticks:16} stays and the world ticks stay frozen (132 → 132 over 1.2 s), then the use is released on the first tick after unpause, 64 apples - vanilla's single-player pause (released after closing, not while paused).

Harness: python tools/test_interaction_input_parity.py → 400 interaction-input-parity cases match the pinned client (1,512 output lines), including the new keybind-screen rows.

git diff: 6 files, +110 −28 (138 changed lines).

Self-check:

pr_ready (tools/pr_ready.py --base upstream/main on chi4a, against upstream/main at 5062f2259, 6 min 43 s)

Check Result
Scope ✅ 6 files, +110 −28
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 495 passed (1 min 20 s)
rustfmt ✅ (14 s)
clippy ❌ failed (5 s)
tests: horizon-client, horizon-client-input ❌ 832 passed, 106 failed (4 min 55 s)
doc tests ✅ 0 passed (3 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 ❌ 367 affected, (2 s)
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

The 106 failing horizon-client tests are identical to the clean upstream/main baseline on this Windows machine (same MD5 of the failing list: FF1AE6C68AD2895C4FA73186BE20473E); CI runs them on Linux.

Notes on the Windows machine this ran on: the two red rows are pre-existing here, not caused by this change - the workspace-wide clippy -D warnings fails on clippy::missing_const_for_thread_local in the untouched horizon-core (also on a clean upstream/main tree), and the 106 horizon-client test failures are byte-identical with and without this change (git stash, same list, same MD5). On the touched crates clippy is clean (cargo clippy -p horizon-client --all-targets -- -D warnings -A clippy::missing_const_for_thread_local exits 0) and cargo test -p horizon-client-input passes 58/58. CI verify and the maintainer's run-parity label will confirm on Linux; tools/parity.py itself needs fcntl and cannot run here.

Screenshots

No screenshots captured; the before/after stacks and using values above are the player-visible difference (the apple is no longer eaten behind the open inventory).

🤖 Generated with DeepSeek Harness (DeepSeek 4.1 Flash, model deepseek-flash).


🔄 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/5511 **Author:** [@posok124521](https://github.com/posok124521) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/item-use-screen` --- ### 📝 Commits (3) - [`b2ab3d0`](https://github.com/horizon-rust/horizon/commit/b2ab3d0d78a01e394febb829b1718a75aadc8d61) Release the item use when a keybind opens a screen - [`5288309`](https://github.com/horizon-rust/horizon/commit/5288309e8083b03effc50071f42ec92941a4cf03) Merge remote-tracking branch 'upstream/main' into fix/item-use-screen - [`66dcd82`](https://github.com/horizon-rust/horizon/commit/66dcd828ab47928700965d5fab042ec8077f0fba) e2e: cover the item use a keybind screen releases ### 📊 Changes **7 files changed** (+204 additions, -32 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-input/src/interaction_input.rs` (+13 -0) 📝 `crates/horizon-client/examples/probe/interaction_input_fixture.rs` (+18 -8) 📝 `crates/horizon-client/src/game.rs` (+6 -1) 📝 `crates/horizon-client/src/game/remote.rs` (+48 -18) 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaInteractionInputOracle.java` (+12 -0) 📝 `tools/agent_control_e2e.py` (+94 -4) 📝 `tools/test_interaction_input_parity.py` (+13 -1) </details> ### 📄 Description > 🤖 Opened by posok124521's AI agent (DeepSeek 4.1 Flash), not by posok124521 personally. ## What and why Opening the inventory while an item was in use left the use running: the window's key handling set `self.screen`, and the input tick that runs `Minecraft.handleKeybinds`' release sentence is skipped while a screen is open (`remote_handle_input` returns early when `screen != Screen::Playing`). The serving side therefore kept counting and ate the food behind the GUI (a golden apple went 64 → 63 with its effects applied while the inventory was open). Vanilla releases in the same tick the key opens the screen: `Minecraft.handleKeybinds` opens it itself (`while (keyInventory.consumeClick()) gui.setScreen(...)`; chat and advancements open from its `Gui.handleKeybinds` call), `Gui.setScreen` runs `KeyMapping.releaseAll()` (`KeyMapping.release()` does `clickCount = 0; setDown(false)`), and the same `handleKeybinds` invocation then reaches `if (player.isUsingItem()) { if (!keyUse.isDown()) gameMode.releaseUsingItem(player); }`. `MultiPlayerGameMode.releaseUsingItem` sends `ServerboundPlayerActionPacket.Action.RELEASE_USE_ITEM` and calls `player.releaseUsingItem()`; `handleKeybinds` runs before `level.tickEntities`, so the food is not completed. This adds `interaction_input::release_on_screen_open`, the release sentence of `handleKeybinds`, and calls it from the three screen opens that come from the keybinds: inventory/creative (`E`), chat (`T`, `/`, `Enter`) and advancements (`L`). Pause, server containers, mount inventories and dialogs are untouched: vanilla releases those on the first tick after closing (pause, MC-306147) or not at all (the mount inventory, MC-309593). Fixes #4472 ## Kind - [x] 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 - `Minecraft.handleKeybinds`: `Gui.handleKeybinds()` (chat `T`/`/`, advancements `L`) and the `while (keyInventory.consumeClick())` loop open screens *before* the `if (player.isUsingItem()) { if (!keyUse.isDown()) gameMode.releaseUsingItem(player); }` block, with no return between them. - `Gui.setScreen` (open branch): `mouseHandler.releaseMouse(); KeyMapping.releaseAll(); screen.init(...)` — the screen setter has no use release of its own. - `KeyMapping.releaseAll` / `KeyMapping.release`: `clickCount = 0; setDown(false);`; `Options.keyUse` is a `ToggleKeyMapping` (its `release()` resets the held state). - `Minecraft.tick`: calls `handleKeybinds()` only when `gui.overlay() == null && gui.screen() == null`, and before `level.tickEntities()`. - `MultiPlayerGameMode.releaseUsingItem` (exactly one caller, `Minecraft.handleKeybinds`): `RELEASE_USE_ITEM` packet, then `LocalPlayer.releaseUsingItem`. - `LivingEntity.releaseUsingItem` → `ItemStack.releaseUsing` → `stopUsingItem`. - `ServerGamePacketListenerImpl.handlePlayerAction` `RELEASE_USE_ITEM` → `ServerPlayer.releaseUsingItem`. - `KeyboardHandler.keyPress` opens the pause menu outside `handleKeybinds`, so it is not released in that tick (MC-306147). - Tracker corroboration: MC-306119 (Open, affects 26.3; expected "stop using items when your inventory is opened", and its queued-click corner is the one case that still starts a use with a screen open), MC-309593 (the normal inventory interrupts the eat; a mount's inventory does not), MC-306147 (pause on servers). Harness: `tools/test_interaction_input_parity.py` (extended) still runs the shipped `Minecraft.handleKeybinds` in `VanillaInteractionInputOracle` with real `KeyMapping` click counters; new rows open a screen from a keybind (`Gui.setScreen` → `KeyMapping.releaseAll`) while the use key is still held, and compare the release with `interaction_input_fixture`, which calls the same `release_on_screen_open`. The harness covers the release sentence and its ordering; it does not cover the bin's key wiring (the `E`/`T`/`L` call sites), which the live `horizon-ctl` test below covers. ## Verification Live, `horizon-ctl` on the default server-thread path (no `--in-frame`), survival, a stack of 64 golden apples, the inventory opened about 0.7 s into the 1.6 s use and kept open - before and after this change: ``` before after open+0 screen inventory, using {slot:0,ticks:8}, 64 apples screen inventory, using null, 64 apples open+0.4 using {slot:0,ticks:20}, 64 apples using null, 64 apples open+1.1 using null, 63 apples, Regeneration II + Absorption using null, 64 apples open+1.9 using null, 63 apples, effects ticking using null, 64 apples closed playing, 63 apples playing, 64 apples control eat (no GUI) 63 -> 62, effects applied (no GUI) 64 -> 63, effects applied ``` The same test after the change for the other keybind screens: - chat (`T`) opened while eating: `screen "chat"`, `using null`, 64 apples; and still 64 after 0.6 s with chat open. - pause (`Esc`): `using {slot:0, ticks:16}` stays and the world ticks stay frozen (132 → 132 over 1.2 s), then the use is released on the first tick after unpause, 64 apples - vanilla's single-player pause (released after closing, not while paused). Harness: `python tools/test_interaction_input_parity.py` → `400 interaction-input-parity cases match the pinned client (1,512 output lines)`, including the new keybind-screen rows. `git diff`: 6 files, +110 −28 (138 changed lines). Self-check: **pr_ready** (`tools/pr_ready.py --base upstream/main` on chi4a, against upstream/main at 5062f2259, 6 min 43 s) | Check | Result | | --- | --- | | Scope | ✅ 6 files, +110 −28 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 495 passed (1 min 20 s) | | rustfmt | ✅ (14 s) | | clippy | ❌ failed (5 s) | | tests: horizon-client, horizon-client-input | ❌ 832 passed, 106 failed (4 min 55 s) | | doc tests | ✅ 0 passed (3 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 | ❌ 367 affected, (2 s) | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | The 106 failing `horizon-client` tests are identical to the clean `upstream/main` baseline on this Windows machine (same MD5 of the failing list: `FF1AE6C68AD2895C4FA73186BE20473E`); CI runs them on Linux. Notes on the Windows machine this ran on: the two red rows are pre-existing here, not caused by this change - the workspace-wide clippy `-D warnings` fails on `clippy::missing_const_for_thread_local` in the untouched `horizon-core` (also on a clean `upstream/main` tree), and the 106 `horizon-client` test failures are byte-identical with and without this change (`git stash`, same list, same MD5). On the touched crates clippy is clean (`cargo clippy -p horizon-client --all-targets -- -D warnings -A clippy::missing_const_for_thread_local` exits 0) and `cargo test -p horizon-client-input` passes 58/58. CI `verify` and the maintainer's `run-parity` label will confirm on Linux; `tools/parity.py` itself needs `fcntl` and cannot run here. ## Screenshots No screenshots captured; the before/after stacks and `using` values above are the player-visible difference (the apple is no longer eaten behind the open inventory). 🤖 Generated with DeepSeek Harness (DeepSeek 4.1 Flash, model deepseek-flash). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:18:19 +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#6330
No description provided.