[PR #1796] [MERGED] Potions keep their potion across the connection #3766

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

📋 Pull Request Information

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

Base: main ← Head: fix/potion-contents-over-network


📝 Commits (1)

  • 9e21868 Potions keep their potion across the connection

📊 Changes

5 files changed (+158 additions, -5 deletions)

View changed files

📝 crates/horizon-client/src/game/lan_actions.rs (+7 -0)
📝 crates/horizon-client/src/game/remote.rs (+24 -0)
📝 crates/horizon-client/src/lan/guest.rs (+34 -0)
📝 crates/horizon-protocol/src/item.rs (+90 -0)
📝 crates/horizon-protocol/src/item/skip.rs (+3 -5)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

What the player reported

.dezerx on Discord (#horizon-bugs, 2026-10-25, single player on v0.2.5x): potions have the wrong texture/colour, a splash potion is named "Splash Uncraftable Potion", and potions "don't work".

Cause

On a server's client (single player on the server thread since #1514, LAN guests, a dedicated server's players) item stacks lost minecraft:potion_contents both ways:

  • the server's network_stack (lan/guest.rs) never wrote it, and the client read past it (Component::Raw), so every potion was the empty PotionContents: the name falls back to item.minecraft.<item>.effect.empty ("Uncraftable Potion") and the water colour;
  • a potion taken from the creative menu went to the server as SetCreativeModeSlot with only its damage (to_network), and the server's item_from_network read only enchantments, so the creative potion splashed as water.

Reproduced on main (server thread): /give @s splash_potion[potion_contents={potion:"minecraft:swiftness"}] showed "Splash Uncraftable Potion" in the water colour.

Vanilla rule

PotionContents.STREAM_CODEC: optional Potion.STREAM_CODEC (holderRegistry(POTION), the registry id), optional INT custom colour, list of MobEffectInstance custom effects, optional STRING custom name.

Change

  • horizon-protocol: Component::Potion { potion, color, rest } for POTION_CONTENTS (53). The custom effects and name, which Horizon doesn't model, stay as their bytes, so a stack from a vanilla server round-trips exactly. The old read-past path for 53 is gone (one reader).
  • Server → client: network_stack writes the potion by its minecraft:potion id.
  • Client: the item's components get {potion, custom_color}; a creative pick sends its potion.
  • Server ← client: item_from_network keeps the potion.
    Fireworks over the wire are left to #1671 (socksprox); the hunks don't touch the same lines.

Tested

  • Server thread, after the fix: /given splash potion of Swiftness reads "Splash Potion of Swiftness" in light blue, a tipped arrow of Poison is green-tipped; a Splash Potion of Swiftness (long) picked from the creative Food & Drinks tab reaches the server with potion_contents: {potion: "minecraft:long_swiftness"} (/data get entity @s Inventory) and thrown at the feet gives Speed for 7108 ticks (9600 × 0.75, minus the flight).
  • --in-frame doesn't use the wire: unchanged. LAN guests and dedicated servers use the same network_stack / item_from_network.
  • Unit tests: potion_contents_round_trip (protocol, with custom colour/effect/name bytes), potions_go_as_potion_registry_ids (server encoding).
  • Harnesses: item_wire, creative, use_item_on (below).

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at d2c96af14, 8 min 54 s)

Check Result
Scope ✅ 5 files, +158 −5
Cargo.lock ✅ unchanged
Public tree ✅ (1 s)
Python tests ➖ no Python change
rustfmt ✅ (11 s)
clippy ✅ (1 min 16 s)
tests: horizon-client, horizon-protocol ✅ 1308 passed (6 min 57 s)
doc tests ✅ 0 passed (4 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 109 affected, to run in CI (--quick): ambient_sound, arrow, audio_attributes, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, block_transformer, breaking_model, camera and 97 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Named harnesses (local): item_wire PASS, creative PASS, use_item_on PASS.

Not fixed here (same report, other PRs/issues): lingering clouds #1361, fireworks #1478/#1663/#1671.

🤖 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/1796 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/25/2026 **Status:** ✅ Merged **Merged:** 10/25/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/potion-contents-over-network` --- ### 📝 Commits (1) - [`9e21868`](https://github.com/horizon-rust/horizon/commit/9e21868dfa012b3a46d3242d03e56845fb6fb5c5) Potions keep their potion across the connection ### 📊 Changes **5 files changed** (+158 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/lan_actions.rs` (+7 -0) 📝 `crates/horizon-client/src/game/remote.rs` (+24 -0) 📝 `crates/horizon-client/src/lan/guest.rs` (+34 -0) 📝 `crates/horizon-protocol/src/item.rs` (+90 -0) 📝 `crates/horizon-protocol/src/item/skip.rs` (+3 -5) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What the player reported .dezerx on Discord (#horizon-bugs, 2026-10-25, single player on v0.2.5x): potions have the wrong texture/colour, a splash potion is named "Splash Uncraftable Potion", and potions "don't work". ## Cause On a server's client (single player on the server thread since #1514, LAN guests, a dedicated server's players) item stacks lost `minecraft:potion_contents` both ways: - the server's `network_stack` (lan/guest.rs) never wrote it, and the client read past it (`Component::Raw`), so every potion was the empty `PotionContents`: the name falls back to `item.minecraft.<item>.effect.empty` ("Uncraftable Potion") and the water colour; - a potion taken from the creative menu went to the server as `SetCreativeModeSlot` with only its damage (`to_network`), and the server's `item_from_network` read only enchantments, so the creative potion splashed as water. Reproduced on main (server thread): `/give @s splash_potion[potion_contents={potion:"minecraft:swiftness"}]` showed "Splash Uncraftable Potion" in the water colour. ## Vanilla rule `PotionContents.STREAM_CODEC`: optional `Potion.STREAM_CODEC` (`holderRegistry(POTION)`, the registry id), optional INT custom colour, list of `MobEffectInstance` custom effects, optional STRING custom name. ## Change - `horizon-protocol`: `Component::Potion { potion, color, rest }` for `POTION_CONTENTS` (53). The custom effects and name, which Horizon doesn't model, stay as their bytes, so a stack from a vanilla server round-trips exactly. The old read-past path for 53 is gone (one reader). - Server → client: `network_stack` writes the potion by its `minecraft:potion` id. - Client: the item's components get `{potion, custom_color}`; a creative pick sends its potion. - Server ← client: `item_from_network` keeps the potion. Fireworks over the wire are left to #1671 (socksprox); the hunks don't touch the same lines. ## Tested - Server thread, after the fix: `/give`n splash potion of Swiftness reads "Splash Potion of Swiftness" in light blue, a tipped arrow of Poison is green-tipped; a Splash Potion of Swiftness (long) picked from the creative Food & Drinks tab reaches the server with `potion_contents: {potion: "minecraft:long_swiftness"}` (`/data get entity @s Inventory`) and thrown at the feet gives Speed for 7108 ticks (9600 × 0.75, minus the flight). - `--in-frame` doesn't use the wire: unchanged. LAN guests and dedicated servers use the same `network_stack` / `item_from_network`. - Unit tests: `potion_contents_round_trip` (protocol, with custom colour/effect/name bytes), `potions_go_as_potion_registry_ids` (server encoding). - Harnesses: item_wire, creative, use_item_on (below). **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at d2c96af14, 8 min 54 s) | Check | Result | | --- | --- | | Scope | ✅ 5 files, +158 −5 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ (1 s) | | Python tests | ➖ no Python change | | rustfmt | ✅ (11 s) | | clippy | ✅ (1 min 16 s) | | tests: horizon-client, horizon-protocol | ✅ 1308 passed (6 min 57 s) | | doc tests | ✅ 0 passed (4 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 109 affected, to run in CI (--quick): ambient_sound, arrow, audio_attributes, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, block_transformer, breaking_model, camera and 97 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | Named harnesses (local): item_wire PASS, creative PASS, use_item_on PASS. Not fixed here (same report, other PRs/issues): lingering clouds #1361, fireworks #1478/#1663/#1671. 🤖 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 04:12:10 +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#3766
No description provided.