[PR #7149] [MERGED] Add a native mod image slot for mods that draw their own picture #7376

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7149
Author: @Domanffe
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: feat/native-mod-image


📝 Commits (8)

  • 421495d Add a native mod image slot and its helper
  • 7a99152 Reserve the mod image slot only while a native mod is loaded
  • 668e44a Merge remote-tracking branch 'origin/main' into feat/native-mod-image
  • 5d4abef Merge main into native-mod-image; number mod_image through a hook fragment
  • b27fca9 Read the mod-image flag before the pack-staging thread scope
  • 8576ed0 mod_image fragment: stampable
  • e0bcf9a Merge main into #7149
  • a7c3be8 Merge main into #7149, regenerating the mod API host

📊 Changes

8 files changed (+133 additions, -9 deletions)

View changed files

📝 crates/horizon-client-render/src/hud.rs (+43 -6)
📝 crates/horizon-client/src/game.rs (+4 -1)
📝 crates/horizon-client/src/game/mod_api_host_generated.rs (+3 -0)
📝 crates/horizon-client/src/game/native_hooks.rs (+52 -0)
📝 crates/horizon-client/src/game/packs.rs (+5 -2)
📝 crates/horizon-client/src/mod_api/generated_host.rs (+13 -0)
📝 docs/native-mods.md (+2 -0)
➕ tools/native-hook-fragments/mod_image.json (+11 -0)

📄 Description

🤖 Opened by Alexander's AI agent (Hermes), not by Alexander himself.

A native mod draws with the HUD atlas, plain fills and text, so a mod that builds a picture of its own — a world map, a schematic view, an image a content mod ships — has nowhere to upload it. This adds one 1024 by 1024 atlas slot and Game::native_mod_image(width, height, rgba), which patches that slot from the mod's RGBA buffer. native_sprite then draws it cropped and stretched by its source rectangle, which is what a map's pan and zoom need.

  • A whole image only: width * height * 4 bytes, each side at most 1024. A short, long or oversized buffer is refused with false instead of patching part of the slot.
  • The upload is a texture patch of the image, so a mod sends one when the image changed, not every frame. A map sends one when it opens and when a tile changed.
  • The slot is reserved the way the minimap's and the 256 map slots are, so it adds 4 MiB to the atlas whether a mod uses it or not. Say if you would rather have it smaller (512 costs 1 MiB and holds 512 blocks at a block a pixel).
  • API 154: native-hooks.json, the generated host trait and impl, and docs/native-mods.md are updated together.
  • One unit test pins the size rule: a whole image is taken, a partial or oversized one is not.

This is here for a world map native mod: it collects the minimap's tiles into the slot and pans and zooms them, which is impossible with the 128 by 128 minimap sprite alone.

The pr_ready block follows as a comment once the run finishes.


🔄 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/7149 **Author:** [@Domanffe](https://github.com/Domanffe) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/native-mod-image` --- ### 📝 Commits (8) - [`421495d`](https://github.com/horizon-rust/horizon/commit/421495d8e9c6aedfae93c1fa83d2367af6ebc392) Add a native mod image slot and its helper - [`7a99152`](https://github.com/horizon-rust/horizon/commit/7a9915273cccf0e938273746dc5ee048dded73fe) Reserve the mod image slot only while a native mod is loaded - [`668e44a`](https://github.com/horizon-rust/horizon/commit/668e44a3e880bc2679a0e7afb9698f3105fa372a) Merge remote-tracking branch 'origin/main' into feat/native-mod-image - [`5d4abef`](https://github.com/horizon-rust/horizon/commit/5d4abef9e6649d96fe2f5f23053a7ff113d148d0) Merge main into native-mod-image; number mod_image through a hook fragment - [`b27fca9`](https://github.com/horizon-rust/horizon/commit/b27fca99155bb89f077c18dd41c2abceedc4a28e) Read the mod-image flag before the pack-staging thread scope - [`8576ed0`](https://github.com/horizon-rust/horizon/commit/8576ed03f9ba46d6ed034aa5478e474c1f9fd4df) mod_image fragment: stampable - [`e0bcf9a`](https://github.com/horizon-rust/horizon/commit/e0bcf9ab8a504641682c1ba8494b8c5f371428fd) Merge main into #7149 - [`a7c3be8`](https://github.com/horizon-rust/horizon/commit/a7c3be8ebd1c184424f3e2b2ca9efef8899feb89) Merge main into #7149, regenerating the mod API host ### 📊 Changes **8 files changed** (+133 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/hud.rs` (+43 -6) 📝 `crates/horizon-client/src/game.rs` (+4 -1) 📝 `crates/horizon-client/src/game/mod_api_host_generated.rs` (+3 -0) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+52 -0) 📝 `crates/horizon-client/src/game/packs.rs` (+5 -2) 📝 `crates/horizon-client/src/mod_api/generated_host.rs` (+13 -0) 📝 `docs/native-mods.md` (+2 -0) ➕ `tools/native-hook-fragments/mod_image.json` (+11 -0) </details> ### 📄 Description > 🤖 Opened by Alexander's AI agent (Hermes), not by Alexander himself. A native mod draws with the HUD atlas, plain fills and text, so a mod that builds a picture of its own — a world map, a schematic view, an image a content mod ships — has nowhere to upload it. This adds one 1024 by 1024 atlas slot and `Game::native_mod_image(width, height, rgba)`, which patches that slot from the mod's RGBA buffer. `native_sprite` then draws it cropped and stretched by its source rectangle, which is what a map's pan and zoom need. - A whole image only: `width * height * 4` bytes, each side at most 1024. A short, long or oversized buffer is refused with `false` instead of patching part of the slot. - The upload is a texture patch of the image, so a mod sends one when the image changed, not every frame. A map sends one when it opens and when a tile changed. - The slot is reserved the way the minimap's and the 256 map slots are, so it adds 4 MiB to the atlas whether a mod uses it or not. Say if you would rather have it smaller (512 costs 1 MiB and holds 512 blocks at a block a pixel). - API 154: `native-hooks.json`, the generated host trait and impl, and `docs/native-mods.md` are updated together. - One unit test pins the size rule: a whole image is taken, a partial or oversized one is not. This is here for a world map native mod: it collects the minimap's tiles into the slot and pans and zooms them, which is impossible with the 128 by 128 minimap sprite alone. The `pr_ready` block follows as a comment once the run finishes. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:38:34 +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#7376
No description provided.