[PR #3404] [MERGED] Credit the curing player of a zombie villager on the server thread (#3306) #4958

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3404
Author: @degepie
Created: 10/28/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @ludovic111

Base: main ← Head: fix/issue-3306-zombify-villager


📝 Commits (1)

  • 66e1fc5 Credit the curing player of a zombie villager on the server thread

📊 Changes

3 files changed (+112 additions, -9 deletions)

View changed files

📝 crates/horizon-client/src/game/commands/players.rs (+1 -1)
📝 crates/horizon-client/src/game/zombie_villagers.rs (+28 -8)
📝 tools/lan_e2e.py (+83 -0)

📄 Description

🤖 Opened by degepie's AI agent (Claude Code), not by degepie personally.

Fixes #3306.

What

The report is about curing, not about the infection itself: a zombie villager cured with a golden apple gave the player no discount. Infection already works (on Hard a zombie that kills a villager makes a zombie villager that keeps its profession, level, trades and Xp; I checked this in game). The cure did not credit the right player on the default server thread (and for LAN guests):

  • interact_zombie_villager recorded self.level.player_uuid as the cure's starter. On the server thread that is the server Game's own UUID, not the UUID of the player who fed the apple (a guest of that server, swapped in by as_guest). So ConversionPlayer named someone who isn't in the world.
  • cure_zombie_villager added the ZOMBIE_VILLAGER_CURED gossip only when the starter was self.level.player_uuid, and fired cured_zombie_villager for the host only. In practice the gossip went to that wrong UUID, trading looked up the real player's UUID and found reputation 0, so there was no discount. "Zombie Doctor" was not awarded either.

In-frame single player (--in-frame) was not affected, because there the window's player owns level.player_uuid.

Vanilla

  • ZombieVillager.mobInteract → startConverting(player.getUUID(), …): the starter is the interacting player.
  • ZombieVillager.finishConversion: level.getPlayerByUUID(conversionStarter); if that is a ServerPlayer, CriteriaTriggers.CURED_ZOMBIE_VILLAGER.trigger(serverPlayer, this, villager) and level.onReputationEvent(ReputationEventType.ZOMBIE_VILLAGER_CURED, player, villager) (+20 major_positive, +25 minor_positive).
  • Zombie.killedEntity / Zombie.convertVillagerToZombieVillager: I read them to confirm the infection side (always on Hard, !random.nextBoolean() on Normal, never on Easy/Peaceful; data, gossips, offers and Xp copied). Horizon already matches, so nothing changed there.
  • Villager.updateSpecialPrices: the discount is floor(reputation * priceMultiplier). With 125 reputation and 0.05, that is 6 off a 20-wheat price, which gives 14.

How

  • interact_zombie_villager: the starter is acting_player_uuid(), meaning the guest whose turn it is, or else the host.
  • cure_zombie_villager: a new player_here helper (following ServerLevel.getPlayerByUUID) maps the starter to the host or to a placed guest in this dimension, using target_by_uuid (now pub(in crate::game)). The gossip goes to that UUID, and the advancement runs for that player through for_player.
  • tools/lan_e2e.py: a new cure-discount check. The host and the guest each cure a zombie villager with a golden apple, trade 20 wheat → 1 emerald, and must pay 14 (the server's clear … 0 counts 6 wheat and 1 emerald left).

Verified

  • Before (released v0.2.91, server thread, Hard): a zombie killed a farmer and it became a zombie villager with its trades. After curing it with a golden apple, ConversionPlayer held the server's UUID and the cured villager had the gossip, but the trade screen showed full price (20 wheat) and there was no "Zombie Doctor". The same scenario in --in-frame showed 20 → 14 and the advancement, which is how I narrowed it to the server thread. A temporary debug print showed the guest's UUID ≠ the gossip target at lan_open_merchant, so reputation was 0.
  • After (this branch, release build), server thread: the trade screen shows 20 14 and "Zombie Doctor" is awarded. --in-frame: same (no regression).
  • python3 tools/lan_e2e.py --check cure-discount: PASS on this branch, server thread (host + guest: 6 wheat, 1 emerald left each) and --in-frame (same). On v0.2.91 binaries: FAIL (host: expected {'wheat': 6, …}, got {'wheat': 0, …}).
  • No vanilla parity harness covers curing or gossip (parity.py --list has trading only, for offers and prices), so the end-to-end check is the regression test. I added no Rust unit test, because the bug sits in Game-level player identity, which unit tests can't reach.

Not changed (seen while testing, separate): Horizon counts the cure down in customServerAiStep, so a NoAI:1b zombie villager never finishes curing, while vanilla does it in ZombieVillager.tick(). Also data get entity @s UUID on the server thread reports the server Game's UUID rather than the player's.

pr_ready (tools/pr_ready.py --quick on b550, against origin/main at abd1755f9, 11 min 12 s)

Check Result
Scope ✅ 3 files, +112 −9
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 405 passed (1 min 9 s)
rustfmt ✅ (8 s)
clippy ✅ (3 min 14 s)
tests: horizon-client ✅ 1282 passed (4 min 43 s)
doc tests ✅ 0 passed (1 min 52 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 347 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 335 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 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/3404 **Author:** [@degepie](https://github.com/degepie) **Created:** 10/28/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/issue-3306-zombify-villager` --- ### 📝 Commits (1) - [`66e1fc5`](https://github.com/horizon-rust/horizon/commit/66e1fc50790619bc9ccc4e1b5b0adbfcdb9bea0d) Credit the curing player of a zombie villager on the server thread ### 📊 Changes **3 files changed** (+112 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/commands/players.rs` (+1 -1) 📝 `crates/horizon-client/src/game/zombie_villagers.rs` (+28 -8) 📝 `tools/lan_e2e.py` (+83 -0) </details> ### 📄 Description > 🤖 Opened by degepie's AI agent (Claude Code), not by degepie personally. Fixes #3306. ## What The report is about curing, not about the infection itself: a zombie villager cured with a golden apple gave the player no discount. Infection already works (on Hard a zombie that kills a villager makes a zombie villager that keeps its profession, level, trades and Xp; I checked this in game). The cure did not credit the right player on the default server thread (and for LAN guests): - `interact_zombie_villager` recorded `self.level.player_uuid` as the cure's starter. On the server thread that is the server `Game`'s own UUID, not the UUID of the player who fed the apple (a guest of that server, swapped in by `as_guest`). So `ConversionPlayer` named someone who isn't in the world. - `cure_zombie_villager` added the `ZOMBIE_VILLAGER_CURED` gossip only when the starter was `self.level.player_uuid`, and fired `cured_zombie_villager` for the host only. In practice the gossip went to that wrong UUID, trading looked up the real player's UUID and found reputation 0, so there was no discount. "Zombie Doctor" was not awarded either. In-frame single player (`--in-frame`) was not affected, because there the window's player owns `level.player_uuid`. ## Vanilla - `ZombieVillager.mobInteract` → `startConverting(player.getUUID(), …)`: the starter is the interacting player. - `ZombieVillager.finishConversion`: `level.getPlayerByUUID(conversionStarter)`; if that is a `ServerPlayer`, `CriteriaTriggers.CURED_ZOMBIE_VILLAGER.trigger(serverPlayer, this, villager)` and `level.onReputationEvent(ReputationEventType.ZOMBIE_VILLAGER_CURED, player, villager)` (+20 `major_positive`, +25 `minor_positive`). - `Zombie.killedEntity` / `Zombie.convertVillagerToZombieVillager`: I read them to confirm the infection side (always on Hard, `!random.nextBoolean()` on Normal, never on Easy/Peaceful; data, gossips, offers and Xp copied). Horizon already matches, so nothing changed there. - `Villager.updateSpecialPrices`: the discount is `floor(reputation * priceMultiplier)`. With 125 reputation and `0.05`, that is 6 off a 20-wheat price, which gives 14. ## How - `interact_zombie_villager`: the starter is `acting_player_uuid()`, meaning the guest whose turn it is, or else the host. - `cure_zombie_villager`: a new `player_here` helper (following `ServerLevel.getPlayerByUUID`) maps the starter to the host or to a placed guest in this dimension, using `target_by_uuid` (now `pub(in crate::game)`). The gossip goes to that UUID, and the advancement runs for that player through `for_player`. - `tools/lan_e2e.py`: a new `cure-discount` check. The host and the guest each cure a zombie villager with a golden apple, trade 20 wheat → 1 emerald, and must pay 14 (the server's `clear … 0` counts 6 wheat and 1 emerald left). ## Verified - **Before (released v0.2.91, server thread, Hard):** a zombie killed a farmer and it became a zombie villager with its trades. After curing it with a golden apple, `ConversionPlayer` held the server's UUID and the cured villager had the gossip, but the trade screen showed full price (20 wheat) and there was no "Zombie Doctor". The same scenario in `--in-frame` showed 20 → 14 and the advancement, which is how I narrowed it to the server thread. A temporary debug print showed the guest's UUID ≠ the gossip target at `lan_open_merchant`, so reputation was 0. - **After (this branch, release build), server thread:** the trade screen shows ~~20~~ 14 and "Zombie Doctor" is awarded. `--in-frame`: same (no regression). - `python3 tools/lan_e2e.py --check cure-discount`: **PASS** on this branch, server thread (host + guest: 6 wheat, 1 emerald left each) and `--in-frame` (same). On v0.2.91 binaries: **FAIL** (`host: expected {'wheat': 6, …}, got {'wheat': 0, …}`). - No vanilla parity harness covers curing or gossip (`parity.py --list` has `trading` only, for offers and prices), so the end-to-end check is the regression test. I added no Rust unit test, because the bug sits in `Game`-level player identity, which unit tests can't reach. Not changed (seen while testing, separate): Horizon counts the cure down in `customServerAiStep`, so a `NoAI:1b` zombie villager never finishes curing, while vanilla does it in `ZombieVillager.tick()`. Also `data get entity @s UUID` on the server thread reports the server `Game`'s UUID rather than the player's. **pr_ready** (`tools/pr_ready.py --quick` on b550, against origin/main at abd1755f9, 11 min 12 s) | Check | Result | | --- | --- | | Scope | ✅ 3 files, +112 −9 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 405 passed (1 min 9 s) | | rustfmt | ✅ (8 s) | | clippy | ✅ (3 min 14 s) | | tests: horizon-client | ✅ 1282 passed (4 min 43 s) | | doc tests | ✅ 0 passed (1 min 52 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 347 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 335 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 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:09:11 +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#4958
No description provided.