The item_stack helper draws nothing for an empty stack

GuiGraphicsExtractor.item and itemDecorations skip an empty stack (air,
or a count of 0), so native_item_stack now returns false for one instead
of drawing a ghost icon. Regenerating the mod API also refreshes the
native_projectile_impact doc that main had left stale.

Fixes #6968.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
breachatoandClaude Opus 5.5 committed 2026-11-02 10:45:22 +01:00
1 parent 26b9c0c9ba
commit fb024406b9
4 files changed
+15 -7

No files matched your search

@@ -6932,7 +6932,9 @@ impl Game<'_> {
true
}
/// Draw a stack and its slot decorations, except the count, at `at`,
/// `size` GUI pixels square. False for an unknown item. API @API:item_stack@.
/// `size` GUI pixels square. False when nothing was drawn: an unknown item
/// or an empty stack (air, or a count of 0, as `ItemStack.isEmpty`).
/// API @API:item_stack@.
pub(super) fn native_item_stack(
&self,
batch: &mut HudBatch,
@@ -6940,6 +6942,11 @@ impl Game<'_> {
at: [f32; 2],
size: f32,
) -> bool {
// GuiGraphicsExtractor.item and itemDecorations draw nothing for an
// empty stack.
if &*stack.item == "minecraft:air" || stack.count == 0 {
return false;
}
if self.res.items().get(&stack.item).is_none() {
return false;
}
+3 -4
View File
@@ -2013,10 +2013,9 @@ pub trait Hooks: Send + Sync {
/// does not happen: no damage, no knockback, no sound, no block reaction, the
/// arrow does not stick, a pearl does not teleport, a potion or a fireball
/// does not burst. The projectile flies on and is not discarded, so a mod
/// that cancels also decides what becomes of it: it hits again the next tick
/// unless the mod moves, turns or removes it. An arrow stays where it would
/// have hit, and the other projectiles go on through the whole of their
/// motion. Covers what `tick_projectiles` flies: arrows, tridents, snowballs,
/// that cancels also decides what becomes of it. It continues through its
/// whole motion and may hit something on a later tick. Covers what
/// `tick_projectiles` flies: arrows, tridents, snowballs,
/// eggs, pearls, potions, fireballs, wither skulls, wind charges, llama spit and
/// shulker bullets, from players, mobs and dispensers. It does not fire for
/// a breeze's deflection, for a hit on a wind charge, for fireworks or for
+3 -1
View File
@@ -665,6 +665,8 @@ pub trait Host {
max: u32,
) -> u32;
/// Draw a stack and its slot decorations, except the count, at `at`,
/// `size` GUI pixels square. False for an unknown item. API @API:item_stack@.
/// `size` GUI pixels square. False when nothing was drawn: an unknown item
/// or an empty stack (air, or a count of 0, as `ItemStack.isEmpty`).
/// API @API:item_stack@.
fn item_stack(&self, batch: &mut HudBatch, stack: &ItemStack, at: [f32; 2], size: f32) -> bool;
}
+1 -1
View File
@@ -4,5 +4,5 @@
{"name": "item_stack", "target": "horizon_client::game::native_hooks::Game<'_>::native_item_stack"}
],
"rust_summary": "drawing a component-bearing item stack and its decorations on a screen (`native_item_stack`).",
"doc_summary": "drawing an item stack on a screen: `native_item_stack(batch, stack, at, size)` draws its model, glint, damage bar, cooldown and mod decorations, but not its count. It returns false for an unknown item. Bundles need \"hooks\": @API:item_stack@."
"doc_summary": "drawing an item stack on a screen: `native_item_stack(batch, stack, at, size)` draws its model, glint, damage bar, cooldown and mod decorations, but not its count. It draws nothing and returns false for an unknown item or an empty stack (air, or a count of 0). Bundles need \"hooks\": @API:item_stack@."
}