[PR #87] [MERGED] Read the physical Shift keys in container screens and drop a stack clicked outside #2317

Closed
opened 2026-11-02 15:54:55 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/87
Author: @ludovic111
Created: 10/14/2026
Status: ✅ Merged
Merged: 10/14/2026
Merged by: @ludovic111

Base: main ← Head: fix/physical-shift-77


📝 Commits (1)

  • d75ad77 Read the physical Shift keys in container screens and drop a stack clicked outside

📊 Changes

11 files changed (+854 additions, -22 deletions)

View changed files

➕ crates/horizon-client/examples/container_screen_probe.rs (+86 -0)
➕ crates/horizon-client/src/container_screen.rs (+278 -0)
📝 crates/horizon-client/src/game.rs (+165 -11)
📝 crates/horizon-client/src/game/control.rs (+4 -0)
📝 crates/horizon-client/src/game/item_draw.rs (+1 -3)
📝 crates/horizon-client/src/game/recipe_book.rs (+18 -3)
📝 crates/horizon-client/src/game/remote.rs (+33 -2)
📝 crates/horizon-client/src/game/station_control.rs (+3 -3)
📝 crates/horizon-client/src/lib.rs (+1 -0)
➕ mods/horizon/src/test/java/dev/horizonlab/parity/VanillaContainerScreenOracle.java (+170 -0)
➕ tools/test_container_screen_parity.py (+95 -0)

📄 Description

What was wrong (#77)

  1. Shift quick-move read remapped keys. click_inventory / inventory_press (and the recipe book's place-all and search box, the hold-Shift tooltips and the server click path) read self.keys, which holds remapped and toggled keys. Behind a screen a real Left Shift press goes to the sneak toggle mapping, which ignores presses with a screen open (keymapping.rs), and sync_toggle then removes ShiftLeft from self.keys, so with toggle sneak on, Shift-click quick-move could fail.
  2. Clicking outside the window with a carried stack did nothing. With no slot under the cursor, the press and the release returned early.

What vanilla does

  • AbstractContainerScreen.mouseClicked / mouseReleased read event.hasShiftDown() (InputWithModifiers.hasShiftDown: (modifiers() & 3) != 0, the event's physical L/R Shift); Screen.hasShiftDown likewise reads the window's physical keys.
  • hasClickedOutside (AbstractRecipeBookScreen's version on the inventory, crafting table and furnaces, where RecipeBookComponent.hasClickedOutside exempts the open book and its hovered selected tab) turns the slot id into -999. A press holding a stack starts a quick-craft drag; its release with no slots dragged sends PICKUP on -999 (Shift never quick-moves outside; an empty hand sends THROW -999, a no-op). AbstractContainerMenu.doClick: left drops the whole carried stack, right drops one (player.drop(..., true, PREDICTED) → LivingEntity.createItemStackToDrop thrown from the hand, which also swings the arm; ServerPlayer.drop adds the drop stats). A release with another button cancels the drag.

Fix

  • physical_keys tracks the physical keyboard (window key events, cleared on focus loss; the control socket's key and click-slot shift feed it), read through has_shift_down() at every container-screen Shift check (quick move on press and release, recipe book place-all and search box, tooltips, the server ContainerClick). The creative screen's trash Shift check is left to #56, which adds the same physical_keys field.
  • New horizon_client::container_screen: clicked_outside (both rules) and Clicks, the press/release state of mouseClicked/mouseReleased (quick-craft start and cancel, skip-next-release, the input sent). The inventory screens' mouse handling goes through it; a release outside drops through the verified menu engine (menu_click(None, …), slot -999), with a direct doClick fallback for screens the engine doesn't model and a predicted ContainerClick slot -999 on servers.

Tests

  • New harness tools/test_container_screen_parity.py (VanillaContainerScreenOracle + examples/container_screen_probe.rs): the real mouseClicked/mouseReleased of ContainerScreen (1–6 rows), HopperScreen, ShulkerBoxScreen and BeaconScreen with a menu slot, carried stack empty or not and every Shift modifier combination, recording each slotClicked; and hasClickedOutside of those, MerchantScreen and the recipe book screens (book visible or not, selected tab hovered or not). 4,000 cases, 58,025 lines match (1,622 PICKUP -999 left, 680 right, 2,499 THROW -999, 2,355 QUICK_MOVE).
  • The menu clicks themselves stay covered by menu_click; unit tests in container_screen.rs.
  • In game (vscreen, survival): a stack carried with the real mouse and right-clicked outside the window dropped one item, left-click dropped the rest (two item entities, 1 and 31); real-mouse pickup/place on slots and Shift+click quick move (Shift through the control socket) behave as before.
  • cargo fmt --check, cargo clippy --workspace --all-targets --locked -D warnings, cargo test --workspace --locked and tools/check_public_tree.py pass.

Fixes #77

🤖 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/87 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/14/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/physical-shift-77` --- ### 📝 Commits (1) - [`d75ad77`](https://github.com/horizon-rust/horizon/commit/d75ad778e3d12d7c869e665f7bab4ecf8d417334) Read the physical Shift keys in container screens and drop a stack clicked outside ### 📊 Changes **11 files changed** (+854 additions, -22 deletions) <details> <summary>View changed files</summary> ➕ `crates/horizon-client/examples/container_screen_probe.rs` (+86 -0) ➕ `crates/horizon-client/src/container_screen.rs` (+278 -0) 📝 `crates/horizon-client/src/game.rs` (+165 -11) 📝 `crates/horizon-client/src/game/control.rs` (+4 -0) 📝 `crates/horizon-client/src/game/item_draw.rs` (+1 -3) 📝 `crates/horizon-client/src/game/recipe_book.rs` (+18 -3) 📝 `crates/horizon-client/src/game/remote.rs` (+33 -2) 📝 `crates/horizon-client/src/game/station_control.rs` (+3 -3) 📝 `crates/horizon-client/src/lib.rs` (+1 -0) ➕ `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaContainerScreenOracle.java` (+170 -0) ➕ `tools/test_container_screen_parity.py` (+95 -0) </details> ### 📄 Description ## What was wrong (#77) 1. **Shift quick-move read remapped keys.** `click_inventory` / `inventory_press` (and the recipe book's place-all and search box, the hold-Shift tooltips and the server click path) read `self.keys`, which holds remapped and toggled keys. Behind a screen a real Left Shift press goes to the sneak toggle mapping, which ignores presses with a screen open (`keymapping.rs`), and `sync_toggle` then removes `ShiftLeft` from `self.keys`, so with toggle sneak on, Shift-click quick-move could fail. 2. **Clicking outside the window with a carried stack did nothing.** With no slot under the cursor, the press and the release returned early. ## What vanilla does - `AbstractContainerScreen.mouseClicked` / `mouseReleased` read `event.hasShiftDown()` (`InputWithModifiers.hasShiftDown`: `(modifiers() & 3) != 0`, the event's physical L/R Shift); `Screen.hasShiftDown` likewise reads the window's physical keys. - `hasClickedOutside` (`AbstractRecipeBookScreen`'s version on the inventory, crafting table and furnaces, where `RecipeBookComponent.hasClickedOutside` exempts the open book and its hovered selected tab) turns the slot id into **-999**. A press holding a stack starts a quick-craft drag; its release with no slots dragged sends `PICKUP` on -999 (Shift never quick-moves outside; an empty hand sends `THROW` -999, a no-op). `AbstractContainerMenu.doClick`: left drops the whole carried stack, right drops one (`player.drop(..., true, PREDICTED)` → `LivingEntity.createItemStackToDrop` thrown from the hand, which also swings the arm; `ServerPlayer.drop` adds the drop stats). A release with another button cancels the drag. ## Fix - `physical_keys` tracks the physical keyboard (window key events, cleared on focus loss; the control socket's `key` and `click-slot shift` feed it), read through `has_shift_down()` at every container-screen Shift check (quick move on press and release, recipe book place-all and search box, tooltips, the server `ContainerClick`). The creative screen's trash Shift check is left to #56, which adds the same `physical_keys` field. - New `horizon_client::container_screen`: `clicked_outside` (both rules) and `Clicks`, the press/release state of `mouseClicked`/`mouseReleased` (quick-craft start and cancel, skip-next-release, the input sent). The inventory screens' mouse handling goes through it; a release outside drops through the verified menu engine (`menu_click(None, …)`, slot -999), with a direct `doClick` fallback for screens the engine doesn't model and a predicted `ContainerClick` slot -999 on servers. ## Tests - New harness `tools/test_container_screen_parity.py` (`VanillaContainerScreenOracle` + `examples/container_screen_probe.rs`): the real `mouseClicked`/`mouseReleased` of `ContainerScreen` (1–6 rows), `HopperScreen`, `ShulkerBoxScreen` and `BeaconScreen` with a menu slot, carried stack empty or not and every Shift modifier combination, recording each `slotClicked`; and `hasClickedOutside` of those, `MerchantScreen` and the recipe book screens (book visible or not, selected tab hovered or not). 4,000 cases, 58,025 lines match (1,622 `PICKUP -999` left, 680 right, 2,499 `THROW -999`, 2,355 `QUICK_MOVE`). - The menu clicks themselves stay covered by `menu_click`; unit tests in `container_screen.rs`. - In game (vscreen, survival): a stack carried with the real mouse and right-clicked outside the window dropped one item, left-click dropped the rest (two item entities, 1 and 31); real-mouse pickup/place on slots and Shift+click quick move (Shift through the control socket) behave as before. - `cargo fmt --check`, `cargo clippy --workspace --all-targets --locked -D warnings`, `cargo test --workspace --locked` and `tools/check_public_tree.py` pass. Fixes #77 🤖 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-02 15:54:55 +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#2317
No description provided.