[PR #1513] [MERGED] Closing a menu puts a server's player's cursor stack back into their inventory #3561

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

📋 Pull Request Information

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

Base: main ← Head: fix/st-cursor-close


📝 Commits (10+)

  • c86996c Fishing on a server's players: a hook per player, ticked on the server and drawn by its clients
  • 287d7a7 Maps on a server's players: each holder's map ticks on the server and its data reaches them
  • fa4ea80 A server's player's client sets its body as in frame: look pitch, use slowdown, boots on powder snow
  • f96101c Strikes and mob effects reach a server's players: lightning, evoker fangs, poison, axolotls
  • c6ed311 Closing a menu puts a server's player's cursor stack back into their inventory
  • 8c81cc6 Merge remote-tracking branch 'origin/fix/st-wind-charge' into fix/st-fishing
  • 26a91e3 Merge remote-tracking branch 'origin/fix/st-fishing' into fix/st-maps
  • e307f03 Merge remote-tracking branch 'origin/fix/st-maps' into fix/st-player-body
  • d65be41 Merge remote-tracking branch 'origin/fix/st-player-body' into fix/st-hits
  • 45e5b64 Merge remote-tracking branch 'origin/fix/st-hits' into fix/st-cursor-close

📊 Changes

12 files changed (+1004 additions, -172 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+53 -37)
📝 crates/horizon-client/src/game/control.rs (+1 -0)
📝 crates/horizon-client/src/game/fangs.rs (+12 -6)
📝 crates/horizon-client/src/game/fishing.rs (+241 -41)
📝 crates/horizon-client/src/game/lan.rs (+2 -0)
📝 crates/horizon-client/src/game/lan_actions.rs (+25 -12)
📝 crates/horizon-client/src/game/lan_mobs.rs (+21 -0)
📝 crates/horizon-client/src/game/lightning.rs (+22 -16)
📝 crates/horizon-client/src/game/maps.rs (+321 -50)
📝 crates/horizon-client/src/game/remote.rs (+1 -10)
📝 crates/horizon-client/src/game/remote_projectiles.rs (+7 -0)
📝 tools/lan_e2e.py (+298 -0)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Fixes #1283.

What

On a server (LAN guests, and single player on its server thread), closing the inventory or any menu while holding a stack on the cursor now puts the stack back into the player's inventory. Before, it was thrown into the world and a copy stayed on the cursor.

Why

Checked against vanilla 26.3 first:

  • AbstractContainerMenu.removed hands the carried stack to dropOrPlaceInInventory;
  • for a player who is still there, that is Inventory.placeItemBackInInventory, which drops only what doesn't fit;
  • broadcastChanges then sends the emptied cursor to the client.

The LAN host's ContainerClose arms dropped carried at the player's eyes instead. That covers the inventory, containers, crafting, workstations, mounts and merchants. The client also kept showing its own copy, because nothing told it the cursor was empty.

How

guest_carried_back replaces the three drops:

  • lan_place_back puts the stack back into the inventory (the same path the workstations already used for their inputs);
  • send_inventory sends the inventory with its now-empty carried stack.

A player who leaves still has everything placed back, by lan_crafting_left.

Evidence

lan_e2e --check cursor, for each player:

  • put 7 diamonds in hotbar slot 0;
  • open the inventory and click the slot, so the stack is on the cursor;
  • press Escape and wait 40 ticks;
  • read the cursor and the diamonds on the client, the diamonds on the server (clear … 0), and the item entities within 8 blocks.
in-frame host in-frame guest --server-thread host --server-thread guest
before (the strikes PR's head) back in the inventory, cursor empty server 0, cursor still 7 server 0, cursor still 7 server 0, cursor still 7
after inventory 7 (client and server), cursor empty, nothing thrown same same same

Before the fix, the thrown stack had despawned or been picked back up by the time the check counted item entities. The server's count of 0 is what shows the loss.

How tested

On the top of the stack (feat/st-default a4a101ca9, which contains this branch), on the Mac mini:

  • cargo fmt --all -- --check: clean.
  • cargo clippy --workspace --all-targets -- -D warnings: clean.
  • cargo test -p horizon-client --lib --bins: 1064 + 98 + 18 passed.
  • tools/parity.py --changed origin/main: 106/106 passed on the maps head, then 30/30 for the harnesses whose inputs changed after that.
  • tools/lan_e2e.py in the frame and with --server-thread: wind, fishing, maps, body, strikes and cursor pass in both. boats and minecarts pass with --server-thread.
  • A scripted single player session (walk, mine, place, inventory, combat, eating, boats, minecarts, chests, furnaces, beds, chat, signs, books, totems, keep_inventory, fishing, maps, then save and reopen): 48/48 on the server thread and 48/48 with --in-frame.

Stack

On top of the strikes PR (#1512). Merge order: … → #1511 → #1512 → this.

Needs Ludovic

A review and a merge, in stack order.

🤖 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/1513 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/23/2026 **Status:** ✅ Merged **Merged:** 10/24/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/st-cursor-close` --- ### 📝 Commits (10+) - [`c86996c`](https://github.com/horizon-rust/horizon/commit/c86996c234457b08dafcae375a36ebdbe8fcadd9) Fishing on a server's players: a hook per player, ticked on the server and drawn by its clients - [`287d7a7`](https://github.com/horizon-rust/horizon/commit/287d7a7eb5e55a7936e89c9ac948f2a66aab74d1) Maps on a server's players: each holder's map ticks on the server and its data reaches them - [`fa4ea80`](https://github.com/horizon-rust/horizon/commit/fa4ea80d3253ea3a65b0663454f4a03c4e52c4b2) A server's player's client sets its body as in frame: look pitch, use slowdown, boots on powder snow - [`f96101c`](https://github.com/horizon-rust/horizon/commit/f96101cd47f35e998ac1f032f92ce7a4de82f89e) Strikes and mob effects reach a server's players: lightning, evoker fangs, poison, axolotls - [`c6ed311`](https://github.com/horizon-rust/horizon/commit/c6ed3112e7891b4d96de16cee5e16f948bbe12c7) Closing a menu puts a server's player's cursor stack back into their inventory - [`8c81cc6`](https://github.com/horizon-rust/horizon/commit/8c81cc63f71f8f4c4c75a30f14406ed8cf3eaf88) Merge remote-tracking branch 'origin/fix/st-wind-charge' into fix/st-fishing - [`26a91e3`](https://github.com/horizon-rust/horizon/commit/26a91e3a08059af6f43af950593665774b58d1fe) Merge remote-tracking branch 'origin/fix/st-fishing' into fix/st-maps - [`e307f03`](https://github.com/horizon-rust/horizon/commit/e307f036842c53942079b1179c3feea9dcd0930e) Merge remote-tracking branch 'origin/fix/st-maps' into fix/st-player-body - [`d65be41`](https://github.com/horizon-rust/horizon/commit/d65be4183fecfd3256c204e996442bef7bc087c1) Merge remote-tracking branch 'origin/fix/st-player-body' into fix/st-hits - [`45e5b64`](https://github.com/horizon-rust/horizon/commit/45e5b6452068107bee6f53d7b0841e6aa913d003) Merge remote-tracking branch 'origin/fix/st-hits' into fix/st-cursor-close ### 📊 Changes **12 files changed** (+1004 additions, -172 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+53 -37) 📝 `crates/horizon-client/src/game/control.rs` (+1 -0) 📝 `crates/horizon-client/src/game/fangs.rs` (+12 -6) 📝 `crates/horizon-client/src/game/fishing.rs` (+241 -41) 📝 `crates/horizon-client/src/game/lan.rs` (+2 -0) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+25 -12) 📝 `crates/horizon-client/src/game/lan_mobs.rs` (+21 -0) 📝 `crates/horizon-client/src/game/lightning.rs` (+22 -16) 📝 `crates/horizon-client/src/game/maps.rs` (+321 -50) 📝 `crates/horizon-client/src/game/remote.rs` (+1 -10) 📝 `crates/horizon-client/src/game/remote_projectiles.rs` (+7 -0) 📝 `tools/lan_e2e.py` (+298 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Fixes #1283. ## What On a server (LAN guests, and single player on its server thread), closing the inventory or any menu while holding a stack on the cursor now puts the stack back into the player's inventory. Before, it was thrown into the world and a copy stayed on the cursor. ## Why Checked against vanilla 26.3 first: - `AbstractContainerMenu.removed` hands the carried stack to `dropOrPlaceInInventory`; - for a player who is still there, that is `Inventory.placeItemBackInInventory`, which drops only what doesn't fit; - `broadcastChanges` then sends the emptied cursor to the client. The LAN host's `ContainerClose` arms dropped `carried` at the player's eyes instead. That covers the inventory, containers, crafting, workstations, mounts and merchants. The client also kept showing its own copy, because nothing told it the cursor was empty. ## How `guest_carried_back` replaces the three drops: - `lan_place_back` puts the stack back into the inventory (the same path the workstations already used for their inputs); - `send_inventory` sends the inventory with its now-empty carried stack. A player who leaves still has everything placed back, by `lan_crafting_left`. ## Evidence `lan_e2e --check cursor`, for each player: - put 7 diamonds in hotbar slot 0; - open the inventory and click the slot, so the stack is on the cursor; - press Escape and wait 40 ticks; - read the cursor and the diamonds on the client, the diamonds on the server (`clear … 0`), and the item entities within 8 blocks. | | in-frame host | in-frame guest | `--server-thread` host | `--server-thread` guest | |---|---|---|---|---| | **before** (the strikes PR's head) | back in the inventory, cursor empty | **server 0, cursor still 7** | **server 0, cursor still 7** | **server 0, cursor still 7** | | **after** | inventory 7 (client and server), cursor empty, nothing thrown | same | same | same | Before the fix, the thrown stack had despawned or been picked back up by the time the check counted item entities. The server's count of 0 is what shows the loss. ## How tested On the top of the stack (`feat/st-default` a4a101ca9, which contains this branch), on the Mac mini: - `cargo fmt --all -- --check`: clean. - `cargo clippy --workspace --all-targets -- -D warnings`: clean. - `cargo test -p horizon-client --lib --bins`: 1064 + 98 + 18 passed. - `tools/parity.py --changed origin/main`: 106/106 passed on the maps head, then 30/30 for the harnesses whose inputs changed after that. - `tools/lan_e2e.py` in the frame and with `--server-thread`: `wind`, `fishing`, `maps`, `body`, `strikes` and `cursor` pass in both. `boats` and `minecarts` pass with `--server-thread`. - A scripted single player session (walk, mine, place, inventory, combat, eating, boats, minecarts, chests, furnaces, beds, chat, signs, books, totems, keep_inventory, fishing, maps, then save and reopen): 48/48 on the server thread and 48/48 with `--in-frame`. ## Stack On top of the strikes PR (#1512). Merge order: … → #1511 → #1512 → **this**. ## Needs Ludovic A review and a merge, in stack order. 🤖 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 04:10: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#3561
No description provided.