[PR #3571] [MERGED] Ominous bottles list their Bad Omen level and duration in the tooltip #5061

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3571
Author: @d3grando
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @ludovic111

Base: main ← Head: fix-3501


📝 Commits (1)

  • 7808916 Ominous bottles list their Bad Omen level and duration in the tooltip

📊 Changes

5 files changed (+175 additions, -2 deletions)

View changed files

📝 crates/horizon-client/src/game/stations.rs (+6 -0)
📝 crates/horizon-client/src/item_sync.rs (+50 -0)
📝 crates/horizon-client/src/item_tooltip.rs (+95 -0)
📝 crates/horizon-client/src/lan/guest.rs (+6 -0)
📝 crates/horizon-protocol/src/item.rs (+18 -2)

📄 Description

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

Fixes #3501

What and why

An ominous bottle's tooltip showed only its name, so the five bottles (Bad Omen I to V) looked the same. Two things were missing:

  1. No tooltip line. Nothing drew OminousBottleAmplifier.addToTooltip. item_tooltip::ominous_bottle_line now builds it: Bad Omen at the bottle's amplifier for 120000 ticks, formatted the way PotionContents.addPotionTooltip formats an effect (potion.withAmplifier, potion.withDuration, through format_translation, so numbered templates work too), in blue because Bad Omen's category is NEUTRAL. A bottle without the component uses the item's default amplifier, 0. minecraft:tooltip_display can hide it. The line goes after unbreakable and before the block-state line, which is where ItemStack.addDetailsToTooltip puts it. The recipe-book search lines (detail_lines) list it too, after the attribute lines as in vanilla.
  2. The amplifier never reached the client on the default server-thread path, on LAN, or from a dedicated server. The server's network_stack didn't send minecraft:ominous_bottle_amplifier, and the protocol read component 65 as raw bytes, so the client's stack had no amplifier. The server now sends it, and the protocol reads it as a VarInt (OminousBottleAmplifier.STREAM_CODEC is ByteBufCodecs.VAR_INT). item_sync then decodes it like the saved NBT. A vanilla server's bottles also show their level now.

The duration uses the existing brewing::format_duration, so it shows 1:40:00 today. #3504 changes that helper to vanilla's 01:40:00, and this line will follow it. The test compares against the helper rather than a fixed string.

Vanilla reference

  • OminousBottleAmplifier.addToTooltip: List.of(new MobEffectInstance(MobEffects.BAD_OMEN, 120000, value, false, false, true)), then PotionContents.addPotionTooltip(list, consumer, 1.0F, context.tickRate()).
  • PotionContents.addPotionTooltip / getPotionDescription: potion.withAmplifier + potion.potency.N when the amplifier is above 0, and potion.withDuration unless the effect endsWithin(20). The colour is MobEffectCategory.getTooltipFormatting(): MobEffects.BAD_OMEN is NEUTRAL, which is ChatFormatting.BLUE.
  • ItemStack.addDetailsToTooltip: OMINOUS_BOTTLE_AMPLIFIER comes after UNBREAKABLE and the sign texts, and before SUSPICIOUS_STEW_EFFECTS and BLOCK_STATE.
  • OminousBottleAmplifier.STREAM_CODEC: ByteBufCodecs.VAR_INT. Its data_component_type protocol id is 65 in 26.3's registries.

Checked with javap -c -p against the 26.3 client jar.

Tests

New and extended tests. The "before" runs had the fix taken out by hand:

  • item_tooltip::tests::ominous_bottle_lists_bad_omen_at_its_amplifier_for_100_minutes: the default bottle, amplifier 3 (Bad Omen IV), a numbered potion.withDuration template, tooltip_display hiding it, and a glass bottle with no line.
    • before (no line): left: None, right: Some(("Bad Omen (1:40:00)", 4294923605)), FAILED
    • after: ok
  • item_sync::tests::an_ominous_bottle_keeps_its_amplifier_across_the_wire: server ItemStack, then stack_to_network, then the Slot bytes, then from_network, for None, Some(0) and Some(3).
    • before (not sent): assertion failed: Some(0); left: None, right: Some(0), FAILED
    • after: ok
  • horizon-protocol item::tests::stacks_round_trip: a bottle with component 65 writes [1, 0xb0, 0x09, 1, 0, 65, 3] and reads back as Int(3).
    • before: left: ... added: [(65, Raw([3]))] ... right: ... added: [(65, Int(3))], FAILED
    • after: ok

Self-check

tools/pr_ready.py wasn't run (Windows machine). I ran these instead, rebased on main at 11494e17f:

cargo fmt --all -- --check                                                  # clean
cargo clippy -p horizon-protocol --all-targets -- -D warnings               # clean
cargo clippy -p horizon-client --features mods --all-targets -- -D warnings # clean
cargo test -p horizon-protocol --lib item::tests                            # 11 passed
cargo test -p horizon-client --lib -- item_sync::tests item_tooltip::tests  # 14 passed, 1 ignored (needs HORIZON_TEST_RESOURCES)

In game

Windows, survival, default server-thread single player. The hotbar holds ominous_bottle[ominous_bottle_amplifier=3] and a plain ominous_bottle; each was hovered in the inventory.

  • Before (v0.2.97): both tooltips show only the yellow name Ominous Bottle.
  • After: Ominous Bottle and a blue Bad Omen IV (1:40:00) for amplifier 3, and a blue Bad Omen (1:40:00) for the plain bottle.

🤖 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/3571 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix-3501` --- ### 📝 Commits (1) - [`7808916`](https://github.com/horizon-rust/horizon/commit/7808916266e4e15b00b0d45cbbdb865a0ffddbcd) Ominous bottles list their Bad Omen level and duration in the tooltip ### 📊 Changes **5 files changed** (+175 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/stations.rs` (+6 -0) 📝 `crates/horizon-client/src/item_sync.rs` (+50 -0) 📝 `crates/horizon-client/src/item_tooltip.rs` (+95 -0) 📝 `crates/horizon-client/src/lan/guest.rs` (+6 -0) 📝 `crates/horizon-protocol/src/item.rs` (+18 -2) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. Fixes #3501 ## What and why An ominous bottle's tooltip showed only its name, so the five bottles (Bad Omen I to V) looked the same. Two things were missing: 1. **No tooltip line.** Nothing drew `OminousBottleAmplifier.addToTooltip`. `item_tooltip::ominous_bottle_line` now builds it: Bad Omen at the bottle's amplifier for 120000 ticks, formatted the way `PotionContents.addPotionTooltip` formats an effect (`potion.withAmplifier`, `potion.withDuration`, through `format_translation`, so numbered templates work too), in blue because Bad Omen's category is NEUTRAL. A bottle without the component uses the item's default amplifier, 0. `minecraft:tooltip_display` can hide it. The line goes after `unbreakable` and before the block-state line, which is where `ItemStack.addDetailsToTooltip` puts it. The recipe-book search lines (`detail_lines`) list it too, after the attribute lines as in vanilla. 2. **The amplifier never reached the client** on the default server-thread path, on LAN, or from a dedicated server. The server's `network_stack` didn't send `minecraft:ominous_bottle_amplifier`, and the protocol read component 65 as raw bytes, so the client's stack had no amplifier. The server now sends it, and the protocol reads it as a VarInt (`OminousBottleAmplifier.STREAM_CODEC` is `ByteBufCodecs.VAR_INT`). `item_sync` then decodes it like the saved NBT. A vanilla server's bottles also show their level now. The duration uses the existing `brewing::format_duration`, so it shows `1:40:00` today. #3504 changes that helper to vanilla's `01:40:00`, and this line will follow it. The test compares against the helper rather than a fixed string. ## Vanilla reference - `OminousBottleAmplifier.addToTooltip`: `List.of(new MobEffectInstance(MobEffects.BAD_OMEN, 120000, value, false, false, true))`, then `PotionContents.addPotionTooltip(list, consumer, 1.0F, context.tickRate())`. - `PotionContents.addPotionTooltip` / `getPotionDescription`: `potion.withAmplifier` + `potion.potency.N` when the amplifier is above 0, and `potion.withDuration` unless the effect `endsWithin(20)`. The colour is `MobEffectCategory.getTooltipFormatting()`: `MobEffects.BAD_OMEN` is `NEUTRAL`, which is `ChatFormatting.BLUE`. - `ItemStack.addDetailsToTooltip`: `OMINOUS_BOTTLE_AMPLIFIER` comes after `UNBREAKABLE` and the sign texts, and before `SUSPICIOUS_STEW_EFFECTS` and `BLOCK_STATE`. - `OminousBottleAmplifier.STREAM_CODEC`: `ByteBufCodecs.VAR_INT`. Its `data_component_type` protocol id is 65 in 26.3's registries. Checked with `javap -c -p` against the 26.3 client jar. ## Tests New and extended tests. The "before" runs had the fix taken out by hand: - `item_tooltip::tests::ominous_bottle_lists_bad_omen_at_its_amplifier_for_100_minutes`: the default bottle, amplifier 3 (`Bad Omen IV`), a numbered `potion.withDuration` template, `tooltip_display` hiding it, and a glass bottle with no line. - before (no line): `left: None, right: Some(("Bad Omen (1:40:00)", 4294923605))`, FAILED - after: ok - `item_sync::tests::an_ominous_bottle_keeps_its_amplifier_across_the_wire`: server `ItemStack`, then `stack_to_network`, then the `Slot` bytes, then `from_network`, for `None`, `Some(0)` and `Some(3)`. - before (not sent): `assertion failed: Some(0); left: None, right: Some(0)`, FAILED - after: ok - `horizon-protocol` `item::tests::stacks_round_trip`: a bottle with component 65 writes `[1, 0xb0, 0x09, 1, 0, 65, 3]` and reads back as `Int(3)`. - before: `left: ... added: [(65, Raw([3]))] ... right: ... added: [(65, Int(3))]`, FAILED - after: ok ## Self-check `tools/pr_ready.py` wasn't run (Windows machine). I ran these instead, rebased on main at 11494e17f: ``` cargo fmt --all -- --check # clean cargo clippy -p horizon-protocol --all-targets -- -D warnings # clean cargo clippy -p horizon-client --features mods --all-targets -- -D warnings # clean cargo test -p horizon-protocol --lib item::tests # 11 passed cargo test -p horizon-client --lib -- item_sync::tests item_tooltip::tests # 14 passed, 1 ignored (needs HORIZON_TEST_RESOURCES) ``` ## In game Windows, survival, default server-thread single player. The hotbar holds `ominous_bottle[ominous_bottle_amplifier=3]` and a plain `ominous_bottle`; each was hovered in the inventory. - Before (v0.2.97): both tooltips show only the yellow name `Ominous Bottle`. - After: `Ominous Bottle` and a blue `Bad Omen IV (1:40:00)` for amplifier 3, and a blue `Bad Omen (1:40:00)` for the plain bottle. 🤖 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 05:09: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#5061
No description provided.