[GH-ISSUE #1639] villagers will become untradeable after destroying their first work bench #506

Closed
opened 2026-11-02 15:39:36 +07:00 by bsakaguchi · 5 comments
Owner

Originally created by @ludovic111 on GitHub (Oct 24, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/1639

what i did: spawned in a villager, gave it a job, broke their workbench, gave it another job
what happened: the villager did not open up a menu for trading
what i expected: the villager should take the new job and show the trades
horizon version: v0.2.48
os, cpu, gpu: arch linux kernel 7.2.3-arch1-3, ryzen 5 5600gt, rx vega 56
video: https://files.kookii.dev/api/public/dl/qXfHcCQu?inline=true (it might take a little while to load but it should load)

Reported on Discord by kookii 🐣 in #horizon-bugs · Discord thread
Tags: gameplay

Opened by Kira from Discord. Replies from the reporter in the thread are added here as comments.

Originally created by @ludovic111 on GitHub (Oct 24, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/1639 > what i did: spawned in a villager, gave it a job, broke their workbench, gave it another job > what happened: the villager did not open up a menu for trading > what i expected: the villager should take the new job and show the trades > horizon version: v0.2.48 > os, cpu, gpu: arch linux kernel 7.2.3-arch1-3, ryzen 5 5600gt, rx vega 56 > video: https://files.kookii.dev/api/public/dl/qXfHcCQu?inline=true (it might take a little while to load but it should load) Reported on Discord by **kookii 🐣** in #horizon-bugs · [Discord thread](https://discord.com/channels/1559227979002028052/1563671631874760905) Tags: gameplay <sub>Opened by Kira from Discord. Replies from the reporter in the thread are added here as comments.</sub><!-- kira -->
bsakaguchi 2026-11-02 15:39:36 +07:00
Author
Owner

@Domanffe commented on GitHub (Oct 24, 2026):

🤖 Agent: tried to reproduce on a build of main today and the villager never takes the job in the first place, which may be the layer under this report.

Setup: flat air pocket, setblock 2 64 0 minecraft:composter, /summon minecraft:villager 0 64 0 {VillagerData:{profession:"minecraft:none",level:0,type:"minecraft:plains"}}, then 100 ticks. data get entity @e[type=minecraft:villager,limit=1] VillagerData.profession answers "minecraft:none". Breaking the composter and placing a lectern at -2 64 0, then 140 more ticks: still "minecraft:none".

So a summoned villager with a free job site next to it does not acquire a profession here, and horizon-ctl entities 24 villager does not list it either. Two things worth separating before anyone patches the "untradeable after the first workbench" half:

  • whether profession acquisition needs the POI to be inside a village (bed/workstation registration through the village manager) rather than a bare block beside a summoned villager, and
  • whether the trade menu opens at all for a villager that has a profession, which is the part the reporter saw.

I did not get past the first step, so this is a starting point rather than a repro: whoever has a village world should check the same two data get reads there.

<!-- gh-comment-id:6390722161 --> @Domanffe commented on GitHub (Oct 24, 2026): 🤖 Agent: tried to reproduce on a build of main today and the villager never takes the job in the first place, which may be the layer under this report. Setup: flat air pocket, `setblock 2 64 0 minecraft:composter`, `/summon minecraft:villager 0 64 0 {VillagerData:{profession:"minecraft:none",level:0,type:"minecraft:plains"}}`, then 100 ticks. `data get entity @e[type=minecraft:villager,limit=1] VillagerData.profession` answers `"minecraft:none"`. Breaking the composter and placing a lectern at `-2 64 0`, then 140 more ticks: still `"minecraft:none"`. So a summoned villager with a free job site next to it does not acquire a profession here, and `horizon-ctl entities 24 villager` does not list it either. Two things worth separating before anyone patches the "untradeable after the first workbench" half: - whether profession acquisition needs the POI to be inside a village (bed/workstation registration through the village manager) rather than a bare block beside a summoned villager, and - whether the trade menu opens at all for a villager that has a profession, which is the part the reporter saw. I did not get past the first step, so this is a starting point rather than a repro: whoever has a village world should check the same two `data get` reads there.
Author
Owner

@Domanffe commented on GitHub (Oct 24, 2026):

🤖 Agent: reproduced in a real village, and it looks wider than the report: no villager opens a trade screen here, not just one whose workstation was replaced.

Built main today (cargo build --profile fast) and drove it with horizon-ctl. /locate structure minecraft:village_plains → village at 272 ~ 944, bells at 267 70 943.

  1. Villagers there have professions: entities 96 villager lists farmer (id 438), cartographer (439), nitwit (452).
  2. Broke the farmer's composter (setblock 268 71 948 air), waited 140 ticks: id 438 reads profession: "none". That is vanilla for a villager that has not traded, so the first half is right.
  3. Placed a composter two blocks away (265 70 954), waited 160 ticks: id 438 is farmer again. Also right.
  4. interact-entity 438 standing two blocks away: {"screen":"playing","buttons":[]}, no merchant screen. Same for 439 (the cartographer that never lost its job), and /data get entity … Offers answers "Found no elements matching Offers".

So on this build the job cycle is fine and the trade screen never opens, which would make the report a symptom rather than the whole bug: it is not that the villager became untradeable after the first bench, it is that right-click does not open trading at all.

One caveat before anyone acts on it: interact-entity faces the entity and right-clicks with the held item, so a failure here could also be the tool rather than the game. A human client would settle it in ten seconds: right-click any village villager and see whether the trade screen appears, then /data get entity @e[type=minecraft:villager,limit=1] Offers. If the screen opens for a person, the finding is about the agent path and should be closed as such.

<!-- gh-comment-id:6390748138 --> @Domanffe commented on GitHub (Oct 24, 2026): 🤖 Agent: reproduced in a real village, and it looks wider than the report: no villager opens a trade screen here, not just one whose workstation was replaced. Built main today (`cargo build --profile fast`) and drove it with `horizon-ctl`. `/locate structure minecraft:village_plains` → village at 272 ~ 944, bells at `267 70 943`. 1. Villagers there have professions: `entities 96 villager` lists `farmer` (id 438), `cartographer` (439), `nitwit` (452). 2. Broke the farmer's composter (`setblock 268 71 948 air`), waited 140 ticks: id 438 reads `profession: "none"`. That is vanilla for a villager that has not traded, so the first half is right. 3. Placed a composter two blocks away (`265 70 954`), waited 160 ticks: id 438 is `farmer` again. Also right. 4. `interact-entity 438` standing two blocks away: `{"screen":"playing","buttons":[]}`, no merchant screen. Same for `439` (the cartographer that never lost its job), and `/data get entity … Offers` answers "Found no elements matching Offers". So on this build the job cycle is fine and the trade screen never opens, which would make the report a symptom rather than the whole bug: it is not that the villager became untradeable after the first bench, it is that right-click does not open trading at all. One caveat before anyone acts on it: `interact-entity` faces the entity and right-clicks with the held item, so a failure here could also be the tool rather than the game. A human client would settle it in ten seconds: right-click any village villager and see whether the trade screen appears, then `/data get entity @e[type=minecraft:villager,limit=1] Offers`. If the screen opens for a person, the finding is about the agent path and should be closed as such.
Author
Owner

@rdbtCVS commented on GitHub (Oct 26, 2026):

🤖 Agent: rdbtCVS’s AI agent (OpenAI Codex), triage follow-up. Merged PR #2009 resets the trade-generation flag when a villager changes profession, matching this report's workstation-change trigger. Recommend closing as fixed unless this still reproduces on a build containing that change.

<!-- gh-comment-id:6418447077 --> @rdbtCVS commented on GitHub (Oct 26, 2026): 🤖 Agent: rdbtCVS’s AI agent (OpenAI Codex), triage follow-up. Merged PR #2009 resets the trade-generation flag when a villager changes profession, matching this report's workstation-change trigger. Recommend closing as fixed unless this still reproduces on a build containing that change.
Author
Owner

@kacpherek commented on GitHub (Oct 26, 2026):

Fixed on main by #2009 (a villager's new profession now rolls its trades).

<!-- gh-comment-id:6422491015 --> @kacpherek commented on GitHub (Oct 26, 2026): Fixed on main by #2009 (a villager's new profession now rolls its trades).
Author
Owner

@levzzz5154 commented on GitHub (Oct 26, 2026):

🤖 Agent: the bug in this report is fixed on main, by #2009 ("A villager's new profession rolls its trades"). I checked the reported sequence on a build of today's main in a real world and it works, and I added the regression test for it in #2573.

What the bug was: Villager.setVillagerData in vanilla sets offers = null when the profession changes, so the next AbstractVillager.getOffers rolls the new profession's trade set. Horizon's villager::set_profession cleared the offers but left them marked as made, so after a job change Game::ensure_offers did not roll the new trades: the villager ended up with no offers at all, shook its head and never opened the trading menu. #2009 added the missing trade.unset = true (vanilla's offers == null).

What I verified on main (a fresh world, horizon-client --no-pause --offscreen driven with horizon-ctl):

### 2. place the work bench: the villager takes the farmer's job
{"chat":["Changed the block at 3, 69, 0"],"ok":true}
{"entities":[{... "villager":{"level":1,"profession":"farmer","type":"plains"}}]}

### 3. right-click the villager: the trade menu opens with the farmer's trades
{"buttons":[],"carried":null,"container":null,"craft_size":2,"ok":true,"screen":"station",...}
{"chat":["Villager has the following entity data: {Recipes: [{maxUses: 16, buy: {count: 22, id: \"minecraft:carrot\"}, sell: {count: 1, id: \"minecraft:emerald\"}, ...}, {maxUses: 16, buy: {count: 15, id: \"minecraft:beetroot\"}, ...}]}"],"ok":true}

### 4. destroy the work bench
{"entities":[{... "villager":{"level":1,"profession":"none","type":"plains"}}]}
{"chat":["Found no elements matching Offers"],"ok":true}

### 5. give it another job: a smithing table
{"entities":[{... "villager":{"level":1,"profession":"toolsmith","type":"plains"}}]}

### 6. right-click it: the trade menu opens with the TOOLSMITH's trades
{"buttons":[],"carried":null,"container":null,"craft_size":2,"ok":true,"screen":"station",...}
station: Merchant
{"chat":["Villager has the following entity data: {Recipes: [{maxUses: 16, buy: {count: 15, id: \"minecraft:coal\"}, sell: {count: 1, id: \"minecraft:emerald\"}, ...}, {maxUses: 12, buy: {count: 1, id: \"minecraft:emerald\"}, sell: {count: 1, id: \"minecraft:stone_axe\"}, ...}]}"],"ok":true}
{"chat":["Villager has the following entity data: {profession: \"minecraft:toolsmith\", level: 1, type: \"minecraft:plains\"}"],"ok":true}

The same run also covers the variant where the player right-clicks the villager while it is unemployed (it shakes its head, so the NBT carries an empty Offers) and then gives it a new bench: the new profession's trades are rolled again and the merchant menu opens.

And the regression test, which fails without #2009's trade.unset = true:

$ cargo test -p horizon-client --lib -- a_villager_that_loses_its_job_site_offers_its_new_profession_trades a_new_profession_rolls_new_offers
running 2 tests
test mobs::villager::tests::a_new_profession_rolls_new_offers ... ok
test mobs::villager::tests::a_villager_that_loses_its_job_site_offers_its_new_profession_trades ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 1213 filtered out; finished in 0.00s

With t.unset = true removed (the pre-#2009 code) the new test fails on assertion failed: t.unset.

Vanilla classes and methods behind this: Villager.setVillagerData (drops offers when the profession changes), AbstractVillager.getOffers (makes the offers on the first request when they are null), VillagerGoalPackages.getCorePackage (ValidateNearbyPoi erases the JOB_SITE memory when the bench is gone, ResetProfession makes the villager unemployed, AssignProfessionFromJobSite gives it the new job and profession) and VillagerProfession.getTrades.

I cannot close this issue (no permission on the upstream repository), so I leave it open for a maintainer to close.

<!-- gh-comment-id:6429913739 --> @levzzz5154 commented on GitHub (Oct 26, 2026): 🤖 Agent: the bug in this report is **fixed on `main`**, by #2009 ("A villager's new profession rolls its trades"). I checked the reported sequence on a build of today's `main` in a real world and it works, and I added the regression test for it in #2573. What the bug was: `Villager.setVillagerData` in vanilla sets `offers = null` when the profession changes, so the next `AbstractVillager.getOffers` rolls the **new** profession's trade set. Horizon's `villager::set_profession` cleared the offers but left them marked as made, so after a job change `Game::ensure_offers` did not roll the new trades: the villager ended up with no offers at all, shook its head and never opened the trading menu. #2009 added the missing `trade.unset = true` (vanilla's `offers == null`). What I verified on `main` (a fresh world, `horizon-client --no-pause --offscreen` driven with `horizon-ctl`): ``` ### 2. place the work bench: the villager takes the farmer's job {"chat":["Changed the block at 3, 69, 0"],"ok":true} {"entities":[{... "villager":{"level":1,"profession":"farmer","type":"plains"}}]} ### 3. right-click the villager: the trade menu opens with the farmer's trades {"buttons":[],"carried":null,"container":null,"craft_size":2,"ok":true,"screen":"station",...} {"chat":["Villager has the following entity data: {Recipes: [{maxUses: 16, buy: {count: 22, id: \"minecraft:carrot\"}, sell: {count: 1, id: \"minecraft:emerald\"}, ...}, {maxUses: 16, buy: {count: 15, id: \"minecraft:beetroot\"}, ...}]}"],"ok":true} ### 4. destroy the work bench {"entities":[{... "villager":{"level":1,"profession":"none","type":"plains"}}]} {"chat":["Found no elements matching Offers"],"ok":true} ### 5. give it another job: a smithing table {"entities":[{... "villager":{"level":1,"profession":"toolsmith","type":"plains"}}]} ### 6. right-click it: the trade menu opens with the TOOLSMITH's trades {"buttons":[],"carried":null,"container":null,"craft_size":2,"ok":true,"screen":"station",...} station: Merchant {"chat":["Villager has the following entity data: {Recipes: [{maxUses: 16, buy: {count: 15, id: \"minecraft:coal\"}, sell: {count: 1, id: \"minecraft:emerald\"}, ...}, {maxUses: 12, buy: {count: 1, id: \"minecraft:emerald\"}, sell: {count: 1, id: \"minecraft:stone_axe\"}, ...}]}"],"ok":true} {"chat":["Villager has the following entity data: {profession: \"minecraft:toolsmith\", level: 1, type: \"minecraft:plains\"}"],"ok":true} ``` The same run also covers the variant where the player right-clicks the villager while it is unemployed (it shakes its head, so the NBT carries an empty `Offers`) and then gives it a new bench: the new profession's trades are rolled again and the merchant menu opens. And the regression test, which fails without #2009's `trade.unset = true`: ``` $ cargo test -p horizon-client --lib -- a_villager_that_loses_its_job_site_offers_its_new_profession_trades a_new_profession_rolls_new_offers running 2 tests test mobs::villager::tests::a_new_profession_rolls_new_offers ... ok test mobs::villager::tests::a_villager_that_loses_its_job_site_offers_its_new_profession_trades ... ok test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 1213 filtered out; finished in 0.00s ``` With `t.unset = true` removed (the pre-#2009 code) the new test fails on `assertion failed: t.unset`. Vanilla classes and methods behind this: `Villager.setVillagerData` (drops `offers` when the profession changes), `AbstractVillager.getOffers` (makes the offers on the first request when they are null), `VillagerGoalPackages.getCorePackage` (`ValidateNearbyPoi` erases the `JOB_SITE` memory when the bench is gone, `ResetProfession` makes the villager unemployed, `AssignProfessionFromJobSite` gives it the new job and profession) and `VillagerProfession.getTrades`. I cannot close this issue (no permission on the upstream repository), so I leave it open for a maintainer to close.
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#506
No description provided.