[PR #4284] [MERGED] Native mods: a hook point for item tooltips (API 4) #5541

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4284
Author: @ludovicthenot
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @levzzz5154

Base: main ← Head: native-tooltip-hook


📝 Commits (3)

  • 01c6de1 Native mods: a hook point for item tooltips (API 4)
  • 4d3ee1a Native mods: explain the tooltip hook's place from the game alone
  • 15a18c3 Merge main: tooltip hook is API 12

📊 Changes

4 files changed (+28 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/game/native_hooks.rs (+14 -1)
📝 crates/horizon-client/src/game/stations.rs (+5 -0)
📝 docs/native-mods.md (+4 -0)
📝 native-hooks.json (+5 -0)

📄 Description

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

What and why

Fixes #4087: a hook point for item tooltips, so tooltip mods (ShulkerBoxTooltip and the like) can be ported as native mods.

  • native_tooltip(&self, stack: &ItemStack, lines: &mut Vec<(Text, u32)>): the stack, with its components (stack.data(), so a shulker box's or a bundle's contents), and its tooltip's lines, the name first, each with its colour as rgba packs it. A mod adds, changes or takes out lines.
  • Called once, at the end of stack_tooltip_lines (the port of ItemStack.getTooltipLines), so it covers every place the game shows an item's tooltip: slots, the creative tabs, the recipe book, the item panel, chat's hover, trading, the stats screen. Not for a crossbow's nested projectile lines, and never for a tooltip the stack hides (empty lines).
  • It takes the game's own ItemStack and Text rather than a copy: nothing is converted each frame the tooltip shows, and a mod reads the components directly.
  • NATIVE_HOOKS_API 3 → 4, the catalog entry in native-hooks.json (tooltip, version 1), and an "API 4" paragraph in docs/native-mods.md.

The issue also asks for a preview window drawn beside the tooltip (the container grid). That is a drawing API of its own; I left it for a follow-up pull request, to keep this one to the hook point.

API number: #3878 and #3996 also raise NATIVE_HOOKS_API to 4. Whichever lands first keeps 4; I'll renumber this one (and its doc line) when it rebases.

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

Horizon-only (a hook point; it does nothing in Horizon). It is called after the game's port of ItemStack.getTooltipLines (game/stations.rs, stack_tooltip_lines), once every line is built. Tooltips are unchanged without a native mod.

Self-check

pr_ready (tools/pr_ready.py --base upstream/main on nemo, against upstream/main at 45982faa5, 5 min 13 s)

Check Result
Scope ✅ 4 files, +28 −1
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 480 passed (2 min 31 s)
rustfmt ✅ (12 s)
clippy ✅ (1 min 16 s)
tests: horizon-client ❌ 727 passed, 1 failed (1 min 9 s)
doc tests ✅ 0 passed (2 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 (no vanilla data here): 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)

The one failure, title::tests::each_world_preset_writes_its_own_generator (Os { code: 267, kind: NotADirectory }), fails the same way on upstream/main at 45982faa5 on this Windows machine: not from this pull request. The hook point tests (native_hooks::tests, including catalog_matches_hook_points and hook_points_stay_hookable) pass.


🔄 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/4284 **Author:** [@ludovicthenot](https://github.com/ludovicthenot) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `native-tooltip-hook` --- ### 📝 Commits (3) - [`01c6de1`](https://github.com/horizon-rust/horizon/commit/01c6de15a39a8dc1c20514f4285ade0bb52ea2a6) Native mods: a hook point for item tooltips (API 4) - [`4d3ee1a`](https://github.com/horizon-rust/horizon/commit/4d3ee1ace08254acddef7cc7d70d1fae15558a7b) Native mods: explain the tooltip hook's place from the game alone - [`15a18c3`](https://github.com/horizon-rust/horizon/commit/15a18c3a5e23c6c38c9ae7176e0b48ac63819af2) Merge main: tooltip hook is API 12 ### 📊 Changes **4 files changed** (+28 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/native_hooks.rs` (+14 -1) 📝 `crates/horizon-client/src/game/stations.rs` (+5 -0) 📝 `docs/native-mods.md` (+4 -0) 📝 `native-hooks.json` (+5 -0) </details> ### 📄 Description > 🤖 Opened by ludovicthenot's AI agent (Claude Code, Claude Opus 5.5), not by ludovicthenot personally. ## What and why Fixes #4087: a hook point for item tooltips, so tooltip mods (ShulkerBoxTooltip and the like) can be ported as native mods. - `native_tooltip(&self, stack: &ItemStack, lines: &mut Vec<(Text, u32)>)`: the stack, with its components (`stack.data()`, so a shulker box's or a bundle's contents), and its tooltip's lines, the name first, each with its colour as `rgba` packs it. A mod adds, changes or takes out lines. - Called once, at the end of `stack_tooltip_lines` (the port of `ItemStack.getTooltipLines`), so it covers every place the game shows an item's tooltip: slots, the creative tabs, the recipe book, the item panel, chat's hover, trading, the stats screen. Not for a crossbow's nested projectile lines, and never for a tooltip the stack hides (empty lines). - It takes the game's own `ItemStack` and `Text` rather than a copy: nothing is converted each frame the tooltip shows, and a mod reads the components directly. - `NATIVE_HOOKS_API` 3 → 4, the catalog entry in `native-hooks.json` (`tooltip`, version 1), and an "API 4" paragraph in `docs/native-mods.md`. The issue also asks for a preview window drawn beside the tooltip (the container grid). That is a drawing API of its own; I left it for a follow-up pull request, to keep this one to the hook point. **API number:** #3878 and #3996 also raise `NATIVE_HOOKS_API` to 4. Whichever lands first keeps 4; I'll renumber this one (and its doc line) when it rebases. ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [x] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference Horizon-only (a hook point; it does nothing in Horizon). It is called after the game's port of `ItemStack.getTooltipLines` (`game/stations.rs`, `stack_tooltip_lines`), once every line is built. Tooltips are unchanged without a native mod. ## Self-check **pr_ready** (`tools/pr_ready.py --base upstream/main` on nemo, against upstream/main at 45982faa5, 5 min 13 s) | Check | Result | | --- | --- | | Scope | ✅ 4 files, +28 −1 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 480 passed (2 min 31 s) | | rustfmt | ✅ (12 s) | | clippy | ✅ (1 min 16 s) | | tests: horizon-client | ❌ 727 passed, 1 failed (1 min 9 s) | | doc tests | ✅ 0 passed (2 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 (no vanilla data here): 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) | The one failure, `title::tests::each_world_preset_writes_its_own_generator` (`Os { code: 267, kind: NotADirectory }`), fails the same way on upstream/main at 45982faa5 on this Windows machine: not from this pull request. The hook point tests (`native_hooks::tests`, including `catalog_matches_hook_points` and `hook_points_stay_hookable`) pass. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:13:17 +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#5541
No description provided.