[GH-ISSUE #3425] Potion tooltips print effect durations as "0:07" instead of vanilla's "00:07" #969

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

Originally created by @degepie on GitHub (Oct 28, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/3425

🤖 Filed by degepie's AI agent (Claude Code), not by degepie personally.

What happens

Potion, splash/lingering potion and tipped arrow tooltips print the effect duration without zero-padding the minutes, e.g. Speed (3:00) on a Potion of Swiftness or Weakness (1:30) on a Potion of Weakness; vanilla shows Speed (03:00) and Weakness (01:30).

What vanilla does

PotionContents.addPotionTooltip formats each effect's duration with MobEffectUtil.formatDuration. An infinite effect shows the effect.duration.infinite text. Otherwise the duration (scaled by durationScale) goes to StringUtil.formatTickDuration, which converts ticks to seconds with the level's tick rate (not a fixed 20) and prints mm:ss, or hh:mm:ss from one hour up, every field zero-padded to two digits.

So vanilla prints 00:07, 01:30, 08:00, 01:00:00 (and effect.duration.infinite for infinite effects).

ticks vanilla Horizon
140 (7 s) 00:07 0:07
1800 (1:30) 01:30 1:30
9600 (8 min) 08:00 8:00
72000 (1 h) 01:00:00 1:00:00

Where in Horizon

origin/main 142388e1c (142388e1c136e622652ec7505af15d8ad195e041):

  • crates/horizon-client/src/brewing.rs:18-26 format_duration: format!("{h}:{m:02}:{s:02}") / format!("{m}:{s:02}"), at a fixed 20 TPS. Its unit test (brewing.rs:320-321) asserts the unpadded form ("8:00", "0:22").
  • Used by brewing::tooltip (brewing.rs:63), which item_tooltip.rs:557 and game/stations.rs:1878 call for potion tooltips.
  • The inventory's effect panel already does it right: crates/horizon-client/src/inventory_effects.rs:58-68 uses {:02} and the level's tick rate, so the two disagree on the same screen.

How to reproduce

  1. Creative world, open the creative inventory, search swiftness.
  2. Hover a Potion of Swiftness: Horizon shows Speed (3:00), vanilla Speed (03:00).

Seen from code only; not checked in game for this report. Open PR #3405 (suspicious stew tooltip) saw Weakness (0:07) in game and explicitly left this mismatch for a separate fix.

Notes

  • Fix: pad minutes ({m:02}, {h:02}) and ideally take the tick rate as inventory_effects.rs does; update the two asserts.
  • Once #3405 lands, the suspicious stew tooltip goes through the same function and is fixed with it.
Originally created by @degepie on GitHub (Oct 28, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/3425 > 🤖 Filed by degepie's AI agent (Claude Code), not by degepie personally. ## What happens Potion, splash/lingering potion and tipped arrow tooltips print the effect duration without zero-padding the minutes, e.g. `Speed (3:00)` on a Potion of Swiftness or `Weakness (1:30)` on a Potion of Weakness; vanilla shows `Speed (03:00)` and `Weakness (01:30)`. ## What vanilla does `PotionContents.addPotionTooltip` formats each effect's duration with `MobEffectUtil.formatDuration`. An infinite effect shows the `effect.duration.infinite` text. Otherwise the duration (scaled by `durationScale`) goes to `StringUtil.formatTickDuration`, which converts ticks to seconds with the level's tick rate (not a fixed 20) and prints `mm:ss`, or `hh:mm:ss` from one hour up, **every field zero-padded to two digits**. So vanilla prints `00:07`, `01:30`, `08:00`, `01:00:00` (and `effect.duration.infinite` for infinite effects). | ticks | vanilla | Horizon | | --- | --- | --- | | 140 (7 s) | `00:07` | `0:07` | | 1800 (1:30) | `01:30` | `1:30` | | 9600 (8 min) | `08:00` | `8:00` | | 72000 (1 h) | `01:00:00` | `1:00:00` | ## Where in Horizon origin/main 142388e1c (`142388e1c136e622652ec7505af15d8ad195e041`): - `crates/horizon-client/src/brewing.rs:18-26` `format_duration`: `format!("{h}:{m:02}:{s:02}")` / `format!("{m}:{s:02}")`, at a fixed 20 TPS. Its unit test (`brewing.rs:320-321`) asserts the unpadded form (`"8:00"`, `"0:22"`). - Used by `brewing::tooltip` (`brewing.rs:63`), which `item_tooltip.rs:557` and `game/stations.rs:1878` call for potion tooltips. - The inventory's effect panel already does it right: `crates/horizon-client/src/inventory_effects.rs:58-68` uses `{:02}` and the level's tick rate, so the two disagree on the same screen. ## How to reproduce 1. Creative world, open the creative inventory, search `swiftness`. 2. Hover a Potion of Swiftness: Horizon shows `Speed (3:00)`, vanilla `Speed (03:00)`. Seen from code only; not checked in game for this report. Open PR #3405 (suspicious stew tooltip) saw `Weakness (0:07)` in game and explicitly left this mismatch for a separate fix. ## Notes - Fix: pad minutes (`{m:02}`, `{h:02}`) and ideally take the tick rate as `inventory_effects.rs` does; update the two asserts. - Once #3405 lands, the suspicious stew tooltip goes through the same function and is fixed with it.
Author
Owner

@kira-horizon[bot] commented on GitHub (Oct 29, 2026):

Claimed by John Pork on Discord (GitHub: ASOwnerYT), to avoid duplicate work. The claim lapses after 14 days without activity (a comment, a pull request or a commit mentioning #3425).

<!-- gh-comment-id:6486963690 --> @kira-horizon[bot] commented on GitHub (Oct 29, 2026): Claimed by `John Pork` on Discord (GitHub: `ASOwnerYT`), to avoid duplicate work. The claim lapses after 14 days without activity (a comment, a pull request or a commit mentioning #3425). <!-- kira:work -->
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#969
No description provided.