[GH-ISSUE #5261] Native mods: item_bar hook (vanilla Item.isBarVisible/getBarWidth/getBarColor) #1614

Closed
opened 2026-11-02 15:48:23 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @Sylviromi on GitHub (Oct 31, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/5261

Originally assigned to: @Sylviromi on GitHub.

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

What a mod cannot do. A native mod cannot show a bar on an item's icon (the durability-bar-shaped overlay vanilla draws under the stack size, e.g. for a tool's durability or a bundle's fullness). A mod item that wants a custom bar — a fluid tank item showing its fill level, an energy-storage item showing charge — has nothing to hook.

Why the existing hooks do not reach it. No hook in native-hooks.json fires at this moment. The moment is vanilla GuiGraphics.renderItemDecorations calling Item.isBarVisible/getBarWidth/getBarColor(ItemStack), which Horizon ports as draw_item_decorations (crates/horizon-client/src/game.rs:7095-7130, where BundleItem's override is already applied at :7114). It cannot be patched with horizon-mixins either: the function body holds a macro at game.rs:7119, and horizon-mixins fails closed on any macro in a target body by design (plan.rs:927).

Proposed hook. native_item_bar(&self, stack: &ItemStack, bar: &mut Option<(i32, u32)>), firing where draw_item_decorations picks the bar to draw. bar arrives holding vanilla's computed value (e.g. damage or bundle fullness); a mod may replace it with its own (width 0-13, RGB colour) or clear it. Client only. Cancellable in the sense that writing None suppresses the bar. API next (per docs/native-hooks-neoforge.md rule 7).

NeoForge has no event for this (per docs/native-hooks-neoforge.md rule 1, no event means Horizon keeps its own name); NeoForge mods (and NeoForge itself) override the same vanilla Item methods directly. RegisterItemDecorationsEvent/IItemDecorator was considered and not proposed: it is a registry of arbitrary draws, larger than this one moment needs.

Who already wants it. The closest open issue is #4953 (a general tracking issue for large tech mods, not this specific hook). No existing issue covers this hook.

Workaround. None today — a mod item with a custom resource level has no way to draw a bar on its icon.

Originally created by @Sylviromi on GitHub (Oct 31, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/5261 Originally assigned to: @Sylviromi on GitHub. > 🤖 Filed by Sylviromi's AI agent (Claude Code, Sonnet 5), not by Sylviromi personally. **What a mod cannot do.** A native mod cannot show a bar on an item's icon (the durability-bar-shaped overlay vanilla draws under the stack size, e.g. for a tool's durability or a bundle's fullness). A mod item that wants a custom bar — a fluid tank item showing its fill level, an energy-storage item showing charge — has nothing to hook. **Why the existing hooks do not reach it.** No hook in `native-hooks.json` fires at this moment. The moment is vanilla `GuiGraphics.renderItemDecorations` calling `Item.isBarVisible`/`getBarWidth`/`getBarColor(ItemStack)`, which Horizon ports as `draw_item_decorations` (crates/horizon-client/src/game.rs:7095-7130, where `BundleItem`'s override is already applied at :7114). It cannot be patched with horizon-mixins either: the function body holds a macro at game.rs:7119, and horizon-mixins fails closed on any macro in a target body by design (plan.rs:927). **Proposed hook.** `native_item_bar(&self, stack: &ItemStack, bar: &mut Option<(i32, u32)>)`, firing where `draw_item_decorations` picks the bar to draw. `bar` arrives holding vanilla's computed value (e.g. damage or bundle fullness); a mod may replace it with its own `(width 0-13, RGB colour)` or clear it. Client only. Cancellable in the sense that writing `None` suppresses the bar. API next (per docs/native-hooks-neoforge.md rule 7). NeoForge has no event for this (per docs/native-hooks-neoforge.md rule 1, no event means Horizon keeps its own name); NeoForge mods (and NeoForge itself) override the same vanilla `Item` methods directly. `RegisterItemDecorationsEvent`/`IItemDecorator` was considered and not proposed: it is a registry of arbitrary draws, larger than this one moment needs. **Who already wants it.** The closest open issue is #4953 (a general tracking issue for large tech mods, not this specific hook). No existing issue covers this hook. **Workaround.** None today — a mod item with a custom resource level has no way to draw a bar on its icon.
Author
Owner

@Sylviromi commented on GitHub (Oct 31, 2026):

🤖 Agent: /claim

<!-- gh-comment-id:6546184339 --> @Sylviromi commented on GitHub (Oct 31, 2026): 🤖 Agent: /claim
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#1614
No description provided.