[PR #2009] [MERGED] A villager's new profession rolls its trades #3934

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

📋 Pull Request Information

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

Base: main ← Head: fix/villager-new-profession-trades


📝 Commits (1)

  • 9572330 A villager's new profession rolls its trades

📊 Changes

1 file changed (+67 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/mobs/villager.rs (+67 -1)

📄 Description

🤖 Opened by vlesmentie's AI agent (Claude Code, Claude Opus 5.5), not by vlesmentie themselves.

What and why

Fixes #1998.

A villager that lost its workstation and then took one the player placed wore the new profession's clothes but
had no trades: right-clicking it only made it shake its head.

villager::set_profession follows Villager.setVillagerData, where a different profession sets offers = null
so that the next getOffers rolls the new profession's trades (AbstractVillager.getOffers →
updateTrades). Horizon models vanilla's null with Trader::unset ("The offers are not made yet … generated when
first asked for"), and Game::ensure_offers (game/trading.rs) only rolls offers when unset is true. But
set_profession cleared the offers and left unset false, so they stayed empty for good. It now sets unset too.
A villager that keeps its profession keeps its offers, as before.

Vanilla reference

  • Villager.setVillagerData: if the profession differs (!old.profession().equals(new.profession())),
    this.offers = null
  • AbstractVillager.getOffers: offers == null → new MerchantOffers and updateTrades

Checked against the 26.3 client jar's bytecode (javap).

New test mobs::villager::tests::a_new_profession_rolls_new_offers: the same profession keeps the offers made;
a new profession empties them and marks them unset. It fails without the change.

Self-check

pr_ready (tools/pr_ready.py on debian, against origin/main at 666a1ba6f, 4 min 23 s)

Check Result
Scope ✅ 1 files, +67 −1
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ➖ no Python change
rustfmt ✅ (16 s)
clippy ✅ (1 min 12 s)
tests: horizon-client ✅ 1269 passed (2 min 50 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 ➖ not run (no vanilla data here): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Not checked in game.

🤖 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/2009 **Author:** [@vlesmentie](https://github.com/vlesmentie) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/villager-new-profession-trades` --- ### 📝 Commits (1) - [`9572330`](https://github.com/horizon-rust/horizon/commit/9572330ee4402a5cc68af36e59505a009fdfbfed) A villager's new profession rolls its trades ### 📊 Changes **1 file changed** (+67 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/mobs/villager.rs` (+67 -1) </details> ### 📄 Description > 🤖 Opened by vlesmentie's AI agent (Claude Code, Claude Opus 5.5), not by vlesmentie themselves. ## What and why Fixes #1998. A villager that lost its workstation and then took one the player placed wore the new profession's clothes but had no trades: right-clicking it only made it shake its head. `villager::set_profession` follows `Villager.setVillagerData`, where a different profession sets `offers = null` so that the next `getOffers` rolls the new profession's trades (`AbstractVillager.getOffers` → `updateTrades`). Horizon models vanilla's null with `Trader::unset` ("The offers are not made yet … generated when first asked for"), and `Game::ensure_offers` (`game/trading.rs`) only rolls offers when `unset` is true. But `set_profession` cleared the offers and left `unset` false, so they stayed empty for good. It now sets `unset` too. A villager that keeps its profession keeps its offers, as before. ## Vanilla reference - `Villager.setVillagerData`: if the profession differs (`!old.profession().equals(new.profession())`), `this.offers = null` - `AbstractVillager.getOffers`: `offers == null` → new `MerchantOffers` and `updateTrades` Checked against the 26.3 client jar's bytecode (`javap`). New test `mobs::villager::tests::a_new_profession_rolls_new_offers`: the same profession keeps the offers made; a new profession empties them and marks them unset. It fails without the change. ## Self-check **pr_ready** (`tools/pr_ready.py` on debian, against origin/main at 666a1ba6f, 4 min 23 s) | Check | Result | | --- | --- | | Scope | ✅ 1 files, +67 −1 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ➖ no Python change | | rustfmt | ✅ (16 s) | | clippy | ✅ (1 min 12 s) | | tests: horizon-client | ✅ 1269 passed (2 min 50 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 | ➖ not run (no vanilla data here): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | Not checked in game. 🤖 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:13:22 +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#3934
No description provided.