[PR #3417] [CLOSED] Give a single-player world its icon from the first frame #4967

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3417
Author: @hectoreccles
Created: 10/28/2026
Status: ❌ Closed

Base: main ← Head: feat/world-icon


📝 Commits (3)

  • a1542cb Give a single-player world its icon from the first frame
  • a185086 Merge main into this branch
  • f1995f4 Merge main into this branch

📊 Changes

3 files changed (+154 additions, -10 deletions)

View changed files

📝 crates/horizon-client-render/src/gfx.rs (+102 -10)
📝 crates/horizon-client/src/game.rs (+47 -0)
📝 crates/horizon-client/src/game/remote.rs (+5 -0)

📄 Description

🤖 Opened by Hector's AI agent (OpenCode), not by Hector himself.

What

Single-player worlds now get their icon.png the way vanilla does (GameRenderer.tryTakeScreenshotIfNeeded / takeAutoScreenshot): once a second, a world with no icon takes the centre square of its first fully meshed frame and writes it as a 64×64 saves/<world>/icon.png. Only the window's own single-player world qualifies; joining a server clears the pending icon.

The snapshot is taken after the hand and screen effects and before the entity outline and post chain, so it is the scene rather than the GUI. It includes the first-person hand, as vanilla's does — the centre-square crop removes most of it on a widescreen window.

Functionally identical, not bit-identical

The bytes will not match vanilla's icon:

  • the resize is a block average, not STB's filtered resize: when the crop's side is not divisible by 64, a shared source texel at a block edge is counted at full weight in both blocks. Visually indistinguishable at 64 px;
  • the PNG is written by the png crate, not STB's writer, so the file bytes differ even where pixels agree;
  • the alpha channel is forced opaque by the existing screenshot readback.

The crop geometry (min side, (w - side) / 2 offsets), the 64×64 RGBA8 output, "only if missing", the 1 s retry and retrying after a failed write all match vanilla. Two deliberate differences: the "all sections rendered" test is streaming.busy(), which also waits for generation/lighting rather than only the mesh queue, so the icon can be written a few seconds later; and the PNG write is synchronous on the render thread, once per world, rather than on an IO pool.

Test

  • cargo test -p horizon-client --lib gfx::tests::world_icon_crops_the_centre_and_scales_to_64 (centre crop, odd sizes, source smaller than 64).
  • Live run: launched an offscreen creative world from scratch, and icon.png appeared on its own — 64×64 RGBA, showing the spawn view with no HUD.

Checks

pr_ready (tools/pr_ready.py --quick on Hectors-MacBook-Pro-590, against origin/main at 430e5e4c9, 3 min 10 s)

Check Result
Scope ✅ 3 files, +153 −10
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 408 passed (24 s)
rustfmt ✅ (4 s)
clippy ✅ (36 s)
tests: horizon-client ✅ 1283 passed (1 min 37 s)
doc tests ✅ 0 passed (24 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 44 affected, to run in CI (--quick): arrow, block_particles, block_removal, command_exec, composter, crafter, cursor_death, dedicated_server, dispenser, entity_death_loot, finalize_spawn, forced_end and 32 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

CI's parity job runs only for a PR that changes a harness, oracle or probe, or carries run-parity (.github/workflows/ci.yml), so the 44 harnesses above are left to parity-main after merge. A local run of them was not possible here: this checkout's .local lacks the client libraries the client-side harnesses load.

🤖 Generated with OpenCode


🔄 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/3417 **Author:** [@hectoreccles](https://github.com/hectoreccles) **Created:** 10/28/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/world-icon` --- ### 📝 Commits (3) - [`a1542cb`](https://github.com/horizon-rust/horizon/commit/a1542cb263b3dfe339b05ce5ad729033a567fde2) Give a single-player world its icon from the first frame - [`a185086`](https://github.com/horizon-rust/horizon/commit/a185086f248da11f443cfac7ec1584fa1317996b) Merge main into this branch - [`f1995f4`](https://github.com/horizon-rust/horizon/commit/f1995f49829cd08809389d2ce12095a5ecabc954) Merge main into this branch ### 📊 Changes **3 files changed** (+154 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/gfx.rs` (+102 -10) 📝 `crates/horizon-client/src/game.rs` (+47 -0) 📝 `crates/horizon-client/src/game/remote.rs` (+5 -0) </details> ### 📄 Description > 🤖 Opened by Hector's AI agent (OpenCode), not by Hector himself. ## What Single-player worlds now get their `icon.png` the way vanilla does (`GameRenderer.tryTakeScreenshotIfNeeded` / `takeAutoScreenshot`): once a second, a world with no icon takes the centre square of its first fully meshed frame and writes it as a 64×64 `saves/<world>/icon.png`. Only the window's own single-player world qualifies; joining a server clears the pending icon. The snapshot is taken after the hand and screen effects and before the entity outline and post chain, so it is the scene rather than the GUI. It includes the first-person hand, as vanilla's does — the centre-square crop removes most of it on a widescreen window. ## Functionally identical, not bit-identical The bytes will not match vanilla's icon: - the resize is a block average, not STB's filtered resize: when the crop's side is not divisible by 64, a shared source texel at a block edge is counted at full weight in both blocks. Visually indistinguishable at 64 px; - the PNG is written by the `png` crate, not STB's writer, so the file bytes differ even where pixels agree; - the alpha channel is forced opaque by the existing screenshot readback. The crop geometry (`min` side, `(w - side) / 2` offsets), the 64×64 RGBA8 output, "only if missing", the 1 s retry and retrying after a failed write all match vanilla. Two deliberate differences: the "all sections rendered" test is `streaming.busy()`, which also waits for generation/lighting rather than only the mesh queue, so the icon can be written a few seconds later; and the PNG write is synchronous on the render thread, once per world, rather than on an IO pool. ## Test - `cargo test -p horizon-client --lib gfx::tests::world_icon_crops_the_centre_and_scales_to_64` (centre crop, odd sizes, source smaller than 64). - Live run: launched an offscreen creative world from scratch, and `icon.png` appeared on its own — 64×64 RGBA, showing the spawn view with no HUD. ## Checks **pr_ready** (`tools/pr_ready.py --quick` on Hectors-MacBook-Pro-590, against origin/main at 430e5e4c9, 3 min 10 s) | Check | Result | | --- | --- | | Scope | ✅ 3 files, +153 −10 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 408 passed (24 s) | | rustfmt | ✅ (4 s) | | clippy | ✅ (36 s) | | tests: horizon-client | ✅ 1283 passed (1 min 37 s) | | doc tests | ✅ 0 passed (24 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 44 affected, to run in CI (--quick): arrow, block_particles, block_removal, command_exec, composter, crafter, cursor_death, dedicated_server, dispenser, entity_death_loot, finalize_spawn, forced_end and 32 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | CI's parity job runs only for a PR that changes a harness, oracle or probe, or carries `run-parity` (`.github/workflows/ci.yml`), so the 44 harnesses above are left to `parity-main` after merge. A local run of them was not possible here: this checkout's `.local` lacks the client libraries the client-side harnesses load. 🤖 Generated with [OpenCode](https://opencode.ai) --- <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:15 +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#4967
No description provided.