[PR #6992] [MERGED] The item_stack helper draws nothing for an empty stack #7255

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

📋 Pull Request Information

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

Base: main ← Head: fix/6968-empty-item-stack


📝 Commits (1)

  • fb02440 The item_stack helper draws nothing for an empty stack

📊 Changes

4 files changed (+15 additions, -7 deletions)

View changed files

📝 crates/horizon-client/src/game/native_hooks.rs (+8 -1)
📝 crates/horizon-client/src/mod_api/generated.rs (+3 -4)
📝 crates/horizon-client/src/mod_api/generated_host.rs (+3 -1)
📝 tools/native-hook-fragments/item_stack.json (+1 -1)

📄 Description

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

What and why

Fixes #6968.

native_item_stack, the item_stack Host helper, drew an empty stack: a count of 0 still drew the item's model and decorations, because the only guard was that the item id is known. Vanilla 26.3's GuiGraphicsExtractor.item and itemDecorations both start with if (!itemStack.isEmpty()), so a mod screen that passes a slot's contents straight to the helper showed a ghost icon where vanilla leaves the slot blank.

The helper now returns false and draws nothing for an empty stack: air, or a count of 0, as ItemStack.isEmpty. That's the same test explosion.rs and commands.rs use. False already meant "nothing was drawn", so a mod that checks the result keeps working. The doc comment and the fragment's doc_summary say so.

cargo run -p xtask -- mod-api copied the new doc into generated_host.rs. It also refreshed one unrelated paragraph in generated.rs, the native_projectile_impact doc, which native_hooks.rs on main had already changed without regenerating.

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

  • net.minecraft.client.gui.GuiGraphicsExtractor.item(...) and itemDecorations(...): if (!itemStack.isEmpty()) around everything they draw.
  • net.minecraft.world.item.ItemStack.isEmpty: air, or a count of 0 or less.

Not run in game with a mod screen. horizon-machine-sample is the route for that check.

Other projects' code

none

Self-check

pr_ready (tools/pr_ready.py --quick --base upstream/main on DESKTOP-G0M27UC, against upstream/main at 26b9c0c9b, 16 min 16 s)

Check Result
Scope ✅ 4 files, +15 −7
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 611 passed (4 min 39 s)
rustfmt ✅ (21 s)
clippy ✅ (3 min 38 s)
tests: horizon-client, horizon-client-lib ✅ 2053 passed (6 min 58 s)
doc tests ✅ 0 passed (8 s)
content root tests ➖ content root untouched
mod API up to date ✅ (26 s)
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)

🤖 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/6992 **Author:** [@breachato](https://github.com/breachato) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/6968-empty-item-stack` --- ### 📝 Commits (1) - [`fb02440`](https://github.com/horizon-rust/horizon/commit/fb024406b9e989ffd78afcd8d657b652f9849f8c) The item_stack helper draws nothing for an empty stack ### 📊 Changes **4 files changed** (+15 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/native_hooks.rs` (+8 -1) 📝 `crates/horizon-client/src/mod_api/generated.rs` (+3 -4) 📝 `crates/horizon-client/src/mod_api/generated_host.rs` (+3 -1) 📝 `tools/native-hook-fragments/item_stack.json` (+1 -1) </details> ### 📄 Description > 🤖 Opened by breachato's AI agent (Claude Code, Claude Opus 5.5), not by breachato personally. ## What and why Fixes #6968. `native_item_stack`, the `item_stack` Host helper, drew an empty stack: a count of 0 still drew the item's model and decorations, because the only guard was that the item id is known. Vanilla 26.3's `GuiGraphicsExtractor.item` and `itemDecorations` both start with `if (!itemStack.isEmpty())`, so a mod screen that passes a slot's contents straight to the helper showed a ghost icon where vanilla leaves the slot blank. The helper now returns false and draws nothing for an empty stack: air, or a count of 0, as `ItemStack.isEmpty`. That's the same test `explosion.rs` and `commands.rs` use. False already meant "nothing was drawn", so a mod that checks the result keeps working. The doc comment and the fragment's `doc_summary` say so. `cargo run -p xtask -- mod-api` copied the new doc into `generated_host.rs`. It also refreshed one unrelated paragraph in `generated.rs`, the `native_projectile_impact` doc, which `native_hooks.rs` on main had already changed without regenerating. ## Kind - [x] 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 - `net.minecraft.client.gui.GuiGraphicsExtractor.item(...)` and `itemDecorations(...)`: `if (!itemStack.isEmpty())` around everything they draw. - `net.minecraft.world.item.ItemStack.isEmpty`: air, or a count of 0 or less. Not run in game with a mod screen. horizon-machine-sample is the route for that check. ## Other projects' code none ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on DESKTOP-G0M27UC, against upstream/main at 26b9c0c9b, 16 min 16 s) | Check | Result | | --- | --- | | Scope | ✅ 4 files, +15 −7 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 611 passed (4 min 39 s) | | rustfmt | ✅ (21 s) | | clippy | ✅ (3 min 38 s) | | tests: horizon-client, horizon-client-lib | ✅ 2053 passed (6 min 58 s) | | doc tests | ✅ 0 passed (8 s) | | content root tests | ➖ content root untouched | | mod API up to date | ✅ (26 s) | | 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) | 🤖 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:36:30 +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#7255
No description provided.