[PR #1933] [MERGED] Item cooldowns: the sweep on a slot, and no use while one runs #3875

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/1933
Author: @levzzz5154
Created: 10/25/2026
Status: ✅ Merged
Merged: 10/26/2026
Merged by: @ludovic111

Base: main ← Head: fix/item-cooldowns


📝 Commits (3)

  • b71623d Item cooldowns: the sweep on a slot, and no use while one runs
  • ef5361e Creatures: drop the doc comments the removed cooldown fields left behind
  • e5403c0 Merge origin/main into fix/item-cooldowns

📊 Changes

9 files changed (+306 additions, -32 deletions)

View changed files

➕ crates/horizon-client/src/cooldowns.rs (+174 -0)
📝 crates/horizon-client/src/game.rs (+49 -7)
📝 crates/horizon-client/src/game/creatures.rs (+9 -18)
📝 crates/horizon-client/src/game/lan_actions.rs (+30 -1)
📝 crates/horizon-client/src/game/remote.rs (+16 -2)
📝 crates/horizon-client/src/game/wind.rs (+0 -4)
📝 crates/horizon-client/src/items.rs (+5 -0)
📝 crates/horizon-client/src/lib.rs (+1 -0)
📝 crates/horizon-protocol/src/packets/play.rs (+22 -0)

📄 Description

🤖 Opened by levzzz5154's AI agent ([CC], deepseek-v4.1-flash), not by levzzz5154.

What and why

Fixes #1763.

Nothing tracked ItemCooldowns: draw_item_decorations passed a cooldown of 0.0 with a note that there was
none to shade, so a thrown ender pearl's slot never showed the white sweep, and the pearl was held back by an
ad-hoc pearl_cooldown counter in Creatures (a second copy, started on the client rather than by the item).

horizon_client::cooldowns keeps the use_cooldown component's entries by cooldown group as
Player.getCooldowns does — start and end ticks, getCooldownPercent for a partial tick, tick returning the
groups that just ended — and the game uses it where vanilla does:

  • ItemInfo::use_cooldown from items.json (UseCooldown), and cooldowns::component/group for a stack's own
    component over the item's default, else the item id (getCooldownGroup).
  • ServerPlayerGameMode.useItem/useItemOn: use_hand returns before using a stack that is on cooldown.
  • ItemStack.applyAfterUseComponentSideEffects: apply_use_cooldown starts the entry when a use finishes — a
    thrown pearl or wind charge, an eaten chorus fruit (finish_consuming).
  • GuiGraphicsExtractor.itemCooldown: draw_item_decorations shades the slot by
    cooldowns.percent(group, partial).
  • A server's guests keep their own entries (GuestPlay::cooldowns, swapped in for their turn) and are sent
    ClientboundCooldownPacket when one starts and when it ends (duration 0), which the client applies
    (ClientPacketListener.handleItemCooldown); the packet is new in horizon-protocol.
  • MultiPlayerGameMode.useItem predicts the entry locally inside startPrediction, which the server's packet then
    confirms.

The two ad-hoc counters (pearl_cooldown, wind_cooldown) are gone: the components carry both (ender_pearl
1.0 s, wind_charge 0.5 s, chorus_fruit 1.0 s).

Verification

In the game (horizon-ctl, server thread, survival, 16 pearls):

  • One use-item: 15 pearls left, and the hotbar slot's top rows are shaded (0x7FFFFFFF over the item, the same
    rows itemCooldown fills), fading out over the second.
  • Two use-item in a row: still 15, the second use is refused by the cooldown; after the second passes, the next
    throw works.
  • A chorus fruit: eaten, a second one refused until the second ends.

cooldowns::tests pin the percent curve and the group lookup; a_cooldown_packet_carries_its_group_and_ticks
pins the packet.

Scope

9 files, +306 −29, one new module. cargo test -p horizon-client --lib cooldowns and
cargo test -p horizon-protocol a_cooldown pass.

🤖 Generated with [CC].

Self-check

pr_ready (tools/pr_ready.py --quick --base upstream/main on cachyos-x8664, against upstream/main at 7fd1f3118, 2 min 22 s)

Check Result
Scope ✅ 9 files, +306 −29
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ➖ no Python change
rustfmt ✅ (4 s)
clippy ❌ failed (8 s)
tests: horizon-client, horizon-protocol ✅ 1335 passed (2 min 6 s)
doc tests ✅ 0 passed (2 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 269 affected, to run in CI (--quick)
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

clippy fails on crates/horizon-client/src/mobs/axolotl.rs:169 (overly_complex_bool_expr), which fails the same way on upstream/main at 7fd1f3118: nothing in this branch touches it.

🤖 Generated with [CC].


🔄 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/1933 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 10/25/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/item-cooldowns` --- ### 📝 Commits (3) - [`b71623d`](https://github.com/horizon-rust/horizon/commit/b71623dfd7a7b402b40bf6424efbcfae8f8e8c64) Item cooldowns: the sweep on a slot, and no use while one runs - [`ef5361e`](https://github.com/horizon-rust/horizon/commit/ef5361e4c25c223c6607af9efad9ca0d9348978d) Creatures: drop the doc comments the removed cooldown fields left behind - [`e5403c0`](https://github.com/horizon-rust/horizon/commit/e5403c0224f4ba788b6a6efe1dd2c1c3be58e02b) Merge origin/main into fix/item-cooldowns ### 📊 Changes **9 files changed** (+306 additions, -32 deletions) <details> <summary>View changed files</summary> ➕ `crates/horizon-client/src/cooldowns.rs` (+174 -0) 📝 `crates/horizon-client/src/game.rs` (+49 -7) 📝 `crates/horizon-client/src/game/creatures.rs` (+9 -18) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+30 -1) 📝 `crates/horizon-client/src/game/remote.rs` (+16 -2) 📝 `crates/horizon-client/src/game/wind.rs` (+0 -4) 📝 `crates/horizon-client/src/items.rs` (+5 -0) 📝 `crates/horizon-client/src/lib.rs` (+1 -0) 📝 `crates/horizon-protocol/src/packets/play.rs` (+22 -0) </details> ### 📄 Description > 🤖 Opened by levzzz5154's AI agent ([CC], deepseek-v4.1-flash), not by levzzz5154. ## What and why Fixes #1763. Nothing tracked `ItemCooldowns`: `draw_item_decorations` passed a cooldown of `0.0` with a note that there was none to shade, so a thrown ender pearl's slot never showed the white sweep, and the pearl was held back by an ad-hoc `pearl_cooldown` counter in `Creatures` (a second copy, started on the client rather than by the item). `horizon_client::cooldowns` keeps the `use_cooldown` component's entries by cooldown group as `Player.getCooldowns` does — start and end ticks, `getCooldownPercent` for a partial tick, `tick` returning the groups that just ended — and the game uses it where vanilla does: - `ItemInfo::use_cooldown` from `items.json` (`UseCooldown`), and `cooldowns::component`/`group` for a stack's own component over the item's default, else the item id (`getCooldownGroup`). - `ServerPlayerGameMode.useItem`/`useItemOn`: `use_hand` returns before using a stack that is on cooldown. - `ItemStack.applyAfterUseComponentSideEffects`: `apply_use_cooldown` starts the entry when a use finishes — a thrown pearl or wind charge, an eaten chorus fruit (`finish_consuming`). - `GuiGraphicsExtractor.itemCooldown`: `draw_item_decorations` shades the slot by `cooldowns.percent(group, partial)`. - A server's guests keep their own entries (`GuestPlay::cooldowns`, swapped in for their turn) and are sent `ClientboundCooldownPacket` when one starts and when it ends (duration 0), which the client applies (`ClientPacketListener.handleItemCooldown`); the packet is new in `horizon-protocol`. - `MultiPlayerGameMode.useItem` predicts the entry locally inside `startPrediction`, which the server's packet then confirms. The two ad-hoc counters (`pearl_cooldown`, `wind_cooldown`) are gone: the components carry both (`ender_pearl` 1.0 s, `wind_charge` 0.5 s, `chorus_fruit` 1.0 s). ## Verification In the game (`horizon-ctl`, server thread, survival, 16 pearls): - One `use-item`: 15 pearls left, and the hotbar slot's top rows are shaded (`0x7FFFFFFF` over the item, the same rows `itemCooldown` fills), fading out over the second. - Two `use-item` in a row: still 15, the second use is refused by the cooldown; after the second passes, the next throw works. - A chorus fruit: eaten, a second one refused until the second ends. `cooldowns::tests` pin the percent curve and the group lookup; `a_cooldown_packet_carries_its_group_and_ticks` pins the packet. ## Scope 9 files, +306 −29, one new module. `cargo test -p horizon-client --lib cooldowns` and `cargo test -p horizon-protocol a_cooldown` pass. 🤖 Generated with [[CC]](https://github.com/levzzz5154/horizon). ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on cachyos-x8664, against upstream/main at 7fd1f3118, 2 min 22 s) | Check | Result | | --- | --- | | Scope | ✅ 9 files, +306 −29 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ➖ no Python change | | rustfmt | ✅ (4 s) | | clippy | ❌ failed (8 s) | | tests: horizon-client, horizon-protocol | ✅ 1335 passed (2 min 6 s) | | doc tests | ✅ 0 passed (2 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 269 affected, to run in CI (--quick) | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | `clippy` fails on `crates/horizon-client/src/mobs/axolotl.rs:169` (`overly_complex_bool_expr`), which fails the same way on `upstream/main` at 7fd1f3118: nothing in this branch touches it. 🤖 Generated with [[CC]](https://github.com/levzzz5154/horizon). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:12: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#3875
No description provided.