[PR #695] [MERGED] LAN: another player's chest or crafting table no longer takes your mouse (#687) #2736

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

📋 Pull Request Information

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

Base: main ← Head: fix/other-player-container


📝 Commits (2)

  • 45cbb4f LAN: a guest's chest, crafting table or sign no longer takes the host's mouse (#687)
  • 9240aeb Input capture test: the mock Game has lan_acting (#687)

📊 Changes

5 files changed (+65 additions, -14 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+5 -0)
📝 crates/horizon-client/src/game/agent.rs (+3 -0)
📝 crates/horizon-client/src/game/lan_actions.rs (+15 -8)
📝 tests/test_world_input_capture.py (+2 -2)
📝 tools/lan_e2e.py (+40 -4)

📄 Description

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

Fixes #687: on a LAN world, when another player opened a chest, a crafting table or any other menu, the host's cursor appeared and their camera stopped moving.

Cause

A guest's actions run on the host's game, with the guest's state swapped in (as_guest in game/lan_actions.rs). The swap put the host's open screen back afterwards, but not what opening a screen does to the window:

  • capture(false) released the host's pointer, so the cursor showed and mouse movement stopped turning the camera, while the screen still said "playing";
  • keys.clear() dropped the keys the host was holding (the host stopped walking);
  • a sign the guest placed opened the sign editor on the host's screen. A book, a command block or a mount menu the guest opened did the same.

In vanilla, ServerPlayer.openMenu only sends ClientboundOpenScreenPacket to the player who opened it. The hub already sent it only to that guest; the leak was on the host's own window.

The reporter also saw it on "multiplayer servers". A dedicated server (and single player on --server-thread) has no window, so the pointer can't be taken there. The other leaks (held keys, sign editor) were fixed for those too.

Fix

  • capture leaves the window alone while a guest acts (lan_acting): the guest's own client grabs or releases its pointer.
  • as_guest keeps the host's held keys, sign editor, book, command block screen and mount menu, as it already kept the open screen. The guest holds only its sneak key during its action, as before.
  • horizon-ctl state reports pointer_grabbed (whether mouse movement turns the camera: the real pointer is grabbed, or an agent's mouse-move stands in for it).

Harness (tools/lan_e2e.py)

  • chest and crafting: after the guest opens its chest or crafting table, the host still shows playing and keeps pointer_grabbed.
  • New sign check: the guest places a sign; the host doesn't get the sign screen.

On origin/main all three fail as the report describes:

[lan] chest: FAIL AssertionError("the guest's chest released the host's pointer")
[lan] crafting: FAIL AssertionError("the guest's crafting table released the host's pointer")
[lan] sign: FAIL AssertionError("the guest's sign opened the sign screen on the host")

With this PR all three pass (Mac mini, offscreen, two games).

Checks

  • cargo fmt --all --check: ok
  • cargo clippy --workspace --all-targets -- -D warnings: ok
  • cargo test -p horizon-client --lib: 812 passed, 0 failed
  • Local parity (tools/parity.py --changed origin/main, 16 harnesses): running, the result follows in a comment.

🤖 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/695 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/17/2026 **Status:** ✅ Merged **Merged:** 10/17/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/other-player-container` --- ### 📝 Commits (2) - [`45cbb4f`](https://github.com/horizon-rust/horizon/commit/45cbb4f7d668cf578c8b8e7fca8f65d9112385fa) LAN: a guest's chest, crafting table or sign no longer takes the host's mouse (#687) - [`9240aeb`](https://github.com/horizon-rust/horizon/commit/9240aeb9ff8b315b38895dd24e64243a46bbd49b) Input capture test: the mock Game has lan_acting (#687) ### 📊 Changes **5 files changed** (+65 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+5 -0) 📝 `crates/horizon-client/src/game/agent.rs` (+3 -0) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+15 -8) 📝 `tests/test_world_input_capture.py` (+2 -2) 📝 `tools/lan_e2e.py` (+40 -4) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Fixes #687: on a LAN world, when another player opened a chest, a crafting table or any other menu, the host's cursor appeared and their camera stopped moving. ## Cause A guest's actions run on the host's game, with the guest's state swapped in (`as_guest` in `game/lan_actions.rs`). The swap put the host's open screen back afterwards, but not what opening a screen does to the window: - `capture(false)` released the host's pointer, so the cursor showed and mouse movement stopped turning the camera, while the screen still said "playing"; - `keys.clear()` dropped the keys the host was holding (the host stopped walking); - a sign the guest placed opened the sign editor on the host's screen. A book, a command block or a mount menu the guest opened did the same. In vanilla, `ServerPlayer.openMenu` only sends `ClientboundOpenScreenPacket` to the player who opened it. The hub already sent it only to that guest; the leak was on the host's own window. The reporter also saw it on "multiplayer servers". A dedicated server (and single player on `--server-thread`) has no window, so the pointer can't be taken there. The other leaks (held keys, sign editor) were fixed for those too. ## Fix - `capture` leaves the window alone while a guest acts (`lan_acting`): the guest's own client grabs or releases its pointer. - `as_guest` keeps the host's held keys, sign editor, book, command block screen and mount menu, as it already kept the open screen. The guest holds only its sneak key during its action, as before. - `horizon-ctl state` reports `pointer_grabbed` (whether mouse movement turns the camera: the real pointer is grabbed, or an agent's `mouse-move` stands in for it). ## Harness (`tools/lan_e2e.py`) - `chest` and `crafting`: after the guest opens its chest or crafting table, the host still shows `playing` and keeps `pointer_grabbed`. - New `sign` check: the guest places a sign; the host doesn't get the sign screen. On origin/main all three fail as the report describes: ``` [lan] chest: FAIL AssertionError("the guest's chest released the host's pointer") [lan] crafting: FAIL AssertionError("the guest's crafting table released the host's pointer") [lan] sign: FAIL AssertionError("the guest's sign opened the sign screen on the host") ``` With this PR all three pass (Mac mini, offscreen, two games). ## Checks - `cargo fmt --all --check`: ok - `cargo clippy --workspace --all-targets -- -D warnings`: ok - `cargo test -p horizon-client --lib`: 812 passed, 0 failed - Local parity (`tools/parity.py --changed origin/main`, 16 harnesses): running, the result follows in a comment. 🤖 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:58:40 +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#2736
No description provided.