[PR #2320] [MERGED] Server books: positional page indicator and component-list pages #4201

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2320
Author: @pqhaz3925
Created: 10/26/2026
Status: ✅ Merged
Merged: 10/27/2026
Merged by: @ludovic111

Base: main ← Head: fix/server-book-pages


📝 Commits (1)

  • 76d748c Server books: positional page indicator and component-list pages

📊 Changes

2 files changed (+40 additions, -4 deletions)

View changed files

📝 crates/horizon-client/src/game/books.rs (+6 -3)
📝 crates/horizon-client/src/item_data.rs (+34 -1)

📄 Description

🤖 Opened by pqhaz3925's AI agent (Claude Code), not by pqhaz3925 themselves.

What and why

Written books a server opens (ClientboundOpenBookPacket) showed up broken on Hypixel:

  • The page indicator read Page %1$s of %2$s: 26.3's en_us template is positional, and the indicator only replaced bare %s. It now goes through horizon_protocol::text::format_java (TranslatableContents.decomposeTemplate), like the rest of the translated text.
  • The pages were empty: Hypixel (through ViaVersion) sends each page as a component list ([{"text":""}, {...}, ...]), and item_data::read_text only took a string or a compound, so every page was dropped. It now takes the list form too; entity_nbt::name_text already flattens it.

A unit test covers a list-shaped page next to a plain one.

Vanilla reference

  • BookViewScreen.getPageNumberMessage: Component.translatable("book.pageIndicator", currentPage + 1, Math.max(getNumPages(), 1)) (read with tools/rea_vanilla.py).
  • ComponentSerialization.CODEC: a component is a string, a list or an object; WrittenBookContent pages are Filterable<Component> of that codec.

No harness: book screens have none today; the decode path is covered by the new item_data test.

Self-check

pr_ready (tools/pr_ready.py --quick on macOS (Apple Silicon), against origin/main at 9422f698e, 1 min 4 s)

Check Result
Scope ✅ 2 files, +40 −4
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ➖ no Python change
rustfmt ✅ (3 s)
clippy ✅ (1 s)
tests: horizon-client ✅ 1336 passed (58 s)
doc tests ✅ 0 passed (2 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Screenshots

Before: a Hypixel rules book opened with a blank page and Page %1$s of %2$s. After: Page 1 of 1 and the full text (Terms of Service, Privacy Policy, Server Rules, I Agree / I Do Not Agree).

🤖 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/2320 **Author:** [@pqhaz3925](https://github.com/pqhaz3925) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/27/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/server-book-pages` --- ### 📝 Commits (1) - [`76d748c`](https://github.com/horizon-rust/horizon/commit/76d748caf8b5d5a5e8e5446c0533d862197f3cf3) Server books: positional page indicator and component-list pages ### 📊 Changes **2 files changed** (+40 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/books.rs` (+6 -3) 📝 `crates/horizon-client/src/item_data.rs` (+34 -1) </details> ### 📄 Description > 🤖 Opened by pqhaz3925's AI agent (Claude Code), not by pqhaz3925 themselves. ## What and why Written books a server opens (`ClientboundOpenBookPacket`) showed up broken on Hypixel: - The page indicator read **`Page %1$s of %2$s`**: 26.3's `en_us` template is positional, and the indicator only replaced bare `%s`. It now goes through `horizon_protocol::text::format_java` (`TranslatableContents.decomposeTemplate`), like the rest of the translated text. - The pages were **empty**: Hypixel (through ViaVersion) sends each page as a component *list* (`[{"text":""}, {...}, ...]`), and `item_data::read_text` only took a string or a compound, so every page was dropped. It now takes the list form too; `entity_nbt::name_text` already flattens it. A unit test covers a list-shaped page next to a plain one. ## Vanilla reference - `BookViewScreen.getPageNumberMessage`: `Component.translatable("book.pageIndicator", currentPage + 1, Math.max(getNumPages(), 1))` (read with `tools/rea_vanilla.py`). - `ComponentSerialization.CODEC`: a component is a string, a list or an object; `WrittenBookContent` pages are `Filterable<Component>` of that codec. No harness: book screens have none today; the decode path is covered by the new `item_data` test. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on macOS (Apple Silicon), against origin/main at 9422f698e, 1 min 4 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +40 −4 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ➖ no Python change | | rustfmt | ✅ (3 s) | | clippy | ✅ (1 s) | | tests: horizon-client | ✅ 1336 passed (58 s) | | doc tests | ✅ 0 passed (2 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | ## Screenshots Before: a Hypixel rules book opened with a blank page and `Page %1$s of %2$s`. After: `Page 1 of 1` and the full text (Terms of Service, Privacy Policy, Server Rules, I Agree / I Do Not Agree). 🤖 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:15: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#4201
No description provided.