[PR #3453] [MERGED] Swing the hand when Q drops a stack from an inventory slot on a server #4992

Closed
opened 2026-11-03 05:09:26 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix-3357


📝 Commits (2)

  • 7211d02 Swing the hand when Q drops a stack from an inventory slot on a server
  • 0c06082 Merge main into this branch

📊 Changes

1 file changed (+95 additions, -10 deletions)

View changed files

📝 crates/horizon-client/src/game/remote.rs (+95 -10)

📄 Description

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

What and why

Fixes #3357

On a server (single player included, since it runs on its server thread), pressing Q over a slot in the inventory dropped the item, but the arm didn't swing. Q in the world swings, and so does clicking outside the window with a carried stack.

A menu click on a server goes through remote_menu_ops. The menu engine predicts the click and sends it. In menu_session, the drops of a predicted click are skipped (the server makes the item entity), and nothing else swings the hand. Only the slot -999 path (remote_throw) called swing_arm.

The prediction loop of remote_menu_ops is now a function, predict_clicks. It also reports whether a click dropped a stack. When one did, remote_menu_ops swings the main hand. This covers Q and Ctrl+Q over a slot, plus the other drops doClick predicts: a hotbar swap or a result-slot move with no room left.

Vanilla reference

  • AbstractContainerMenu.doClick: every drop in a click is player.drop(stack, true, Prediction.PREDICTED). That includes THROW over a slot (both buttons), the click outside the window (slot -999) and a SWAP whose stack doesn't fit back.
  • LivingEntity.drop(ItemStack, boolean, Prediction): swing(InteractionHand.MAIN_HAND, SwingAnimation.DEFAULT, prediction != Prediction.PREDICTED). It does this before the isClientSide return, so the client predicting the click swings its own arm.
  • LivingEntity.swing(InteractionHand, SwingAnimation, boolean): on the server, false sends the swing with sendToTrackingPlayers only, not to the player itself. So the local player has to swing on their own.

Read with javap -c on the 26.3 client jar. No harness covers client-side swing prediction.

New test: game::remote::tests::a_predicted_throw_from_a_slot_swings_the_hand (InventoryMenu on the prepared items). It checks three clicks: THROW from a hotbar slot drops and swings, a pickup doesn't, and a right click outside the window does.

Before: predict_clicks with main's behaviour, where the drop isn't reported:

test game::remote::tests::a_predicted_throw_from_a_slot_swings_the_hand ... FAILED
panicked at crates\horizon-client\src\game\remote.rs:6579:9:
Q over a slot drops one and swings

After:

test game::remote::tests::a_predicted_throw_from_a_slot_swings_the_hand ... ok

Self-check

Run on Windows 11. tools/pr_ready.py and tools/parity.py stop on Windows at signal.SIGHUP, so I ran the steps by hand:

cargo fmt --all -- --check                                                      ok
cargo clippy -p horizon-client --features mods --all-targets -- -D warnings     ok
cargo test -p horizon-client --features mods --bin horizon-client               140 passed, 3 ignored
python3 tools/check_public_tree.py                                              passed

Screenshots

Nothing to see in a still image, so here is the swings counter from horizon-ctl state (LivingEntity.swing starts). Singleplayer Survival, 16 cobblestone in the hotbar. The fast build ran against the v0.2.97 prepared resources.

action main (791d8b895) this branch
Q in the world 0 → 1, dropped 0 → 1, dropped
Q over a hotbar slot in the inventory 1 → 1, dropped (15 → 14) 1 → 2, dropped (15 → 14)
click outside the window with the stack 1 → 2 2 → 3

horizon-ctl state swing counter, main:

world Q: swings 0 -> 1, cobble=15 carried=
over slot 1: cobble=15 carried=
inventory Q over slot: swings 1 -> 1, cobble=14 carried=
inventory click outside with a carried stack: swings 1 -> 2, cobble= carried=

This branch:

world Q: swings 0 -> 1, cobble=15 carried=
over slot 1: cobble=15 carried=
inventory Q over slot: swings 1 -> 2, cobble=14 carried=
inventory click outside with a carried stack: swings 2 -> 3, cobble= carried=

🤖 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/3453 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix-3357` --- ### 📝 Commits (2) - [`7211d02`](https://github.com/horizon-rust/horizon/commit/7211d029abb4dd0e323e064c82d94beb4ede676c) Swing the hand when Q drops a stack from an inventory slot on a server - [`0c06082`](https://github.com/horizon-rust/horizon/commit/0c06082dfa2a75f065282fbad54d04f7664ee717) Merge main into this branch ### 📊 Changes **1 file changed** (+95 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/remote.rs` (+95 -10) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. ## What and why Fixes #3357 On a server (single player included, since it runs on its server thread), pressing Q over a slot in the inventory dropped the item, but the arm didn't swing. Q in the world swings, and so does clicking outside the window with a carried stack. A menu click on a server goes through `remote_menu_ops`. The menu engine predicts the click and sends it. In `menu_session`, the drops of a predicted click are skipped (the server makes the item entity), and nothing else swings the hand. Only the slot -999 path (`remote_throw`) called `swing_arm`. The prediction loop of `remote_menu_ops` is now a function, `predict_clicks`. It also reports whether a click dropped a stack. When one did, `remote_menu_ops` swings the main hand. This covers Q and Ctrl+Q over a slot, plus the other drops `doClick` predicts: a hotbar swap or a result-slot move with no room left. ## Vanilla reference - `AbstractContainerMenu.doClick`: every drop in a click is `player.drop(stack, true, Prediction.PREDICTED)`. That includes THROW over a slot (both buttons), the click outside the window (slot -999) and a SWAP whose stack doesn't fit back. - `LivingEntity.drop(ItemStack, boolean, Prediction)`: `swing(InteractionHand.MAIN_HAND, SwingAnimation.DEFAULT, prediction != Prediction.PREDICTED)`. It does this before the `isClientSide` return, so the client predicting the click swings its own arm. - `LivingEntity.swing(InteractionHand, SwingAnimation, boolean)`: on the server, `false` sends the swing with `sendToTrackingPlayers` only, not to the player itself. So the local player has to swing on their own. Read with `javap -c` on the 26.3 client jar. No harness covers client-side swing prediction. New test: `game::remote::tests::a_predicted_throw_from_a_slot_swings_the_hand` (`InventoryMenu` on the prepared items). It checks three clicks: THROW from a hotbar slot drops and swings, a pickup doesn't, and a right click outside the window does. Before: `predict_clicks` with main's behaviour, where the drop isn't reported: ``` test game::remote::tests::a_predicted_throw_from_a_slot_swings_the_hand ... FAILED panicked at crates\horizon-client\src\game\remote.rs:6579:9: Q over a slot drops one and swings ``` After: ``` test game::remote::tests::a_predicted_throw_from_a_slot_swings_the_hand ... ok ``` ## Self-check Run on Windows 11. `tools/pr_ready.py` and `tools/parity.py` stop on Windows at `signal.SIGHUP`, so I ran the steps by hand: ``` cargo fmt --all -- --check ok cargo clippy -p horizon-client --features mods --all-targets -- -D warnings ok cargo test -p horizon-client --features mods --bin horizon-client 140 passed, 3 ignored python3 tools/check_public_tree.py passed ``` ## Screenshots Nothing to see in a still image, so here is the `swings` counter from `horizon-ctl state` (`LivingEntity.swing` starts). Singleplayer Survival, 16 cobblestone in the hotbar. The `fast` build ran against the v0.2.97 prepared resources. | action | main (791d8b895) | this branch | |---|---|---| | Q in the world | 0 → 1, dropped | 0 → 1, dropped | | Q over a hotbar slot in the inventory | **1 → 1**, dropped (15 → 14) | **1 → 2**, dropped (15 → 14) | | click outside the window with the stack | 1 → 2 | 2 → 3 | `horizon-ctl state` swing counter, main: ``` world Q: swings 0 -> 1, cobble=15 carried= over slot 1: cobble=15 carried= inventory Q over slot: swings 1 -> 1, cobble=14 carried= inventory click outside with a carried stack: swings 1 -> 2, cobble= carried= ``` This branch: ``` world Q: swings 0 -> 1, cobble=15 carried= over slot 1: cobble=15 carried= inventory Q over slot: swings 1 -> 2, cobble=14 carried= inventory click outside with a carried stack: swings 2 -> 3, cobble= carried= ``` 🤖 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 05:09:26 +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#4992
No description provided.