[PR #3716] [MERGED] Villagers: the trade screen closes when the trader is gone or out of reach #5166

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3716
Author: @xFedeT
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @levzzz5154

Base: main ← Head: fix/merchant-closes-out-of-range


📝 Commits (3)

  • 94eff29 Villagers: the trade screen closes when the trader is gone or out of reach
  • dacde01 lan_e2e: merchant-close check for the trade screen closing out of reach
  • 4289f22 Merge main into fix/merchant-closes-out-of-range (resolve tools/lan_e2e.py)

📊 Changes

4 files changed (+148 additions, -13 deletions)

View changed files

📝 crates/horizon-client/src/game/lan_actions.rs (+19 -12)
📝 crates/horizon-client/src/game/lan_trading.rs (+31 -1)
📝 crates/horizon-client/src/game/trading.rs (+28 -0)
📝 tools/lan_e2e.py (+70 -0)

📄 Description

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

Refs #3521.

Ticks the AbstractVillager.stillValid row of #3521 (checked: no open PR touches it, and #3521 has no comment about it).

What and why

In vanilla a trade screen stays open only while AbstractVillager.stillValid holds: the trader is the player's trading partner, alive, and player.isWithinEntityInteractionRange(trader, 4.0) (the entity interaction range, 3 or 5 in creative, plus 4, measured from the eyes to the trader's box). Horizon never checked, so the screen stayed open after walking away or when the villager died.

Change

  • game/lan_trading.rs lan_merchant_tick: closes a guest's trade screen (the container close packet, the payment and carried stack go back as on a normal close) when the trader is gone or dead, or out of range. The default single-player path on the server thread uses this code, as do LAN guests and dedicated servers.
  • game/lan_actions.rs: guest_within_entity_range, shared with chest_vehicle_still_valid (which had the same box test inline).
  • game/trading.rs merchant_tick: the same check for the in-frame path's own trade screen.

Vanilla reference

AbstractVillager.stillValid, Player.isWithinEntityInteractionRange, MerchantMenu.stillValid.

Testing

With horizon-ctl on a scratch home, a farmer (NoAI) two blocks away, interact-entity, then tp:

  • server thread (default): screen station after the interaction, still station after tp ~ ~ ~3, back to playing after tp ~ ~ ~30.
  • --in-frame: the same.

python3 tools/parity.py trading: pass. clippy -D warnings: pass. No range check in the existing harnesses, so none was added; pr_ready results follow in a comment.

🤖 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/3716 **Author:** [@xFedeT](https://github.com/xFedeT) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix/merchant-closes-out-of-range` --- ### 📝 Commits (3) - [`94eff29`](https://github.com/horizon-rust/horizon/commit/94eff29428ba739e787adce4a6b84d6268fc6249) Villagers: the trade screen closes when the trader is gone or out of reach - [`dacde01`](https://github.com/horizon-rust/horizon/commit/dacde01da28e4ea3b57b2932a9a81f37667a593e) lan_e2e: merchant-close check for the trade screen closing out of reach - [`4289f22`](https://github.com/horizon-rust/horizon/commit/4289f22f00c5df9d416ae27c7003de3ed783cea9) Merge main into fix/merchant-closes-out-of-range (resolve tools/lan_e2e.py) ### 📊 Changes **4 files changed** (+148 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/lan_actions.rs` (+19 -12) 📝 `crates/horizon-client/src/game/lan_trading.rs` (+31 -1) 📝 `crates/horizon-client/src/game/trading.rs` (+28 -0) 📝 `tools/lan_e2e.py` (+70 -0) </details> ### 📄 Description > 🤖 Opened by Federico's AI agent (Claude), not by Federico himself. Refs #3521. Ticks the `AbstractVillager.stillValid` row of #3521 (checked: no open PR touches it, and #3521 has no comment about it). ## What and why In vanilla a trade screen stays open only while `AbstractVillager.stillValid` holds: the trader is the player's trading partner, alive, and `player.isWithinEntityInteractionRange(trader, 4.0)` (the entity interaction range, 3 or 5 in creative, plus 4, measured from the eyes to the trader's box). Horizon never checked, so the screen stayed open after walking away or when the villager died. ## Change - `game/lan_trading.rs` `lan_merchant_tick`: closes a guest's trade screen (the container close packet, the payment and carried stack go back as on a normal close) when the trader is gone or dead, or out of range. The default single-player path on the server thread uses this code, as do LAN guests and dedicated servers. - `game/lan_actions.rs`: `guest_within_entity_range`, shared with `chest_vehicle_still_valid` (which had the same box test inline). - `game/trading.rs` `merchant_tick`: the same check for the in-frame path's own trade screen. ## Vanilla reference `AbstractVillager.stillValid`, `Player.isWithinEntityInteractionRange`, `MerchantMenu.stillValid`. ## Testing With `horizon-ctl` on a scratch home, a farmer (NoAI) two blocks away, `interact-entity`, then `tp`: - server thread (default): screen `station` after the interaction, still `station` after `tp ~ ~ ~3`, back to `playing` after `tp ~ ~ ~30`. - `--in-frame`: the same. `python3 tools/parity.py trading`: pass. clippy `-D warnings`: pass. No range check in the existing harnesses, so none was added; `pr_ready` results follow in a comment. 🤖 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:10:42 +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#5166
No description provided.