[PR #1739] [MERGED] Trading: keep Hero of the Village discounts for server players #3731

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

📋 Pull Request Information

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

Base: main ← Head: t3/fix-hero-trading-discount


📝 Commits (2)

  • 489b5a4 Trading: keep Hero discounts for server players
  • ebf76f4 Merge main into t3/fix-hero-trading-discount: keep both sides' appended checks

📊 Changes

2 files changed (+74 additions, -3 deletions)

View changed files

📝 crates/horizon-client/src/game/lan_trading.rs (+2 -3)
📝 tools/lan_e2e.py (+72 -0)

📄 Description

🤖 Opened by rdbt's AI agent (OpenCode, gpt-6.1-sol), not by rdbt personally.

What and why

Preserve the Hero of the Village effect already captured by the merchant session. interact_trader computes it while as_guest has the guest's effects swapped in; lan_open_merchant then discarded it by assigning None before recalculating prices.

Remove that assignment and update the stale comment. Hero discounts now survive the merchant handoff for server-thread single player and network guests.

Extend tools/lan_e2e.py with hero-trading: both players complete a fixed 20-wheat-for-one-emerald offer with no effect, Hero I, Hero III, and after clearing Hero. It checks the saved offer's special price and authoritative inventory deductions, and captures the trading screen. The other player keeps Hero V to catch effects leaking between players.

Fixes #1365.

Vanilla reference

net.minecraft.world.entity.npc.villager.Villager.updateSpecialPrices(Player), inspected from the pinned 26.3 server bytecode with tools/rea_vanilla.py.

Vanilla uses 0.3F + 0.0625F * amplifier, floors the reduction against the base cost, and reduces by at least one item. The fixed 20-wheat offer therefore costs 14 with Hero I and 12 with Hero III.

Regression validation

  • Before the fix, the new threaded check fails with Hero I still active: price 20, 0 wheat left, one emerald received.
  • After the fix, 16 completed-trade cases pass: both players, server-thread and in-frame modes; Hero I leaves six wheat, Hero III leaves eight, ordinary and cleared-effect trades consume 20.
  • tools/test_trading_parity.py: 5,364 cases / 28,358 output lines match vanilla, including 1,000 pricing and 1,500 trading cases.
python3 tools/lan_e2e.py --check hero-trading
python3 tools/lan_e2e.py --server-thread --check hero-trading
python3 tools/test_trading_parity.py

The LAN checks ran under Xvfb with a temporary game_env adapter because this machine has no vscreen. Game, launcher, and XDG homes were fresh scratch directories. The self-check used an isolated Cargo target, a workspace-local TMPDIR, and a checkout-local prepared-resource view completed from the existing 26.3 data-generator reports.

Self-check

pr_ready (tools/pr_ready.py --quick on archlinux, against origin/main at f2f58aca9, 3 min 52 s)

Check Result
Scope ✅ 2 files, +74 −3
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 252 passed (21 s)
rustfmt ✅ (7 s)
clippy ✅
tests: horizon-client ✅ 1201 passed (3 min 3 s)
doc tests ✅ 0 passed (7 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 95 affected, to run in CI (--quick): arrow, block_removal, command_exec, composter, crafter, dedicated_server, dispenser, locator_bar, mace, online_mode, replace_blobs, resource_pack and 83 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Screenshots

Local screenshot artifacts from the regression runs:

  • .local/hero-trading-before/host-hero-trading-hero-i.png: Hero I incorrectly displays 20 wheat.
  • .local/hero-trading-threaded/host-hero-trading-hero-i.png: the base 20 is struck through and the discounted cost is 14.
  • .local/hero-trading-threaded/guest-hero-trading-hero-i.png: the network guest also displays 14.

The check captures the ordinary, Hero I, Hero III, and cleared-effect screens for each player in its output directory.

🤖 Generated with OpenCode (gpt-6.1-sol).


🔄 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/1739 **Author:** [@rdbtCVS](https://github.com/rdbtCVS) **Created:** 10/25/2026 **Status:** ✅ Merged **Merged:** 10/25/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `t3/fix-hero-trading-discount` --- ### 📝 Commits (2) - [`489b5a4`](https://github.com/horizon-rust/horizon/commit/489b5a4ffa038341dccc66c8d2bfa27994007068) Trading: keep Hero discounts for server players - [`ebf76f4`](https://github.com/horizon-rust/horizon/commit/ebf76f4c03de88cc8e816bb755febd47f852e47f) Merge main into t3/fix-hero-trading-discount: keep both sides' appended checks ### 📊 Changes **2 files changed** (+74 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/lan_trading.rs` (+2 -3) 📝 `tools/lan_e2e.py` (+72 -0) </details> ### 📄 Description > 🤖 Opened by rdbt's AI agent (OpenCode, gpt-6.1-sol), not by rdbt personally. ## What and why Preserve the Hero of the Village effect already captured by the merchant session. `interact_trader` computes it while `as_guest` has the guest's effects swapped in; `lan_open_merchant` then discarded it by assigning `None` before recalculating prices. Remove that assignment and update the stale comment. Hero discounts now survive the merchant handoff for server-thread single player and network guests. Extend `tools/lan_e2e.py` with `hero-trading`: both players complete a fixed 20-wheat-for-one-emerald offer with no effect, Hero I, Hero III, and after clearing Hero. It checks the saved offer's special price and authoritative inventory deductions, and captures the trading screen. The other player keeps Hero V to catch effects leaking between players. Fixes #1365. ## Vanilla reference `net.minecraft.world.entity.npc.villager.Villager.updateSpecialPrices(Player)`, inspected from the pinned 26.3 server bytecode with `tools/rea_vanilla.py`. Vanilla uses `0.3F + 0.0625F * amplifier`, floors the reduction against the base cost, and reduces by at least one item. The fixed 20-wheat offer therefore costs 14 with Hero I and 12 with Hero III. ## Regression validation - Before the fix, the new threaded check fails with Hero I still active: price **20**, **0 wheat left**, one emerald received. - After the fix, **16 completed-trade cases pass**: both players, server-thread and in-frame modes; Hero I leaves six wheat, Hero III leaves eight, ordinary and cleared-effect trades consume 20. - `tools/test_trading_parity.py`: **5,364 cases / 28,358 output lines match vanilla**, including 1,000 pricing and 1,500 trading cases. ```sh python3 tools/lan_e2e.py --check hero-trading python3 tools/lan_e2e.py --server-thread --check hero-trading python3 tools/test_trading_parity.py ``` The LAN checks ran under Xvfb with a temporary `game_env` adapter because this machine has no `vscreen`. Game, launcher, and XDG homes were fresh scratch directories. The self-check used an isolated Cargo target, a workspace-local `TMPDIR`, and a checkout-local prepared-resource view completed from the existing 26.3 data-generator reports. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on archlinux, against origin/main at f2f58aca9, 3 min 52 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +74 −3 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 252 passed (21 s) | | rustfmt | ✅ (7 s) | | clippy | ✅ | | tests: horizon-client | ✅ 1201 passed (3 min 3 s) | | doc tests | ✅ 0 passed (7 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 95 affected, to run in CI (--quick): arrow, block_removal, command_exec, composter, crafter, dedicated_server, dispenser, locator_bar, mace, online_mode, replace_blobs, resource_pack and 83 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | ## Screenshots Local screenshot artifacts from the regression runs: - `.local/hero-trading-before/host-hero-trading-hero-i.png`: Hero I incorrectly displays 20 wheat. - `.local/hero-trading-threaded/host-hero-trading-hero-i.png`: the base 20 is struck through and the discounted cost is 14. - `.local/hero-trading-threaded/guest-hero-trading-hero-i.png`: the network guest also displays 14. The check captures the ordinary, Hero I, Hero III, and cleared-effect screens for each player in its output directory. 🤖 Generated with [OpenCode](https://opencode.ai) (gpt-6.1-sol). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:11:50 +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#3731
No description provided.