[PR #6828] [MERGED] A creative or spectator player is never a mob's target #7121

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6828
Author: @ClickingMaster
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: fix/zombified-piglin-creative-target


📝 Commits (1)

  • 36a4682 A creative or spectator player is never a mob's target

📊 Changes

2 files changed (+45 additions, -0 deletions)

View changed files

📝 crates/horizon-client/src/mobs/ai.rs (+15 -0)
📝 crates/horizon-client/src/mobs/undead.rs (+30 -0)

📄 Description

🤖 Opened by ClickingMaster's AI agent (Claude Code, Claude Sonnet 5.5), not by ClickingMaster personally.

Part of #6790 (its first point: aggroed zombified piglins target you in creative). The second point is not addressed here; see the end.

Cause

Vanilla's Mob.getTarget() and Mob.setTarget() both go through asValidTarget: a Player that isCreative() or isSpectator() reads as no target, whichever goal or alert set it. Horizon reads m.ai.target directly, and only the running target goals checked creative mode. A piglin alerted by another piglin (SetTarget) or one whose goal was not running kept the target and chased the creative player.

Fix

drop_invalid_player_target in mobs/ai.rs, called at the start of each mob's tick: a creative or spectator Who::Player target is cleared. A zombified piglin or iron golem also stops being angry (NeutralMob.updatePersistentAnger ends the anger at a creative/spectator player).

Test

mobs::undead::creative_target_tests::an_angry_zombified_piglin_drops_a_creative_player: an angry piglin targeting a creative player, ticked 40 times.

  • Before: fails, target still Some(Player).
  • After: passes, target None.

Not covered

The report's second point (a ghast hits a zombified piglin and the piglins turn on the player): I could not find how that happens. In vanilla Mob.canAttack refuses ghasts, so piglins should not retaliate at the ghast either, and Horizon has no such rule. I left it alone rather than guess; it needs a repro.

Self-check

  • tools/pr_ready.py --quick: ran, all pass (rustfmt, clippy -D warnings, 1378 horizon-client-lib tests, 602 Python tests). Harnesses not run (--quick); CI's parity job picks them.
  • port_ledger.py check: not run.
  • Mob AI is shared by the server-thread and LAN paths; nothing touches the deprecated in-frame path.

🤖 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/6828 **Author:** [@ClickingMaster](https://github.com/ClickingMaster) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/zombified-piglin-creative-target` --- ### 📝 Commits (1) - [`36a4682`](https://github.com/horizon-rust/horizon/commit/36a468212131cbe4a6f04343f48b54c96c8daf9e) A creative or spectator player is never a mob's target ### 📊 Changes **2 files changed** (+45 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/mobs/ai.rs` (+15 -0) 📝 `crates/horizon-client/src/mobs/undead.rs` (+30 -0) </details> ### 📄 Description > 🤖 Opened by ClickingMaster's AI agent (Claude Code, Claude Sonnet 5.5), not by ClickingMaster personally. Part of #6790 (its first point: aggroed zombified piglins target you in creative). The second point is not addressed here; see the end. ## Cause Vanilla's `Mob.getTarget()` and `Mob.setTarget()` both go through `asValidTarget`: a `Player` that `isCreative()` or `isSpectator()` reads as no target, whichever goal or alert set it. Horizon reads `m.ai.target` directly, and only the running target goals checked creative mode. A piglin alerted by another piglin (`SetTarget`) or one whose goal was not running kept the target and chased the creative player. ## Fix `drop_invalid_player_target` in `mobs/ai.rs`, called at the start of each mob's tick: a creative or spectator `Who::Player` target is cleared. A zombified piglin or iron golem also stops being angry (`NeutralMob.updatePersistentAnger` ends the anger at a creative/spectator player). ## Test `mobs::undead::creative_target_tests::an_angry_zombified_piglin_drops_a_creative_player`: an angry piglin targeting a creative player, ticked 40 times. - Before: fails, target still `Some(Player)`. - After: passes, target `None`. ## Not covered The report's second point (a ghast hits a zombified piglin and the piglins turn on the player): I could not find how that happens. In vanilla `Mob.canAttack` refuses ghasts, so piglins should not retaliate at the ghast either, and Horizon has no such rule. I left it alone rather than guess; it needs a repro. ## Self-check - `tools/pr_ready.py --quick`: ran, all pass (rustfmt, clippy `-D warnings`, 1378 horizon-client-lib tests, 602 Python tests). Harnesses not run (`--quick`); CI's parity job picks them. - `port_ledger.py check`: not run. - Mob AI is shared by the server-thread and LAN paths; nothing touches the deprecated in-frame path. 🤖 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 06:34:14 +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#7121
No description provided.