[PR #3130] [MERGED] Mod API: a sprite shape draws as vanilla's blitSprite, nine-sliced by its gui.scaling #4817

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3130
Author: @d3grando
Created: 10/28/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @levzzz5154

Base: main ← Head: mod-sprites-nine-slice


📝 Commits (1)

  • 1df28d1 Mod API: a sprite shape draws as vanilla's blitSprite, nine-sliced by its gui.scaling

📊 Changes

4 files changed (+100 additions, -20 deletions)

View changed files

📝 crates/horizon-client-render/src/ui.rs (+83 -16)
📝 crates/horizon-client/src/game/mod_render.rs (+12 -2)
📝 crates/horizon-mod-sdk/wit/horizon.wit (+4 -1)
📝 docs/api/mods-reference.md (+1 -1)

📄 Description

🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves.

What and why

render's sprite shape stretched every GUI sprite over its rect (HudBatch::sprite_scaled). Vanilla's frames and
buttons are nine-slices, so a mod drawing tooltip/background + tooltip/frame or widget/button in a box of
any other size got smeared borders: thick sides on a wide tooltip, a blurred frame on a tall one. I hit it writing a
tooltip-style client mod (LookAt, in the registry as horizon-mods#18), which
draws its frame from fills instead because of it.

The shape now goes through a new ui::blit_sprite, which does what vanilla's blitSprite does with the sprite's
gui.scaling: nine-sliced (the existing draw_nine_slice, so high-resolution packs keep working as in #1458) when its
.png.mcmeta says nine_slice, stretched otherwise. ui::nine_slice and its default borders are unchanged:
blit_sprite only nine-slices sprites that have the metadata, so icons like hud/heart/full still stretch.

  • crates/horizon-client/src/ui.rs: nine_slice_metadata (the lookup scaling already did), blit_sprite,
    draw_sprite, and two tests (vanilla's tooltip/frame metadata keeps its 10-pixel corners in a 160 × 26 box; a
    sprite without metadata is one stretched quad).
  • crates/horizon-client/src/game/mod_render.rs: the sprite shape calls ui::blit_sprite.
  • crates/horizon-mod-sdk/wit/horizon.wit: sprite-shape.sprite says how it is drawn; docs/api/mods-reference.md
    regenerated (HORIZON_WRITE_DOCS=1 cargo test -p horizon-mods --features pack --test api_reference).

Not covered: gui.scaling type tile. No vanilla GUI sprite uses it (47 use nine_slice, none tile, in the 26.3
client jar), and Horizon doesn't parse it yet, so such a pack sprite still stretches, as before.

Vanilla reference

net.minecraft.client.gui.GuiGraphicsExtractor.blitSprite(RenderPipeline, Identifier, int, int, int, int, int):
getSpriteScaling(sprite), then a type switch: GuiSpriteScaling$Stretch → blitSprite(..., TextureAtlasSprite, ...),
$Tile → blitTiledSprite, $NineSlice → blitNineSlicedSprite (read with javap -c on the 26.3 client jar;
tools/rea_vanilla.py needs npx, which this Windows machine doesn't have). No harness: mod HUD shapes have none;
the unit tests above check the dispatch.

Self-check

pr_ready (tools/pr_ready.py --quick on DESKTOP-J80C959, against origin/main at b6c936f82, 1 min 30 s)

Check Result
Scope ✅ 4 files, +100 −20
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ❌ 398 run, FAILED (failures=2, errors=8, skipped=11) (42 s)
rustfmt ✅ (5 s)
clippy ✅ (8 s)
tests: horizon-client, horizon-mod-sdk ❌ 1094 passed, 2 failed (24 s)
doc tests ✅ 2 passed (7 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 ➖ 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)

Both ❌ are Windows-only and fail the same on origin/main (b6c936f82) on this machine, so they aren't from this change:

  • Rust: save::tests::session_lock_is_exclusive (Windows error 33, a lock violation) and crash::tests::stacks_start_at_the_panicking_frame, run on a detached origin/main: same 2 failures.
  • Python: tool tests needing symlinks (WinError 1314 without admin rights) and Unix paths (test_port_harness, test_port_publish, test_parity_reach); this change touches no Python.

Screenshots

A throwaway client mod drawing tooltip/background + tooltip/frame at 220 × 40 and 60 × 90 and widget/button at
220 × 20, GUI scale 2. Before: release v0.2.92. After: this branch (--profile fast --features mods), Windows 11,
RTX 5080.

Before: stretched sprites; after: nine-sliced as vanilla

Rebased on main after #3186

Rebased on main after #3186. ui.rs now lives in crates/horizon-client-render; the change is the same. Re-checked on Windows 11: cargo fmt --all --check clean; cargo clippy -- -D warnings --all-targets clean for -p horizon-client-render, -p horizon-client --features mods and -p horizon-mod-sdk; cargo test -p horizon-client-render --lib ui:: 52 passed (both blit_sprite_* tests included); cargo test -p horizon-mods --features pack --test api_reference 4 passed.

🤖 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/3130 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/28/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `mod-sprites-nine-slice` --- ### 📝 Commits (1) - [`1df28d1`](https://github.com/horizon-rust/horizon/commit/1df28d179346d6c877e2664a54f95396e4ea4e8b) Mod API: a sprite shape draws as vanilla's blitSprite, nine-sliced by its gui.scaling ### 📊 Changes **4 files changed** (+100 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/ui.rs` (+83 -16) 📝 `crates/horizon-client/src/game/mod_render.rs` (+12 -2) 📝 `crates/horizon-mod-sdk/wit/horizon.wit` (+4 -1) 📝 `docs/api/mods-reference.md` (+1 -1) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. ## What and why `render`'s sprite shape stretched every GUI sprite over its rect (`HudBatch::sprite_scaled`). Vanilla's frames and buttons are nine-slices, so a mod drawing `tooltip/background` + `tooltip/frame` or `widget/button` in a box of any other size got smeared borders: thick sides on a wide tooltip, a blurred frame on a tall one. I hit it writing a tooltip-style client mod ([LookAt](https://github.com/d3grando/lookat), in the registry as horizon-mods#18), which draws its frame from fills instead because of it. The shape now goes through a new `ui::blit_sprite`, which does what vanilla's `blitSprite` does with the sprite's `gui.scaling`: nine-sliced (the existing `draw_nine_slice`, so high-resolution packs keep working as in #1458) when its `.png.mcmeta` says `nine_slice`, stretched otherwise. `ui::nine_slice` and its default borders are unchanged: `blit_sprite` only nine-slices sprites that have the metadata, so icons like `hud/heart/full` still stretch. - `crates/horizon-client/src/ui.rs`: `nine_slice_metadata` (the lookup `scaling` already did), `blit_sprite`, `draw_sprite`, and two tests (vanilla's `tooltip/frame` metadata keeps its 10-pixel corners in a 160 × 26 box; a sprite without metadata is one stretched quad). - `crates/horizon-client/src/game/mod_render.rs`: the sprite shape calls `ui::blit_sprite`. - `crates/horizon-mod-sdk/wit/horizon.wit`: `sprite-shape.sprite` says how it is drawn; `docs/api/mods-reference.md` regenerated (`HORIZON_WRITE_DOCS=1 cargo test -p horizon-mods --features pack --test api_reference`). Not covered: `gui.scaling` type `tile`. No vanilla GUI sprite uses it (47 use `nine_slice`, none `tile`, in the 26.3 client jar), and Horizon doesn't parse it yet, so such a pack sprite still stretches, as before. ## Vanilla reference `net.minecraft.client.gui.GuiGraphicsExtractor.blitSprite(RenderPipeline, Identifier, int, int, int, int, int)`: `getSpriteScaling(sprite)`, then a type switch: `GuiSpriteScaling$Stretch` → `blitSprite(..., TextureAtlasSprite, ...)`, `$Tile` → `blitTiledSprite`, `$NineSlice` → `blitNineSlicedSprite` (read with `javap -c` on the 26.3 client jar; `tools/rea_vanilla.py` needs `npx`, which this Windows machine doesn't have). No harness: mod HUD shapes have none; the unit tests above check the dispatch. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on DESKTOP-J80C959, against origin/main at b6c936f82, 1 min 30 s) | Check | Result | | --- | --- | | Scope | ✅ 4 files, +100 −20 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ❌ 398 run, FAILED (failures=2, errors=8, skipped=11) (42 s) | | rustfmt | ✅ (5 s) | | clippy | ✅ (8 s) | | tests: horizon-client, horizon-mod-sdk | ❌ 1094 passed, 2 failed (24 s) | | doc tests | ✅ 2 passed (7 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 | ➖ 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) | Both ❌ are Windows-only and fail the same on `origin/main` (b6c936f82) on this machine, so they aren't from this change: - Rust: `save::tests::session_lock_is_exclusive` (Windows error 33, a lock violation) and `crash::tests::stacks_start_at_the_panicking_frame`, run on a detached `origin/main`: same 2 failures. - Python: tool tests needing symlinks (`WinError 1314` without admin rights) and Unix paths (`test_port_harness`, `test_port_publish`, `test_parity_reach`); this change touches no Python. ## Screenshots A throwaway client mod drawing `tooltip/background` + `tooltip/frame` at 220 × 40 and 60 × 90 and `widget/button` at 220 × 20, GUI scale 2. Before: release v0.2.92. After: this branch (`--profile fast --features mods`), Windows 11, RTX 5080. ![Before: stretched sprites; after: nine-sliced as vanilla](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/mod-sprites-nine-slice.png) ## Rebased on main after #3186 Rebased on main after #3186. `ui.rs` now lives in `crates/horizon-client-render`; the change is the same. Re-checked on Windows 11: `cargo fmt --all --check` clean; `cargo clippy -- -D warnings --all-targets` clean for `-p horizon-client-render`, `-p horizon-client --features mods` and `-p horizon-mod-sdk`; `cargo test -p horizon-client-render --lib ui::` 52 passed (both `blit_sprite_*` tests included); `cargo test -p horizon-mods --features pack --test api_reference` 4 passed. 🤖 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 05:08:09 +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#4817
No description provided.