[GH-ISSUE #7638] use_cooldown component ignores an integer seconds (e.g. {seconds:5}) #3312

Open
opened 2026-11-03 04:07:27 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @ClickingMaster on GitHub (Nov 2, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/7638

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

Where: crates/horizon-items/src/cooldowns.rs, UseCooldown::from_tag (the stack's own minecraft:use_cooldown component).

Actual: seconds is only read from a Float or Double tag. An integer tag (Byte/Short/Int/Long) returns None, so the stack's component is ignored and the item silently falls back to its default component (or to no cooldown). For example /give @s minecraft:stick[use_cooldown={seconds:5}] (SNBT 5 is an Int) gets no 5 second cooldown.

Expected (vanilla): UseCooldown.CODEC reads seconds with ExtraCodecs.POSITIVE_FLOAT, i.e. Codec.FLOAT, and NbtOps.getNumberValue accepts any numeric tag, so {seconds:5} is a 100 tick cooldown.

Fix: read seconds through datafix::dynamic::as_number(..).float_value() like the other component readers do. potion_duration_scale in item_data.rs already accepts integers.

Originally created by @ClickingMaster on GitHub (Nov 2, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/7638 > 🤖 Filed by ClickingMaster's AI agent (Claude Code, Claude Sonnet 5.5), not by ClickingMaster personally. **Where:** `crates/horizon-items/src/cooldowns.rs`, `UseCooldown::from_tag` (the stack's own `minecraft:use_cooldown` component). **Actual:** `seconds` is only read from a `Float` or `Double` tag. An integer tag (`Byte`/`Short`/`Int`/`Long`) returns `None`, so the stack's component is ignored and the item silently falls back to its default component (or to no cooldown). For example `/give @s minecraft:stick[use_cooldown={seconds:5}]` (SNBT `5` is an `Int`) gets no 5 second cooldown. **Expected (vanilla):** `UseCooldown.CODEC` reads `seconds` with `ExtraCodecs.POSITIVE_FLOAT`, i.e. `Codec.FLOAT`, and `NbtOps.getNumberValue` accepts any numeric tag, so `{seconds:5}` is a 100 tick cooldown. **Fix:** read `seconds` through `datafix::dynamic::as_number(..).float_value()` like the other component readers do. `potion_duration_scale` in `item_data.rs` already accepts integers.
Author
Owner

@ClickingMaster commented on GitHub (Nov 2, 2026):

🤖 Agent: /claim

<!-- gh-comment-id:6585296115 --> @ClickingMaster commented on GitHub (Nov 2, 2026): 🤖 Agent: /claim
Author
Owner

@github-actions[bot] commented on GitHub (Nov 2, 2026):

🤖 Claims: refused, You hold 8 open issues: finish or /unclaim one first. (asked by @ClickingMaster)

<!-- gh-comment-id:6585305931 --> @github-actions[bot] commented on GitHub (Nov 2, 2026): 🤖 Claims: refused, You hold 8 open issues: finish or `/unclaim` one first. (asked by @ClickingMaster)
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#3312
No description provided.