[PR #2103] [MERGED] Merchant offers: preserve required potion components #4005

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

📋 Pull Request Information

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

Base: main ← Head: fix/1948-merchant-cost-components


📝 Commits (4)

  • d25d0f0 Merchant offers: preserve required potion components
  • db5c10b Merchant offers: rustfmt
  • ddbf2ce Trading probe: compare generated offers only
  • 96afc48 Merge main into fix/1948-merchant-cost-components

📊 Changes

5 files changed (+170 additions, -22 deletions)

View changed files

📝 crates/horizon-client/src/game/lan_trading.rs (+8 -7)
📝 crates/horizon-client/src/game/remote.rs (+8 -4)
📝 crates/horizon-client/src/item_sync.rs (+79 -0)
📝 crates/horizon-protocol/src/item.rs (+2 -2)
📝 crates/horizon-protocol/src/packets/play.rs (+73 -9)

📄 Description

🤖 Opened by rdbt's AI agent (OpenAI Codex, GPT-6.1 Sol), not by rdbt personally.

What and why

Fixes #1948. Merchant offer costs now preserve their required components across the server-thread/LAN packet boundary, so the wandering trader asks clients for a Water Bottle rather than an Uncraftable Potion. Both payment slots use the existing item-component conversion; ordinary offers retain their empty predicates. Authoritative payment matching is unchanged.

Vanilla reference

Inspected the pinned 26.3 server jar with javap -c -p: ItemCost.STREAM_CODEC, DataComponentExactPredicate.STREAM_CODEC, TypedDataComponent$1 and MerchantOffers.STREAM_CODEC. Exact predicates are lists of typed components, without the removal count used by an item-stack patch. The vanilla villager_trade/wandering_trader/water_bottle_emerald.json requires minecraft:potion_contents.potion = minecraft:water.

Regression coverage checks the exact wire layout and truncation handling, preserves water-potion data across the offer packet, compares water/other-potion/bare-potion matching with authoritative costs, and keeps an ordinary emerald cost usable. The existing trading parity fixture now round-trips generated offer costs through the network codec.

Validation

  • cargo test -p horizon-protocol merchant_cost_predicate --lib: passed (1 test).
  • cargo test -p horizon-client merchant_water_cost --lib: passed (1 test; corrected the test's initial unqualified potion identifier to match vanilla data).
  • git diff --check: passed.
  • python3 tools/pr_ready.py --quick --base origin/main: exit 143 (terminated) during crate tests. Public tree, rustfmt and Clippy passed; the broader crate tests and doc tests did not complete. No failing test output was reported before termination.

Parity runs are deferred to CI as requested. No manual game launch or screenshot was performed; live server-thread/LAN gameplay validation is not claimed.

Self-check

The process was terminated before it printed its final self-check block. This is its complete captured output; this PR does not claim a passing quick self-check:

pr_ready: 6 files changed since origin/main; checks on local
  Public tree...
  Public tree: pass (1 s)
  rustfmt...
  rustfmt: pass (9 s)
  clippy...
  clippy: pass (3 min 4 s)
  tests: horizon-client, horizon-protocol...

🤖 Generated with OpenAI Codex.


🔄 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/2103 **Author:** [@rdbtCVS](https://github.com/rdbtCVS) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/1948-merchant-cost-components` --- ### 📝 Commits (4) - [`d25d0f0`](https://github.com/horizon-rust/horizon/commit/d25d0f025bee024cb52ecef433ca6c3a2f0c960d) Merchant offers: preserve required potion components - [`db5c10b`](https://github.com/horizon-rust/horizon/commit/db5c10ba20c2a129dbd47855f50867ff09855da2) Merchant offers: rustfmt - [`ddbf2ce`](https://github.com/horizon-rust/horizon/commit/ddbf2ce21181d7b4dc40db0f08e42c3eaed3ec3f) Trading probe: compare generated offers only - [`96afc48`](https://github.com/horizon-rust/horizon/commit/96afc48ce21740237cec2df11d7de15304a14c10) Merge main into fix/1948-merchant-cost-components ### 📊 Changes **5 files changed** (+170 additions, -22 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/lan_trading.rs` (+8 -7) 📝 `crates/horizon-client/src/game/remote.rs` (+8 -4) 📝 `crates/horizon-client/src/item_sync.rs` (+79 -0) 📝 `crates/horizon-protocol/src/item.rs` (+2 -2) 📝 `crates/horizon-protocol/src/packets/play.rs` (+73 -9) </details> ### 📄 Description > 🤖 Opened by rdbt's AI agent (OpenAI Codex, GPT-6.1 Sol), not by rdbt personally. ## What and why Fixes #1948. Merchant offer costs now preserve their required components across the server-thread/LAN packet boundary, so the wandering trader asks clients for a Water Bottle rather than an Uncraftable Potion. Both payment slots use the existing item-component conversion; ordinary offers retain their empty predicates. Authoritative payment matching is unchanged. ## Vanilla reference Inspected the pinned 26.3 server jar with `javap -c -p`: `ItemCost.STREAM_CODEC`, `DataComponentExactPredicate.STREAM_CODEC`, `TypedDataComponent$1` and `MerchantOffers.STREAM_CODEC`. Exact predicates are lists of typed components, without the removal count used by an item-stack patch. The vanilla `villager_trade/wandering_trader/water_bottle_emerald.json` requires `minecraft:potion_contents.potion = minecraft:water`. Regression coverage checks the exact wire layout and truncation handling, preserves water-potion data across the offer packet, compares water/other-potion/bare-potion matching with authoritative costs, and keeps an ordinary emerald cost usable. The existing trading parity fixture now round-trips generated offer costs through the network codec. ## Validation - `cargo test -p horizon-protocol merchant_cost_predicate --lib`: passed (1 test). - `cargo test -p horizon-client merchant_water_cost --lib`: passed (1 test; corrected the test's initial unqualified potion identifier to match vanilla data). - `git diff --check`: passed. - `python3 tools/pr_ready.py --quick --base origin/main`: **exit 143 (terminated)** during crate tests. Public tree, rustfmt and Clippy passed; the broader crate tests and doc tests did not complete. No failing test output was reported before termination. Parity runs are deferred to CI as requested. No manual game launch or screenshot was performed; live server-thread/LAN gameplay validation is not claimed. ## Self-check The process was terminated before it printed its final self-check block. This is its complete captured output; this PR does **not** claim a passing quick self-check: ```text pr_ready: 6 files changed since origin/main; checks on local Public tree... Public tree: pass (1 s) rustfmt... rustfmt: pass (9 s) clippy... clippy: pass (3 min 4 s) tests: horizon-client, horizon-protocol... ``` 🤖 Generated with [OpenAI Codex](https://openai.com/codex/). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:13:58 +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#4005
No description provided.