[PR #3591] [MERGED] Wolves: any target makes a wolf angry, so an alerted pack looks angry #5080

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

📋 Pull Request Information

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

Base: main ← Head: fix-3185


📝 Commits (3)

  • e086b2c Wolves: any target makes a wolf angry, so an alerted pack looks angry
  • f781769 Merge remote-tracking branch 'hr/main' into pr-3591
  • e852db5 A wolf angry at the player stays angry across a reload

📊 Changes

5 files changed (+94 additions, -14 deletions)

View changed files

📝 crates/horizon-client/examples/probe/mob_ai_probe.rs (+9 -0)
📝 crates/horizon-client/src/game/persist.rs (+7 -1)
📝 crates/horizon-client/src/mobs/tame.rs (+69 -13)
📝 mods/horizon/src/test/java/dev/horizonlab/parity/VanillaMobAiOracle.java (+5 -0)
📝 tools/test_mob_ai_parity.py (+4 -0)

📄 Description

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

What and why

Fixes #3185 (related: #2820)

When the player hits a wolf, HurtByTargetGoal.setAlertOthers gives its pack mates the player as a target, and they attack. Only the wolf that was hit showed the angry texture: Horizon set a wolf's anger in after_hurt when the player hit it, and nowhere else.

Vanilla's Wolf.aiStep ends with NeutralMob.updatePersistentAnger(level, true): whenever the wolf has a target (its attacker, the attacker of a pack mate, prey, its owner's enemy) it becomes angry at it, and with stopWhenNotAngry = true the 20-39 s timer (PERSISTENT_ANGER_TIME, one random draw) starts over every tick it holds the target. This PR ports that into tame::ai_step:

  • a target (not a creative/spectator player, per Mob.getTarget) sets angry_at and restarts the timer (400 + nextInt(381): the old nextInt(380) was one short of rangeOfSeconds(20, 39));
  • without a target the anger counts down; it ends (stopBeingAngry) when it runs out, when the target mob dies, or when the player it is angry at is in creative or spectator mode, or the difficulty is peaceful;
  • isAngryAt(player) (the target condition of NearestAttackableTargetGoal<Player>) reads the anger's target instead of "any anger";
  • after_hurt no longer draws the anger itself (Wolf.hurtServer doesn't), so the random draws come in vanilla's order;
  • saving a wolf (Game::mob_tree_nbt, used by chunk saves and /data get) keeps its anger target instead of overwriting it with the current target, which would otherwise make a wolf that lost sight of the player forget it was angry at them.

Vanilla reference

  • Wolf.aiStep → NeutralMob.updatePersistentAnger(ServerLevel, boolean), Wolf.startPersistentAngerTimer (TimeUtil.rangeOfSeconds(20, 39) → UniformInt.sample), NeutralMob.stopBeingAngry, NeutralMob.isValidPlayerTarget, NeutralMob.isAngryAt, Mob.getTarget (asValidTarget), LivingEntity.setLastHurtByMob.
  • Wolf.hurtServer sets no anger.
  • Harness: tools/test_mob_ai_parity.py now prints a wolf's anger left (wolf <ticks>, -1 when calm; oracle and probe) and has a wolf_hurt scenario (a wolf the player hits at tick 20, 200 ticks).

Self-check

tools/pr_ready.py / tools/parity.py stop on Windows (signal.SIGHUP), so these ran by hand (Windows 11):

cargo fmt --all -- --check                                                    # ok
cargo clippy -p horizon-client --features mods --all-targets -- -D warnings   # ok
cargo test -p horizon-client --lib -- mobs::tame entity_nbt                   # 13 passed
python -m unittest tests.test_port_harness                                    # OK
python tools/test_mob_ai_parity.py --only wolf                                # 4/4 scenarios match entirely, 766/766 mob-ticks

wolf_hurt with tame.rs back to main:

wolf_hurt mob 0: first divergence at tick 20 of 201 (random draws this tick: vanilla 5, horizon 5)
      vanilla 0 31=3ac44c40: UniformInt.sample:27 Wolf.startPersistentAngerTimer:603 NeutralMob.updatePersistentAnger:107 Wolf.aiStep:349 ...
    wolf: vanilla 467 | horizon 482
0/1 scenarios match entirely; 20/201 mob-ticks match before each mob's first divergence

With the fix: wolf_hurt: all 201 ticks match (and llama_wolf, wolf_deep_water, peaceful_type_wolf still match). The full mob_ai run was not repeated here: only wolves change. Checks re-run after rebasing on main at 11494e17f. The save change is covered by fmt/clippy and the entity_nbt tests only; it was not tried in game.

The alert itself isn't in the scenario: the probe doesn't apply MobEvent::SetTarget (the game does, in creatures.rs), so it is shown in game.

In game

Server-thread single player, survival: three wild wolves outside a glass box around the player; one gets /damage ... minecraft:player_attack by @s, then 3 s pass.

  • Before (main): only the wolf that was hit has red eyes; the alerted pack mates attack the box with calm eyes.
  • After: all three have the angry texture.

🤖 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/3591 **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-3185` --- ### 📝 Commits (3) - [`e086b2c`](https://github.com/horizon-rust/horizon/commit/e086b2cfdda38851255c38ba63f6a64eb17607ec) Wolves: any target makes a wolf angry, so an alerted pack looks angry - [`f781769`](https://github.com/horizon-rust/horizon/commit/f781769177cd4939852edfce90d23a69f0b21f8e) Merge remote-tracking branch 'hr/main' into pr-3591 - [`e852db5`](https://github.com/horizon-rust/horizon/commit/e852db5e60d6a23541bcee369d003a653842ef9e) A wolf angry at the player stays angry across a reload ### 📊 Changes **5 files changed** (+94 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/examples/probe/mob_ai_probe.rs` (+9 -0) 📝 `crates/horizon-client/src/game/persist.rs` (+7 -1) 📝 `crates/horizon-client/src/mobs/tame.rs` (+69 -13) 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaMobAiOracle.java` (+5 -0) 📝 `tools/test_mob_ai_parity.py` (+4 -0) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. ## What and why Fixes #3185 (related: #2820) When the player hits a wolf, `HurtByTargetGoal.setAlertOthers` gives its pack mates the player as a target, and they attack. Only the wolf that was hit showed the angry texture: Horizon set a wolf's anger in `after_hurt` when the player hit it, and nowhere else. Vanilla's `Wolf.aiStep` ends with `NeutralMob.updatePersistentAnger(level, true)`: whenever the wolf has a target (its attacker, the attacker of a pack mate, prey, its owner's enemy) it becomes angry at it, and with `stopWhenNotAngry = true` the 20-39 s timer (`PERSISTENT_ANGER_TIME`, one random draw) starts over every tick it holds the target. This PR ports that into `tame::ai_step`: - a target (not a creative/spectator player, per `Mob.getTarget`) sets `angry_at` and restarts the timer (`400 + nextInt(381)`: the old `nextInt(380)` was one short of `rangeOfSeconds(20, 39)`); - without a target the anger counts down; it ends (`stopBeingAngry`) when it runs out, when the target mob dies, or when the player it is angry at is in creative or spectator mode, or the difficulty is peaceful; - `isAngryAt(player)` (the target condition of `NearestAttackableTargetGoal<Player>`) reads the anger's target instead of "any anger"; - `after_hurt` no longer draws the anger itself (`Wolf.hurtServer` doesn't), so the random draws come in vanilla's order; - saving a wolf (`Game::mob_tree_nbt`, used by chunk saves and `/data get`) keeps its anger target instead of overwriting it with the current target, which would otherwise make a wolf that lost sight of the player forget it was angry at them. ## Vanilla reference - `Wolf.aiStep` → `NeutralMob.updatePersistentAnger(ServerLevel, boolean)`, `Wolf.startPersistentAngerTimer` (`TimeUtil.rangeOfSeconds(20, 39)` → `UniformInt.sample`), `NeutralMob.stopBeingAngry`, `NeutralMob.isValidPlayerTarget`, `NeutralMob.isAngryAt`, `Mob.getTarget` (`asValidTarget`), `LivingEntity.setLastHurtByMob`. - `Wolf.hurtServer` sets no anger. - Harness: `tools/test_mob_ai_parity.py` now prints a wolf's anger left (`wolf <ticks>`, `-1` when calm; oracle and probe) and has a `wolf_hurt` scenario (a wolf the player hits at tick 20, 200 ticks). ## Self-check `tools/pr_ready.py` / `tools/parity.py` stop on Windows (`signal.SIGHUP`), so these ran by hand (Windows 11): ``` cargo fmt --all -- --check # ok cargo clippy -p horizon-client --features mods --all-targets -- -D warnings # ok cargo test -p horizon-client --lib -- mobs::tame entity_nbt # 13 passed python -m unittest tests.test_port_harness # OK python tools/test_mob_ai_parity.py --only wolf # 4/4 scenarios match entirely, 766/766 mob-ticks ``` `wolf_hurt` with `tame.rs` back to main: ``` wolf_hurt mob 0: first divergence at tick 20 of 201 (random draws this tick: vanilla 5, horizon 5) vanilla 0 31=3ac44c40: UniformInt.sample:27 Wolf.startPersistentAngerTimer:603 NeutralMob.updatePersistentAnger:107 Wolf.aiStep:349 ... wolf: vanilla 467 | horizon 482 0/1 scenarios match entirely; 20/201 mob-ticks match before each mob's first divergence ``` With the fix: `wolf_hurt: all 201 ticks match` (and `llama_wolf`, `wolf_deep_water`, `peaceful_type_wolf` still match). The full `mob_ai` run was not repeated here: only wolves change. Checks re-run after rebasing on `main` at 11494e17f. The save change is covered by fmt/clippy and the `entity_nbt` tests only; it was not tried in game. The alert itself isn't in the scenario: the probe doesn't apply `MobEvent::SetTarget` (the game does, in `creatures.rs`), so it is shown in game. ## In game Server-thread single player, survival: three wild wolves outside a glass box around the player; one gets `/damage ... minecraft:player_attack by @s`, then 3 s pass. - Before (main): only the wolf that was hit has red eyes; the alerted pack mates attack the box with calm eyes. - After: all three have the angry texture. 🤖 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:06 +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#5080
No description provided.