[PR #1466] [MERGED] Books open on a server's players, and what they write and sign reaches the server #3543

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

📋 Pull Request Information

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

Base: main ← Head: fix/st-books


📝 Commits (4)

  • b8e729b Totems save a server's players: the guest's turn uses it up, and entity event 35 reaches every client
  • de358cd A server's players drop their inventory on death unless keep_inventory is on
  • 52d8ed6 Signs open their editor on a server's players, and what they write reaches the server
  • 5617d70 Books open on a server's players, and what they write and sign reaches the server

📊 Changes

13 files changed (+706 additions, -84 deletions)

View changed files

📝 crates/horizon-client/src/audio.rs (+7 -0)
📝 crates/horizon-client/src/game.rs (+26 -16)
📝 crates/horizon-client/src/game/agent.rs (+6 -0)
📝 crates/horizon-client/src/game/books.rs (+124 -29)
📝 crates/horizon-client/src/game/control.rs (+12 -1)
📝 crates/horizon-client/src/game/lan_actions.rs (+28 -1)
📝 crates/horizon-client/src/game/lan_stations.rs (+16 -11)
📝 crates/horizon-client/src/game/remote.rs (+9 -1)
📝 crates/horizon-client/src/game/sign_edit.rs (+86 -4)
📝 crates/horizon-client/src/game/station_control.rs (+1 -1)
📝 crates/horizon-client/src/game/totem.rs (+79 -20)
📝 crates/horizon-protocol/src/packets/play.rs (+112 -0)
📝 tools/lan_e2e.py (+200 -0)

📄 Description

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

Fixes #1366.

What

Book and quill and written books now work for a server's players, LAN guests and the server-thread host. The book opens, and the pages and title they write and sign reach the server, so other players see the written book.

Why

Horizon had no ClientboundOpenBookPacket and no ServerboundEditBookPacket. Using a book during a guest's turn opened the screen on the host's window instead, and nothing a remote client wrote ever left it.

How

  • Protocol:
    • OpenBook is the hand, as a VarInt.
    • EditBook is a VarInt slot, then up to 100 × stringUtf8(1024) pages, then an optional stringUtf8(32) title.
    • Both match vanilla 26.3's codecs; a round-trip test covers them.
  • Client (LocalPlayer.openItemGui): a book and quill opens its editor on the client itself. Saving or signing it sends EditBook with the selected hotbar slot, or 40 for the off hand.
  • Server (ServerPlayer.openItemGui, handleEditBook):
    • a written book used during a guest's turn sends OpenBook for that hand;
    • EditBook is accepted only for a hotbar slot or slot 40;
    • when it carries a title, it signs the book (signBook), with the player as the author; otherwise it updates the pages.
  • Harness: horizon-ctl book sign|done drive signing.

Evidence

lan_e2e --check books has each side:

  • write a book and quill and sign it;
  • open the written book;
  • drop it, and read the dropped item's components from the other window.
before, in-frame before, --server-thread after (both modes)
host fails (left on the previous check's sign screen) no book screen opens edit, sign, view; written_book 1; the other side reads the text
guest not reached not reached same

Both "before" runs stopped at the host's step. In the issue's repro, the guest's window has no way to open a book at all, because nothing ever sends OpenBook.

How tested

Self-check on the top of the stack (fix/st-books, which contains this PR), Mac mini M4 Pro:

  • cargo fmt --all --check: OK
  • cargo clippy --workspace --all-targets -- -D warnings: OK
  • cargo test -p horizon-protocol: 71 passed. cargo test -p horizon-client --lib: 1061 passed (26 ignored). --bins: 98 + 18 passed.
  • python3 tools/parity.py --changed origin/main: 106 harnesses, 106 passed, 0 failed (23 min).
  • tools/lan_e2e.py, the new checks in both modes (in-frame, then --server-thread), host and guest; the existing sign and lectern checks still pass. Before = origin/main b65e082fd built with the same profile, after = this stack.

Stack

Four small PRs, one fix each, each on top of the previous one (the new lan_e2e checks share one block at the end of the file). Merge in order: #1463 (totem) → #1464 (keep_inventory) → #1465 (signs) → #1466 (books). The change for each PR is its top commit. #1475 (Elytra) and #1476 (shields, tridents, crossbows, spyglasses) continue the stack after #1466.

They leave alone the lines that #1419, #1420 and #1423–#1427 change in tools/lan_e2e.py. The new checks go in a block before if __name__ (CHECKS += [...], CHECK_FNS.update(...)). git merge-tree is clean against each of #1423–#1427. #1419 and #1420 already conflict with main on their own.

Needs Ludovic

A review and a merge, in stack order. Nothing else.

🤖 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/1466 **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-books` --- ### 📝 Commits (4) - [`b8e729b`](https://github.com/horizon-rust/horizon/commit/b8e729b950284890ec79d11e4bb448e3a3e4782c) Totems save a server's players: the guest's turn uses it up, and entity event 35 reaches every client - [`de358cd`](https://github.com/horizon-rust/horizon/commit/de358cd72127156cd9c27ecd662ee73b86adb113) A server's players drop their inventory on death unless keep_inventory is on - [`52d8ed6`](https://github.com/horizon-rust/horizon/commit/52d8ed6721be9b7db334284f14b0fb271ba13f86) Signs open their editor on a server's players, and what they write reaches the server - [`5617d70`](https://github.com/horizon-rust/horizon/commit/5617d702cc62e676de8c24c4506ad055a62617b8) Books open on a server's players, and what they write and sign reaches the server ### 📊 Changes **13 files changed** (+706 additions, -84 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/audio.rs` (+7 -0) 📝 `crates/horizon-client/src/game.rs` (+26 -16) 📝 `crates/horizon-client/src/game/agent.rs` (+6 -0) 📝 `crates/horizon-client/src/game/books.rs` (+124 -29) 📝 `crates/horizon-client/src/game/control.rs` (+12 -1) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+28 -1) 📝 `crates/horizon-client/src/game/lan_stations.rs` (+16 -11) 📝 `crates/horizon-client/src/game/remote.rs` (+9 -1) 📝 `crates/horizon-client/src/game/sign_edit.rs` (+86 -4) 📝 `crates/horizon-client/src/game/station_control.rs` (+1 -1) 📝 `crates/horizon-client/src/game/totem.rs` (+79 -20) 📝 `crates/horizon-protocol/src/packets/play.rs` (+112 -0) 📝 `tools/lan_e2e.py` (+200 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Fixes #1366. ## What Book and quill and written books now work for a server's players, LAN guests and the server-thread host. The book opens, and the pages and title they write and sign reach the server, so other players see the written book. ## Why Horizon had no `ClientboundOpenBookPacket` and no `ServerboundEditBookPacket`. Using a book during a guest's turn opened the screen on the host's window instead, and nothing a remote client wrote ever left it. ## How - **Protocol:** - `OpenBook` is the hand, as a VarInt. - `EditBook` is a VarInt slot, then up to 100 × `stringUtf8(1024)` pages, then an optional `stringUtf8(32)` title. - Both match vanilla 26.3's codecs; a round-trip test covers them. - **Client** (`LocalPlayer.openItemGui`): a book and quill opens its editor on the client itself. Saving or signing it sends `EditBook` with the selected hotbar slot, or 40 for the off hand. - **Server** (`ServerPlayer.openItemGui`, `handleEditBook`): - a written book used during a guest's turn sends `OpenBook` for that hand; - `EditBook` is accepted only for a hotbar slot or slot 40; - when it carries a title, it signs the book (`signBook`), with the player as the author; otherwise it updates the pages. - **Harness:** `horizon-ctl book sign|done` drive signing. ## Evidence `lan_e2e --check books` has each side: - write a book and quill and sign it; - open the written book; - drop it, and read the dropped item's components from the other window. | | before, in-frame | before, `--server-thread` | after (both modes) | |---|---|---|---| | host | fails (left on the previous check's sign screen) | **no book screen opens** | edit, sign, view; `written_book 1`; the other side reads the text | | guest | not reached | not reached | same | Both "before" runs stopped at the host's step. In the issue's repro, the guest's window has no way to open a book at all, because nothing ever sends `OpenBook`. ## How tested Self-check on the top of the stack (fix/st-books, which contains this PR), Mac mini M4 Pro: - `cargo fmt --all --check`: OK - `cargo clippy --workspace --all-targets -- -D warnings`: OK - `cargo test -p horizon-protocol`: 71 passed. `cargo test -p horizon-client --lib`: 1061 passed (26 ignored). `--bins`: 98 + 18 passed. - `python3 tools/parity.py --changed origin/main`: 106 harnesses, 106 passed, 0 failed (23 min). - `tools/lan_e2e.py`, the new checks in both modes (in-frame, then `--server-thread`), host and guest; the existing `sign` and `lectern` checks still pass. Before = origin/main b65e082fd built with the same profile, after = this stack. ## Stack Four small PRs, one fix each, each on top of the previous one (the new lan_e2e checks share one block at the end of the file). Merge in order: #1463 (totem) → #1464 (keep_inventory) → #1465 (signs) → #1466 (books). The change for each PR is its top commit. #1475 (Elytra) and #1476 (shields, tridents, crossbows, spyglasses) continue the stack after #1466. They leave alone the lines that #1419, #1420 and #1423–#1427 change in `tools/lan_e2e.py`. The new checks go in a block before `if __name__` (`CHECKS += [...]`, `CHECK_FNS.update(...)`). `git merge-tree` is clean against each of #1423–#1427. #1419 and #1420 already conflict with main on their own. ## Needs Ludovic A review and a merge, in stack order. Nothing else. 🤖 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:17 +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#3543
No description provided.