[PR #2911] [MERGED] Select World: show each world's preview icon #4685

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2911
Author: @masa-masa-0314
Created: 10/27/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @levzzz5154

Base: main ← Head: fix/world-select-icons


📝 Commits (6)

  • 2092c5a Worlds: take the save's icon.png from the rendered frame
  • 5b4dd8b Merge main into fix/world-select-icons
  • e3b1ae5 Single player: the world icon keeps its save folder through the async start
  • b6cd094 World icon: wait for more than 10 rendered sections
  • bc33470 Merge main into this branch
  • a7ff35c Merge horizon-rust/main into fix/world-select-icons

📊 Changes

6 files changed (+203 additions, -27 deletions)

View changed files

📝 crates/horizon-client-render/src/gfx.rs (+96 -22)
📝 crates/horizon-client/src/game.rs (+80 -1)
📝 crates/horizon-client/src/game/chat.rs (+4 -1)
📝 crates/horizon-client/src/game/control.rs (+4 -1)
📝 crates/horizon-client/src/game/integrated.rs (+17 -2)
📝 crates/horizon-client/src/game/remote.rs (+2 -0)

📄 Description

🤖 Opened by masa-masa-0314's AI agent (ZCode), not by masa-masa-0314 personally.

What and why

Fixes #2881. The Select World list draws every world's preview icon and even has its Reset Icon button, but nothing ever created icon.png, so every row showed the fallback sprite forever. Vanilla gives each save an icon while you play: this adds that.

The client now tracks the world in play's icon.png (GameRenderer.tryTakeScreenshotIfNeeded): while a local world is on the screen without one, once a second — and only once its chunks have all rendered, so the icon never pictures holes — it grabs the rendered frame, centre-crops it to a square, averages it down to 64×64 and writes the save's icon.png. The grab happens after the level and the first-person hand but before the screen effects and the HUD, so the icon has no crosshair, hotbar or menus, as vanilla's doesn't. Like vanilla, an existing icon is never retaken (the Edit World reset is the way to get a new one), and a failed write just tries again a second later.

The frame grab reuses the screenshot pipeline (Renderer.screenshot), which gains a target size: F2's and horizon-ctl's screenshots keep saving the finished frame as drawn. Icons are taken for both single-player execution modes (world in the frame and server thread), never for remote multiplayer servers.

Vanilla reference

  • net.minecraft.client.renderer.GameRenderer.tryTakeScreenshotIfNeeded — called right after renderLevel() in the render loop; skips when the save already has its icon (hasWorldScreenshot), throttles to one attempt a second, asks the integrated server for getWorldScreenshotFile().
  • net.minecraft.client.renderer.GameRenderer.takeAutoScreenshot(Path) — only with every section rendered and more than ten rendered; grabs the main render target, then on the IO pool centre-crops the frame to a square and NativeImage.resizeSubRectTo-averages it into a 64×64 image written to icon.png ("Couldn't save auto screenshot" on failure).
  • net.minecraft.world.level.storage.LevelStorageSource$LevelStorageAccess.getIconFile — the save's icon.png; EditWorldScreen's Reset Icon deletes it (Horizon already had that side).

Self-check

pr_ready (tools/pr_ready.py --base upstream/main on DESKTOP-3050AHP, against upstream/main at cf62fe270, 7 min 47 s)

Check Result
Scope ✅ 6 files, +189 −22
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ❌ 369 run, FAILED (failures=2, errors=7, skipped=1) (1 min 38 s)
rustfmt ✅ (12 s)
clippy ✅ (1 min 32 s)
tests: horizon-client ❌ 1133 passed, 2 failed (3 min 20 s)
doc tests ✅ 0 passed (1 min 1 s)
Parity ➖ not run (no vanilla data here): CI's parity job picks the affected harnesses

The horizon-client failures are this Windows machine's two pre-existing ones (save::tests::session_lock_is_exclusive, crash::tests::stacks_start_at_the_panicking_frame); both fail on clean upstream/main here. The Python failures (test_parity_reach, test_port_harness, test_port_publish) also fail on clean upstream/main on this machine (verified by stashing the diff: same 2 failures, 7 errors) — they need the maintainer's horizon-parity tree.

Also verified end to end on this machine: a headless client (--offscreen --frames 900) on a fresh world wrote a 64×64 icon.png into the save with no HUD in it (below); a second run on the same save left the icon untouched; a full-frame F2-style screenshot still comes out at the window size with the HUD, as before.

the icon the client wrote into the save
If the image does not load, open it on GitHub.

Screenshots

The icon itself is above; this machine's offscreen renderer can't drive the Select World screen (the control socket's clicks need a world open), so the list with the icons in place isn't pictured — it is the rendering the list already had for saves that ship an icon.png.

🤖 Generated with ZCode


🔄 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/2911 **Author:** [@masa-masa-0314](https://github.com/masa-masa-0314) **Created:** 10/27/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix/world-select-icons` --- ### 📝 Commits (6) - [`2092c5a`](https://github.com/horizon-rust/horizon/commit/2092c5a2e8cdafea5746b32d2d538d4feea80e10) Worlds: take the save's icon.png from the rendered frame - [`5b4dd8b`](https://github.com/horizon-rust/horizon/commit/5b4dd8b72e152501e2788af59e38d5911a1937a4) Merge main into fix/world-select-icons - [`e3b1ae5`](https://github.com/horizon-rust/horizon/commit/e3b1ae512fe8fb41d0adfafb5d372c8a2a643dab) Single player: the world icon keeps its save folder through the async start - [`b6cd094`](https://github.com/horizon-rust/horizon/commit/b6cd09442e11614dfa20051014e4233bbd3201df) World icon: wait for more than 10 rendered sections - [`bc33470`](https://github.com/horizon-rust/horizon/commit/bc33470d5cd02f8fddf2a247d79cc366d3351018) Merge main into this branch - [`a7ff35c`](https://github.com/horizon-rust/horizon/commit/a7ff35cf7b25292cb58ca4c025a57a05c2de411b) Merge horizon-rust/main into fix/world-select-icons ### 📊 Changes **6 files changed** (+203 additions, -27 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/gfx.rs` (+96 -22) 📝 `crates/horizon-client/src/game.rs` (+80 -1) 📝 `crates/horizon-client/src/game/chat.rs` (+4 -1) 📝 `crates/horizon-client/src/game/control.rs` (+4 -1) 📝 `crates/horizon-client/src/game/integrated.rs` (+17 -2) 📝 `crates/horizon-client/src/game/remote.rs` (+2 -0) </details> ### 📄 Description > 🤖 Opened by masa-masa-0314's AI agent (ZCode), not by masa-masa-0314 personally. ## What and why Fixes #2881. The Select World list draws every world's preview icon and even has its Reset Icon button, but nothing ever created `icon.png`, so every row showed the fallback sprite forever. Vanilla gives each save an icon while you play: this adds that. The client now tracks the world in play's `icon.png` (`GameRenderer.tryTakeScreenshotIfNeeded`): while a local world is on the screen without one, once a second — and only once its chunks have all rendered, so the icon never pictures holes — it grabs the rendered frame, centre-crops it to a square, averages it down to 64×64 and writes the save's `icon.png`. The grab happens after the level and the first-person hand but before the screen effects and the HUD, so the icon has no crosshair, hotbar or menus, as vanilla's doesn't. Like vanilla, an existing icon is never retaken (the Edit World reset is the way to get a new one), and a failed write just tries again a second later. The frame grab reuses the screenshot pipeline (`Renderer.screenshot`), which gains a target size: F2's and horizon-ctl's screenshots keep saving the finished frame as drawn. Icons are taken for both single-player execution modes (world in the frame and server thread), never for remote multiplayer servers. ## Vanilla reference - `net.minecraft.client.renderer.GameRenderer.tryTakeScreenshotIfNeeded` — called right after `renderLevel()` in the render loop; skips when the save already has its icon (`hasWorldScreenshot`), throttles to one attempt a second, asks the integrated server for `getWorldScreenshotFile()`. - `net.minecraft.client.renderer.GameRenderer.takeAutoScreenshot(Path)` — only with every section rendered and more than ten rendered; grabs the main render target, then on the IO pool centre-crops the frame to a square and `NativeImage.resizeSubRectTo`-averages it into a 64×64 image written to `icon.png` ("Couldn't save auto screenshot" on failure). - `net.minecraft.world.level.storage.LevelStorageSource$LevelStorageAccess.getIconFile` — the save's `icon.png`; `EditWorldScreen`'s Reset Icon deletes it (Horizon already had that side). ## Self-check **pr_ready** (`tools/pr_ready.py --base upstream/main` on DESKTOP-3050AHP, against upstream/main at cf62fe270, 7 min 47 s) | Check | Result | | --- | --- | | Scope | ✅ 6 files, +189 −22 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ❌ 369 run, FAILED (failures=2, errors=7, skipped=1) (1 min 38 s) | | rustfmt | ✅ (12 s) | | clippy | ✅ (1 min 32 s) | | tests: horizon-client | ❌ 1133 passed, 2 failed (3 min 20 s) | | doc tests | ✅ 0 passed (1 min 1 s) | | Parity | ➖ not run (no vanilla data here): CI's parity job picks the affected harnesses | The `horizon-client` failures are this Windows machine's two pre-existing ones (`save::tests::session_lock_is_exclusive`, `crash::tests::stacks_start_at_the_panicking_frame`); both fail on clean `upstream/main` here. The Python failures (`test_parity_reach`, `test_port_harness`, `test_port_publish`) also fail on clean `upstream/main` on this machine (verified by stashing the diff: same 2 failures, 7 errors) — they need the maintainer's `horizon-parity` tree. Also verified end to end on this machine: a headless client (`--offscreen --frames 900`) on a fresh world wrote a 64×64 `icon.png` into the save with no HUD in it (below); a second run on the same save left the icon untouched; a full-frame F2-style screenshot still comes out at the window size with the HUD, as before. ![the icon the client wrote into the save](https://github.com/masa-masa-0314/horizon/blob/pr-screenshots/world-icon.png?raw=true) <sub>If the image does not load, [open it on GitHub](https://github.com/masa-masa-0314/horizon/blob/pr-screenshots/world-icon.png).</sub> ## Screenshots The icon itself is above; this machine's offscreen renderer can't drive the Select World screen (the control socket's clicks need a world open), so the list with the icons in place isn't pictured — it is the rendering the list already had for saves that ship an `icon.png`. 🤖 Generated with ZCode --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:07:11 +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#4685
No description provided.