[PR #6292] [MERGED] Native mods: their own icons on maps, the client half of MapDecorationType #6774

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6292
Author: @levzzz5154
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @levzzz5154

Base: main ← Head: mods/native-map-decorations


📝 Commits (1)

  • 4155022 Native mods: a mod's own icons on filled maps (MapDecorationType, client half)

📊 Changes

4 files changed (+169 additions, -4 deletions)

View changed files

📝 crates/horizon-client/src/game/cartography.rs (+22 -1)
📝 crates/horizon-client/src/game/maps.rs (+113 -3)
📝 crates/horizon-client/src/game/native_hooks.rs (+21 -0)
➕ tools/native-hook-fragments/map_decorations.json (+13 -0)

📄 Description

🤖 Opened by levzzz5154's AI agent (Claude Code, Claude Sonnet 5.5), not by levzzz5154 personally.

What and why

Fixes #6269; part of #4953 ("Map decorations"). This is the first step of two, as laid out in the issue: a client hook that adds a mod's own icons when a map is drawn. native_map_decorations(map, decorations) is asked each time a map is drawn (held, in an item frame, on the cartography table's screen) with NativeMapInfo (id, centre block, scale, dimension, locked, in_frame); the mod pushes NativeMapDecoration { sprite, x, y, rot, shown_on_frame }:

  • sprite is an atlas sprite: vanilla's map/decorations/<name>, or a content mod's texture; one the atlas lacks is left out.
  • x, y are half map pixels from -128 to 127, as vanilla's MapDecoration; the doc comment gives the world-to-map formula from the map's centre and scale. rot is 0 to 15.
  • shown_on_frame is MapDecorationType.showOnItemFrame: in a frame and on the cartography screen only those with it show; a held map shows all.

They are drawn after the vanilla decorations with the same pose (decoration_pose, now also decoration_pose_at(x, y, rot, z)), in the held/frame geometry (map_vertices) and the cartography preview (draw_map_decorations). Vanilla's own decorations are not passed in and nothing is saved in the map. The hook is &self, asked per drawn map per frame.

Not in this PR (the second step in the issue): a decoration type registered by the server and saved with the map's data, synced in the map packet and counted toward its limit. That needs code-side registration with network ids (a vanilla client has no registry entry for a mod type), a tracker item of its own.

Kind

  • feature: something new for players (a mod puts its own icons on maps)

Vanilla reference

MapRenderer.render / extractDecoration (pose, showOnItemFrame), MapItemSavedData coordinate maths for the half-pixel position; NeoForge's public MapDecorationType for the names.

Other projects' code

None; names and contracts only.

Proof in the real game

Offscreen client, single player on the server thread, a throwaway probe in the hook body (removed before commit, git diff shows no TESTHOOK) that logged each call and pushed red_x at (0, 0), woodland_mansion at (60, -60), player at (-60, 60) with shown_on_frame false, and a sprite that does not exist. A filled map held in first person (made by using an empty map, id 0), screenshot read back with the image reader: the red X sits at the map's centre, the mansion icon in the upper right, the player arrow in the lower left, and the unknown sprite is skipped. The log has map_decorations id=0 center=[0, 0] scale=0 dim=minecraft:overworld frame=false every frame.

Not run: the item frame (I could not place a frame with a map from the control socket in the time; it shares map_vertices and its filter is the one line !frame || shown_on_frame), the cartography table screen, a locked or scaled map, a real native mod bundle, the parity harnesses (--quick). One unit test pins that a mod icon's pose is the vanilla decoration's.

Self-check

pr_ready (tools/pr_ready.py --quick --base hr/main, against hr/main at 455b6916b)

Check Result
Scope ✅ 4 files, +169 −4
Public tree ✅
Python tests ✅ 586 passed
rustfmt ✅
clippy ✅
tests: horizon-client ✅ 1806 passed
doc tests ✅
Parity ➖ not run (--quick)

🤖 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/6292 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `mods/native-map-decorations` --- ### 📝 Commits (1) - [`4155022`](https://github.com/horizon-rust/horizon/commit/41550226859c011126ceb2c9c097dc01c35c87ee) Native mods: a mod's own icons on filled maps (MapDecorationType, client half) ### 📊 Changes **4 files changed** (+169 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/cartography.rs` (+22 -1) 📝 `crates/horizon-client/src/game/maps.rs` (+113 -3) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+21 -0) ➕ `tools/native-hook-fragments/map_decorations.json` (+13 -0) </details> ### 📄 Description > 🤖 Opened by levzzz5154's AI agent (Claude Code, Claude Sonnet 5.5), not by levzzz5154 personally. ## What and why Fixes #6269; part of #4953 ("Map decorations"). This is the first step of two, as laid out in the issue: a client hook that adds a mod's own icons when a map is drawn. `native_map_decorations(map, decorations)` is asked each time a map is drawn (held, in an item frame, on the cartography table's screen) with `NativeMapInfo` (id, centre block, scale, dimension, locked, `in_frame`); the mod pushes `NativeMapDecoration { sprite, x, y, rot, shown_on_frame }`: - `sprite` is an atlas sprite: vanilla's `map/decorations/<name>`, or a content mod's texture; one the atlas lacks is left out. - `x`, `y` are half map pixels from -128 to 127, as vanilla's `MapDecoration`; the doc comment gives the world-to-map formula from the map's centre and scale. `rot` is 0 to 15. - `shown_on_frame` is `MapDecorationType.showOnItemFrame`: in a frame and on the cartography screen only those with it show; a held map shows all. They are drawn after the vanilla decorations with the same pose (`decoration_pose`, now also `decoration_pose_at(x, y, rot, z)`), in the held/frame geometry (`map_vertices`) and the cartography preview (`draw_map_decorations`). Vanilla's own decorations are not passed in and nothing is saved in the map. The hook is `&self`, asked per drawn map per frame. Not in this PR (the second step in the issue): a decoration type registered by the server and saved with the map's data, synced in the map packet and counted toward its limit. That needs code-side registration with network ids (a vanilla client has no registry entry for a mod type), a tracker item of its own. ## Kind - [x] feature: something new for players (a mod puts its own icons on maps) ## Vanilla reference `MapRenderer.render` / `extractDecoration` (pose, `showOnItemFrame`), `MapItemSavedData` coordinate maths for the half-pixel position; NeoForge's public `MapDecorationType` for the names. ## Other projects' code None; names and contracts only. ## Proof in the real game Offscreen client, single player on the server thread, a throwaway probe in the hook body (removed before commit, `git diff` shows no TESTHOOK) that logged each call and pushed `red_x` at (0, 0), `woodland_mansion` at (60, -60), `player` at (-60, 60) with `shown_on_frame` false, and a sprite that does not exist. A filled map held in first person (made by using an empty map, id 0), screenshot read back with the image reader: the red X sits at the map's centre, the mansion icon in the upper right, the player arrow in the lower left, and the unknown sprite is skipped. The log has `map_decorations id=0 center=[0, 0] scale=0 dim=minecraft:overworld frame=false` every frame. Not run: the item frame (I could not place a frame with a map from the control socket in the time; it shares `map_vertices` and its filter is the one line `!frame || shown_on_frame`), the cartography table screen, a locked or scaled map, a real native mod bundle, the parity harnesses (`--quick`). One unit test pins that a mod icon's pose is the vanilla decoration's. ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base hr/main`, against hr/main at 455b6916b) | Check | Result | | --- | --- | | Scope | ✅ 4 files, +169 −4 | | Public tree | ✅ | | Python tests | ✅ 586 passed | | rustfmt | ✅ | | clippy | ✅ | | tests: horizon-client | ✅ 1806 passed | | doc tests | ✅ | | Parity | ➖ not run (--quick) | 🤖 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 06:26:24 +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#6774
No description provided.