[PR #3569] [MERGED] Villager gossip: hits and murders count against the player who did them #5059

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

📋 Pull Request Information

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

Base: main ← Head: fix-3431


📝 Commits (1)

  • 1da38a5 Villager gossip: hits and murders count against the player who did them

📊 Changes

2 files changed (+35 additions, -19 deletions)

View changed files

📝 crates/horizon-client/src/game/creatures.rs (+1 -1)
📝 crates/horizon-client/src/game/villagers.rs (+34 -18)

📄 Description

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

Fixes #3431

What and why

On the default single-player path the world runs on the server thread, and the window's player joins it as a guest. A villager's gossip about being hit (minor_negative) and its witnesses' gossip about a murder (major_negative) were filed under self.level.player_uuid, which is the world's singleplayer_uuid. Trading (lan_open_merchant) reads the reputation under the guest's own connection UUID, so hitting or killing villagers never raised that player's prices. LAN guests had the same problem.

last_hurt_by_player already records who last hurt each mob: None for the host, or the guest's connection. The new player_uuid_of turns that into the player's UUID:

  • the host: level.player_uuid, as before;
  • the guest whose turn it is: lan_acting_uuid;
  • any other guest: hub.guest(conn).uuid.

villager_reputation_tick (hits) and villager_murdered (witnesses) now use that UUID. Nothing changes for in-frame single player, where the host is the player. #3404 fixes the same mix-up for the cure gossip.

Vanilla reference

  • Villager.setLastHurtByMob: a hit from a player → ServerLevel.onReputationEvent(VILLAGER_HURT, attacker, this).
  • Villager.tellWitnessesThatIWasMurdered: each witness gets VILLAGER_KILLED for the killer.
  • Villager.onReputationEventFrom: gossips.add(entity.getUUID(), MINOR_NEGATIVE | MAJOR_NEGATIVE, …), so the gossip goes under the player's own UUID.
  • Villager.updateSpecialPrices → getPlayerReputation(player) reads player.getUUID(), the same UUID. The price changes by -Mth.floor(reputation * priceMultiplier): −25 × 0.05 makes 20 wheat cost 22.

No parity harness covers gossip (trading covers offers and prices only), and the bug sits in Game-level player identity, which a unit test can't build. The check below is a scripted in-game run instead. It drives the server-thread world through horizon-ctl: summon a NoAI farmer selling 1 emerald for 20 wheat (priceMultiplier 0.05), punch it once, read its Gossips, then trade with 64 wheat (shift-click the result).

Before (origin/main b19b4e92d):

player Player03321, connection UUID [I; -349863127, 2043228483, -1396897611, -503857718]
gossip: Villager has the following entity data: [{Target: [I; -1608632253, -450807400, -1786055591, -2146546415], Type: "minor_negative", Value: 25}]
inventory after one trade: {"minecraft:emerald": 3, "minecraft:wheat": 4}
FAIL: the hit's gossip names another UUID
witness after a kill: [{Target: [I; -1608632253, -450807400, -1786055591, -2146546415], Type: "major_negative", Value: 25}]

The gossip names the world's UUID, so the trade still costs 20 (three trades from 64 wheat).

After (this branch):

player Player46693, connection UUID [I; -868432495, 1918713539, -2064603332, -1393973022]
gossip: Villager has the following entity data: [{Target: [I; -868432495, 1918713539, -2064603332, -1393973022], Type: "minor_negative", Value: 25}]
inventory after one trade: {"minecraft:emerald": 2, "minecraft:wheat": 20}
PASS: the hit's gossip names the player
witness after a kill: [{Target: [I; -868432495, 1918713539, -2064603332, -1393973022], Type: "major_negative", Value: 25}]

The gossip names the player, and the trade costs 22 (two trades).

Self-check

tools/pr_ready.py doesn't run on Windows (it uses Unix sockets and symlinks), so I ran these instead:

  • cargo fmt --all -- --check: ok
  • cargo clippy -p horizon-client --features mods --all-targets -- -D warnings: ok
  • cargo test -p horizon-client --features mods --bin horizon-client villager: 3 passed
  • cargo build --profile fast -p horizon-client --features mods --bins, then the in-game check above (before on main, after on this branch). After rebasing on current main (ff0e16e3b) I rebuilt and ran the check again: PASS, gossip under the player's UUID, 2 emeralds and 20 wheat left.

I didn't add a tools/lan_e2e.py check, because lan_e2e doesn't run on Windows.

In game

On the trade screen after one punch, the price on main stays at 20. With this branch, 20 is struck out and 22 is shown, as in vanilla.

🤖 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/3569 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix-3431` --- ### 📝 Commits (1) - [`1da38a5`](https://github.com/horizon-rust/horizon/commit/1da38a5c468140fc15186b065c91e72c54f4ebb6) Villager gossip: hits and murders count against the player who did them ### 📊 Changes **2 files changed** (+35 additions, -19 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/creatures.rs` (+1 -1) 📝 `crates/horizon-client/src/game/villagers.rs` (+34 -18) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. Fixes #3431 ## What and why On the default single-player path the world runs on the server thread, and the window's player joins it as a guest. A villager's gossip about being hit (`minor_negative`) and its witnesses' gossip about a murder (`major_negative`) were filed under `self.level.player_uuid`, which is the world's `singleplayer_uuid`. Trading (`lan_open_merchant`) reads the reputation under the guest's own connection UUID, so hitting or killing villagers never raised that player's prices. LAN guests had the same problem. `last_hurt_by_player` already records who last hurt each mob: `None` for the host, or the guest's connection. The new `player_uuid_of` turns that into the player's UUID: - the host: `level.player_uuid`, as before; - the guest whose turn it is: `lan_acting_uuid`; - any other guest: `hub.guest(conn).uuid`. `villager_reputation_tick` (hits) and `villager_murdered` (witnesses) now use that UUID. Nothing changes for in-frame single player, where the host is the player. #3404 fixes the same mix-up for the cure gossip. ## Vanilla reference - `Villager.setLastHurtByMob`: a hit from a player → `ServerLevel.onReputationEvent(VILLAGER_HURT, attacker, this)`. - `Villager.tellWitnessesThatIWasMurdered`: each witness gets `VILLAGER_KILLED` for the killer. - `Villager.onReputationEventFrom`: `gossips.add(entity.getUUID(), MINOR_NEGATIVE | MAJOR_NEGATIVE, …)`, so the gossip goes under the player's own UUID. - `Villager.updateSpecialPrices` → `getPlayerReputation(player)` reads `player.getUUID()`, the same UUID. The price changes by `-Mth.floor(reputation * priceMultiplier)`: −25 × 0.05 makes 20 wheat cost 22. No parity harness covers gossip (`trading` covers offers and prices only), and the bug sits in `Game`-level player identity, which a unit test can't build. The check below is a scripted in-game run instead. It drives the server-thread world through `horizon-ctl`: summon a `NoAI` farmer selling 1 emerald for 20 wheat (`priceMultiplier` 0.05), punch it once, read its `Gossips`, then trade with 64 wheat (shift-click the result). **Before (origin/main b19b4e92d):** ``` player Player03321, connection UUID [I; -349863127, 2043228483, -1396897611, -503857718] gossip: Villager has the following entity data: [{Target: [I; -1608632253, -450807400, -1786055591, -2146546415], Type: "minor_negative", Value: 25}] inventory after one trade: {"minecraft:emerald": 3, "minecraft:wheat": 4} FAIL: the hit's gossip names another UUID witness after a kill: [{Target: [I; -1608632253, -450807400, -1786055591, -2146546415], Type: "major_negative", Value: 25}] ``` The gossip names the world's UUID, so the trade still costs 20 (three trades from 64 wheat). **After (this branch):** ``` player Player46693, connection UUID [I; -868432495, 1918713539, -2064603332, -1393973022] gossip: Villager has the following entity data: [{Target: [I; -868432495, 1918713539, -2064603332, -1393973022], Type: "minor_negative", Value: 25}] inventory after one trade: {"minecraft:emerald": 2, "minecraft:wheat": 20} PASS: the hit's gossip names the player witness after a kill: [{Target: [I; -868432495, 1918713539, -2064603332, -1393973022], Type: "major_negative", Value: 25}] ``` The gossip names the player, and the trade costs 22 (two trades). ## Self-check `tools/pr_ready.py` doesn't run on Windows (it uses Unix sockets and symlinks), so I ran these instead: - `cargo fmt --all -- --check`: ok - `cargo clippy -p horizon-client --features mods --all-targets -- -D warnings`: ok - `cargo test -p horizon-client --features mods --bin horizon-client villager`: 3 passed - `cargo build --profile fast -p horizon-client --features mods --bins`, then the in-game check above (before on main, after on this branch). After rebasing on current main (ff0e16e3b) I rebuilt and ran the check again: PASS, gossip under the player's UUID, 2 emeralds and 20 wheat left. I didn't add a `tools/lan_e2e.py` check, because lan_e2e doesn't run on Windows. ## In game On the trade screen after one punch, the price on main stays at 20. With this branch, 20 is struck out and 22 is shown, as in vanilla. 🤖 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:56 +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#5059
No description provided.