[PR #5454] [MERGED] Native mods: item_bar hook, the bar drawn under an item (API next) #6297

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5454
Author: @Sylviromi
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @levzzz5154

Base: main ← Head: item-bar


📝 Commits (1)

  • 82b9c42 Native mods: item_bar hook, the bar drawn under an item (API next)

📊 Changes

3 files changed (+25 additions, -4 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+7 -4)
📝 crates/horizon-client/src/game/native_hooks.rs (+8 -0)
➕ tools/native-hook-fragments/item_bar.json (+10 -0)

📄 Description

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

Closes #5261.

What and why

native_item_bar(&self, stack: &ItemStack, bar: &mut Option<(i32, u32)>) fires in
draw_item_decorations (crates/horizon-client/src/game.rs ~7462), where
GuiGraphicsExtractor.itemDecorations picks the bar to draw, after the bundle override. bar
arrives holding vanilla's own choice; a mod may replace it (width 0..=13, an RGB colour) or clear
it to hide the bar. Client only. A mod that does not hook it leaves the bar unchanged.

Kind

  • feature: something new for players (listed under New in the release notes)

Vanilla reference

Item.isBarVisible/getBarWidth/getBarColor(ItemStack), called from
GuiGraphics.renderItemDecorations, ported as draw_item_decorations. No NeoForge event exists
for this moment (docs/native-hooks-neoforge.md rule 1); NeoForge mods override the same vanilla
Item methods directly.

Other projects' code

none

In-game proof

Built a native mod bundle with a HEAD injection into native_item_bar that set the bar from a
fluid-container item's fill level. In game: a half-filled container showed a half-width bar, a
full or an empty one showed none, and other items (tools, bundles) were unchanged. No screenshot:
the test content is a private mod.

Self-check

pr_ready: 3 files changed since origin/main; checks on local
  Public tree...
  Public tree: pass (0 s)
  Python tests...
  Python tests: pass (48 s)
  rustfmt...
  rustfmt: pass (9 s)
  clippy...
  clippy: pass (1 min 50 s)
  tests: horizon-client...
  tests: horizon-client: pass (1 min 16 s)
  doc tests...
  doc tests: pass (1 s)
**pr_ready** (`tools/pr_ready.py --quick` on boilingpoint, against origin/main at 256a52eb2, 4 min 4 s)

| Check | Result |
| --- | --- |
| Scope | ✅ 3 files, +25 −4 |
| Cargo.lock | ✅ unchanged |
| Public tree | ✅ |
| Python tests | ✅ 508 passed (48 s) |
| rustfmt | ✅ (9 s) |
| clippy | ✅ (1 min 50 s) |
| tests: horizon-client | ✅ 1542 passed (1 min 16 s) |
| doc tests | ✅ 0 passed (1 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) |

API: pending — the hook's number comes from tools/native-hook-fragments/item_bar.json, stamped
at merge per that fragment directory's README (docs/native-hooks-neoforge.md rule 7).

Label: feature.

Screenshots

None (see "In-game proof" above: the test content is a private mod).

🤖 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/5454 **Author:** [@Sylviromi](https://github.com/Sylviromi) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `item-bar` --- ### 📝 Commits (1) - [`82b9c42`](https://github.com/horizon-rust/horizon/commit/82b9c426a3dbd79e7d6e013470b03e4407458a62) Native mods: item_bar hook, the bar drawn under an item (API next) ### 📊 Changes **3 files changed** (+25 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+7 -4) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+8 -0) ➕ `tools/native-hook-fragments/item_bar.json` (+10 -0) </details> ### 📄 Description > 🤖 Opened by Sylviromi's AI agent (Claude Code, Claude Sonnet 5), not by Sylviromi personally. Closes #5261. ## What and why `native_item_bar(&self, stack: &ItemStack, bar: &mut Option<(i32, u32)>)` fires in `draw_item_decorations` (crates/horizon-client/src/game.rs ~7462), where `GuiGraphicsExtractor.itemDecorations` picks the bar to draw, after the bundle override. `bar` arrives holding vanilla's own choice; a mod may replace it (width 0..=13, an RGB colour) or clear it to hide the bar. Client only. A mod that does not hook it leaves the bar unchanged. ## Kind - [x] feature: something new for players (listed under New in the release notes) ## Vanilla reference `Item.isBarVisible`/`getBarWidth`/`getBarColor(ItemStack)`, called from `GuiGraphics.renderItemDecorations`, ported as `draw_item_decorations`. No NeoForge event exists for this moment (docs/native-hooks-neoforge.md rule 1); NeoForge mods override the same vanilla `Item` methods directly. ## Other projects' code none ## In-game proof Built a native mod bundle with a HEAD injection into `native_item_bar` that set the bar from a fluid-container item's fill level. In game: a half-filled container showed a half-width bar, a full or an empty one showed none, and other items (tools, bundles) were unchanged. No screenshot: the test content is a private mod. ## Self-check ``` pr_ready: 3 files changed since origin/main; checks on local Public tree... Public tree: pass (0 s) Python tests... Python tests: pass (48 s) rustfmt... rustfmt: pass (9 s) clippy... clippy: pass (1 min 50 s) tests: horizon-client... tests: horizon-client: pass (1 min 16 s) doc tests... doc tests: pass (1 s) **pr_ready** (`tools/pr_ready.py --quick` on boilingpoint, against origin/main at 256a52eb2, 4 min 4 s) | Check | Result | | --- | --- | | Scope | ✅ 3 files, +25 −4 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 508 passed (48 s) | | rustfmt | ✅ (9 s) | | clippy | ✅ (1 min 50 s) | | tests: horizon-client | ✅ 1542 passed (1 min 16 s) | | doc tests | ✅ 0 passed (1 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) | ``` API: pending — the hook's number comes from `tools/native-hook-fragments/item_bar.json`, stamped at merge per that fragment directory's README (docs/native-hooks-neoforge.md rule 7). Label: feature. ## Screenshots None (see "In-game proof" above: the test content is a private mod). 🤖 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:17:57 +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#6297
No description provided.