[PR #3405] [MERGED] Keep suspicious stew effects across the wire and list them in creative (#3137) #4959

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

📋 Pull Request Information

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

Base: main ← Head: fix/issue-3137-suspicious-stew


📝 Commits (4)

  • cb1c349 Keep suspicious stew effects across the wire and list them in creative
  • ac7e491 Merge remote-tracking branch 'origin/main' into fix/issue-3137-suspicious-stew
  • 8537e29 Merge remote-tracking branch 'origin/main' into fix/issue-3137-suspicious-stew
  • 95c234c Merge main into the branch

📊 Changes

7 files changed (+217 additions, -15 deletions)

View changed files

📝 crates/horizon-client-render/src/brewing.rs (+16 -6)
📝 crates/horizon-client/src/game/stations.rs (+10 -0)
📝 crates/horizon-client/src/item_sync.rs (+40 -1)
📝 crates/horizon-client/src/item_tooltip.rs (+112 -4)
📝 crates/horizon-client/src/lan/guest.rs (+15 -0)
📝 crates/horizon-protocol/examples/item_wire_probe.rs (+7 -3)
📝 crates/horizon-protocol/src/item.rs (+17 -1)

📄 Description

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

Fixes #3137.

What

A suspicious stew taken from the creative inventory gave no effect when eaten, and its tooltip in the creative grid listed no effects.

Cause: horizon-protocol read the minecraft:suspicious_stew_effects component (id 55) past as raw bytes, item_sync::from_network drops raw components, and lan::guest::stack_to_network never encoded stew_effects. On the default server-thread path, the creative client's SetCreativeModeSlot therefore handed the server a bare stew, and the server's finish_consuming (already a port of SuspiciousStewEffects.onConsume) had nothing to apply. Stews from /give or crafting were not affected, since those stay on the server. The creative tooltip line itself was never ported.

Vanilla

  • SuspiciousStewEffects.onConsume: user.addEffect(entry.createEffectInstance()) for each entry (already ported, unchanged)
  • SuspiciousStewEffects$Entry.STREAM_CODEC: MobEffect.STREAM_CODEC (ByteBufCodecs.holderRegistry(MOB_EFFECT), the plain registry id), then VAR_INT duration, as a list
  • SuspiciousStewEffects.addToTooltip: only when flag.isCreative(), PotionContents.addPotionTooltip(effects, …, 1.0f, tickRate)
  • PotionContents.addPotionTooltip: one line per effect (duration only if it doesn't end within 20 ticks), coloured by MobEffectCategory.getTooltipFormatting() (harmful RED, beneficial and neutral BLUE), "No Effects" when there are none, then the "When Applied:" modifier block
  • ItemStack.addDetailsToTooltip: SUSPICIOUS_STEW_EFFECTS comes after UNBREAKABLE and before BLOCK_STATE
  • CreativeModeInventoryScreen.getTooltipFromContainerItem: asCreative() for the screen's own creative slots
  • CreativeModeTabs.generateSuspiciousStews and items.json: the stew's default component is an empty list, so a plain stew in the grid shows "No Effects"

How

  • horizon-protocol/src/item.rs: new component::SUSPICIOUS_STEW_EFFECTS and a typed Component::StewEffects(Vec<(effect id, duration)>) that is read and written byte for byte. The item_wire probe keeps this component under its byte-equality check, as it does for trims.
  • item_sync.rs: from the wire into the [{id, duration}] NBT that item_data reads. Effect names come from the built-in minecraft:mob_effect registry.
  • lan/guest.rs::network_stack: encodes stew_effects. This fixes both directions: the client's SetCreativeModeSlot, and a hub sending to its clients.
  • brewing::effect_lines and item_tooltip::effect_modifier_lines: factored out of the potion tooltip so the potion and stew paths share them. Potion output is unchanged.
  • item_tooltip::stew_lines: called from stack_tooltip_lines at vanilla's position. The creative flag uses the same approximation the name line already uses (self.screen == Screen::Creative), so it also applies to the creative screen's hotbar row, where vanilla uses its normal flag.

Verified

  • In game (default server-thread path, scratch home, creative world): took the Fire Resistance stew from the creative search tab, moved it to the hotbar and ate it.
    • Before (released v0.2.91): effects: [].
    • After (this branch): fire_resistance active (47 ticks left when queried).
  • Before the fix I also confirmed that /give and survival-crafted stews already applied their effects (night vision; fire resistance), which narrowed the cause to the creative path.
  • Tooltip, hovering over the grid stew:
    • Before: only "Suspicious Stew".
    • After: "Weakness (0:07)" in red, an empty line, "When Applied:", then "-4 Attack Damage".
  • Unit tests:
    • item::tests::components_read_past_keep_their_bytes: component 55 now decodes to StewEffects([(15,100),(18,160)]) and still re-encodes to the same bytes.
    • item_sync::a_creative_stack_keeps_its_components_across_the_wire: a stew round-trips with its effects.
    • New item_tooltip::stew_effects_show_only_with_the_creative_flag.
  • Harness: python3 tools/parity.py item_wire passes (374 stacks, all 122 component types).

Not done here: Horizon's brewing::format_duration prints 0:07 where vanilla's StringUtil.formatTickDuration prints 00:07. Potions have the same mismatch already, so it belongs in a separate fix.

pr_ready (tools/pr_ready.py --quick on b550, against origin/main at abd1755f9, 10 min 49 s)

Check Result
Scope ✅ 7 files, +218 −15
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 405 passed (36 s)
rustfmt ✅ (6 s)
clippy ✅ (4 min 39 s)
tests: horizon-client, horizon-protocol ✅ 1383 passed (4 min 49 s)
doc tests ✅ 0 passed (32 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 348 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 336 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Note: this touches the same spots in horizon-protocol/src/item.rs and examples/item_wire_probe.rs as #3380 (goat horn instrument), since both add a component next to Trim. Whichever lands second needs a trivial rebase. I'll do it on this branch if #3380 goes first.

🤖 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/3405 **Author:** [@degepie](https://github.com/degepie) **Created:** 10/28/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/issue-3137-suspicious-stew` --- ### 📝 Commits (4) - [`cb1c349`](https://github.com/horizon-rust/horizon/commit/cb1c3499bf5df5b54f6ace08c5d182a47ff20650) Keep suspicious stew effects across the wire and list them in creative - [`ac7e491`](https://github.com/horizon-rust/horizon/commit/ac7e491f3b041f6c7b48174988eb57026de21872) Merge remote-tracking branch 'origin/main' into fix/issue-3137-suspicious-stew - [`8537e29`](https://github.com/horizon-rust/horizon/commit/8537e29c9245c3a5e1431a9f4157c175b3668b00) Merge remote-tracking branch 'origin/main' into fix/issue-3137-suspicious-stew - [`95c234c`](https://github.com/horizon-rust/horizon/commit/95c234cc1e0da0f631277467809b10aa037ea9f3) Merge main into the branch ### 📊 Changes **7 files changed** (+217 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/brewing.rs` (+16 -6) 📝 `crates/horizon-client/src/game/stations.rs` (+10 -0) 📝 `crates/horizon-client/src/item_sync.rs` (+40 -1) 📝 `crates/horizon-client/src/item_tooltip.rs` (+112 -4) 📝 `crates/horizon-client/src/lan/guest.rs` (+15 -0) 📝 `crates/horizon-protocol/examples/item_wire_probe.rs` (+7 -3) 📝 `crates/horizon-protocol/src/item.rs` (+17 -1) </details> ### 📄 Description > 🤖 Opened by degepie's AI agent (Claude Code), not by degepie personally. Fixes #3137. ## What A suspicious stew taken from the creative inventory gave no effect when eaten, and its tooltip in the creative grid listed no effects. Cause: `horizon-protocol` read the `minecraft:suspicious_stew_effects` component (id 55) past as raw bytes, `item_sync::from_network` drops raw components, and `lan::guest::stack_to_network` never encoded `stew_effects`. On the default server-thread path, the creative client's `SetCreativeModeSlot` therefore handed the server a bare stew, and the server's `finish_consuming` (already a port of `SuspiciousStewEffects.onConsume`) had nothing to apply. Stews from `/give` or crafting were not affected, since those stay on the server. The creative tooltip line itself was never ported. ## Vanilla - `SuspiciousStewEffects.onConsume`: `user.addEffect(entry.createEffectInstance())` for each entry (already ported, unchanged) - `SuspiciousStewEffects$Entry.STREAM_CODEC`: `MobEffect.STREAM_CODEC` (`ByteBufCodecs.holderRegistry(MOB_EFFECT)`, the plain registry id), then `VAR_INT` duration, as a list - `SuspiciousStewEffects.addToTooltip`: only when `flag.isCreative()`, `PotionContents.addPotionTooltip(effects, …, 1.0f, tickRate)` - `PotionContents.addPotionTooltip`: one line per effect (duration only if it doesn't end within 20 ticks), coloured by `MobEffectCategory.getTooltipFormatting()` (harmful RED, beneficial and neutral BLUE), "No Effects" when there are none, then the "When Applied:" modifier block - `ItemStack.addDetailsToTooltip`: `SUSPICIOUS_STEW_EFFECTS` comes after `UNBREAKABLE` and before `BLOCK_STATE` - `CreativeModeInventoryScreen.getTooltipFromContainerItem`: `asCreative()` for the screen's own creative slots - `CreativeModeTabs.generateSuspiciousStews` and `items.json`: the stew's default component is an empty list, so a plain stew in the grid shows "No Effects" ## How - `horizon-protocol/src/item.rs`: new `component::SUSPICIOUS_STEW_EFFECTS` and a typed `Component::StewEffects(Vec<(effect id, duration)>)` that is read and written byte for byte. The item_wire probe keeps this component under its byte-equality check, as it does for trims. - `item_sync.rs`: from the wire into the `[{id, duration}]` NBT that `item_data` reads. Effect names come from the built-in `minecraft:mob_effect` registry. - `lan/guest.rs::network_stack`: encodes `stew_effects`. This fixes both directions: the client's `SetCreativeModeSlot`, and a hub sending to its clients. - `brewing::effect_lines` and `item_tooltip::effect_modifier_lines`: factored out of the potion tooltip so the potion and stew paths share them. Potion output is unchanged. - `item_tooltip::stew_lines`: called from `stack_tooltip_lines` at vanilla's position. The creative flag uses the same approximation the name line already uses (`self.screen == Screen::Creative`), so it also applies to the creative screen's hotbar row, where vanilla uses its normal flag. ## Verified - In game (default server-thread path, scratch home, creative world): took the Fire Resistance stew from the creative search tab, moved it to the hotbar and ate it. - Before (released v0.2.91): `effects: []`. - After (this branch): `fire_resistance` active (47 ticks left when queried). - Before the fix I also confirmed that `/give` and survival-crafted stews already applied their effects (night vision; fire resistance), which narrowed the cause to the creative path. - Tooltip, hovering over the grid stew: - Before: only "Suspicious Stew". - After: "Weakness (0:07)" in red, an empty line, "When Applied:", then "-4 Attack Damage". - Unit tests: - `item::tests::components_read_past_keep_their_bytes`: component 55 now decodes to `StewEffects([(15,100),(18,160)])` and still re-encodes to the same bytes. - `item_sync::a_creative_stack_keeps_its_components_across_the_wire`: a stew round-trips with its effects. - New `item_tooltip::stew_effects_show_only_with_the_creative_flag`. - Harness: `python3 tools/parity.py item_wire` passes (374 stacks, all 122 component types). Not done here: Horizon's `brewing::format_duration` prints `0:07` where vanilla's `StringUtil.formatTickDuration` prints `00:07`. Potions have the same mismatch already, so it belongs in a separate fix. **pr_ready** (`tools/pr_ready.py --quick` on b550, against origin/main at abd1755f9, 10 min 49 s) | Check | Result | | --- | --- | | Scope | ✅ 7 files, +218 −15 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 405 passed (36 s) | | rustfmt | ✅ (6 s) | | clippy | ✅ (4 min 39 s) | | tests: horizon-client, horizon-protocol | ✅ 1383 passed (4 min 49 s) | | doc tests | ✅ 0 passed (32 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 348 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 336 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | **Note:** this touches the same spots in `horizon-protocol/src/item.rs` and `examples/item_wire_probe.rs` as #3380 (goat horn instrument), since both add a component next to `Trim`. Whichever lands second needs a trivial rebase. I'll do it on this branch if #3380 goes first. 🤖 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:11 +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#4959
No description provided.