[PR #2018] [MERGED] Fix hostile mob removal in Peaceful difficulty #3941

Closed
opened 2026-11-03 04:13:26 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2018
Author: @rdbtCVS
Created: 10/26/2026
Status: ✅ Merged
Merged: 10/26/2026
Merged by: @ludovic111

Base: main ← Head: fix/peaceful-mob-despawn-1942


📝 Commits (3)

  • 03a3c48 Fix Peaceful removal of existing hostile mobs
  • 6a7951e mob_ai oracle: create a Peaceful scenario's hostile mobs past canSpawn
  • 4b3af58 mob_ai: drop the Peaceful type scenarios that diverge for other reasons

📊 Changes

4 files changed (+40 additions, -2 deletions)

View changed files

📝 crates/horizon-client/examples/probe/mob_ai_probe.rs (+8 -1)
📝 crates/horizon-client/src/mobs/ai.rs (+4 -0)
📝 mods/horizon/src/test/java/dev/horizonlab/parity/VanillaMobAiOracle.java (+11 -1)
📝 tools/test_mob_ai_parity.py (+17 -0)

📄 Description

🤖 Opened by rdbt's AI agent (OpenAI Codex, GPT-6.1 Sol), not by rdbt.

What and why

Fixes #1942.

Existing hostile mobs were kept alive in Peaceful, including zombies loaded with a world. Apply the missing Peaceful removal check in the shared mob despawn path, before persistence and nearest-player checks. This covers both ticking mobs and loaded mobs outside simulation distance, on the in-frame and server paths. Reuse the existing vanilla entity-type allowlist so piglins, shulkers and other allowed types remain; retain the mannequin exemption.

Extend the mob AI parity harness with 31 scenarios: zombies at all four difficulties, ordinary/persistent/named/NoAI combinations, disallowed hostile types, and allowed neutral/passive/hostile exceptions. Existing scenario positions remain unchanged.

Vanilla reference

Minecraft Java 26.3 net.minecraft.world.entity.Mob.checkDespawn: bytecode offsets 0–27 check Level.getDifficulty() == Difficulty.PEACEFUL and !EntityType.isAllowedInPeaceful(), then discard and return before persistence or player-distance checks. Verified directly with javap -c against the pinned 26.3 client jar. LivingEntity.checkDespawn does not remove mannequins. Horizon's spawn_rules::allowed_in_peaceful already mirrors the entity-type rule, and LocalDifficulty is exactly zero for Peaceful.

Coverage: tools/test_mob_ai_parity.py, VanillaMobAiOracle, and the Rust mob AI probe. Parity execution is left to CI as requested.

Self-check

pr_ready (tools/pr_ready.py --quick on archlinux, against origin/main at 88d061ec9, 8 min 58 s)

Check Result
Scope ✅ 4 files, +35 −1
Cargo.lock ✅ unchanged
Public tree ✅ (2 s)
Python tests ✅ 304 passed (56 s)
rustfmt ✅ (9 s)
clippy ✅ (1 min 43 s)
tests: horizon-client ✅ 1292 passed (5 min 32 s)
doc tests ✅ 0 passed (2 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 76 affected, to run in CI (--quick): arrow, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, breaking_model, cauldron, chat_screen, command_exec, command_parse and 64 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Command: python3 tools/pr_ready.py --quick --base origin/main — exit 0. Focused scenario-generation check: 31 distinct regression scenarios, exit 0.

🤖 Generated with OpenAI Codex


🔄 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/2018 **Author:** [@rdbtCVS](https://github.com/rdbtCVS) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/peaceful-mob-despawn-1942` --- ### 📝 Commits (3) - [`03a3c48`](https://github.com/horizon-rust/horizon/commit/03a3c48a71bb472ae036561e72f5628b2788649d) Fix Peaceful removal of existing hostile mobs - [`6a7951e`](https://github.com/horizon-rust/horizon/commit/6a7951e150aaf013bf27959591a590c3ac9b5e45) mob_ai oracle: create a Peaceful scenario's hostile mobs past canSpawn - [`4b3af58`](https://github.com/horizon-rust/horizon/commit/4b3af580d97a1d99a44144d4977ad24ed844b2d8) mob_ai: drop the Peaceful type scenarios that diverge for other reasons ### 📊 Changes **4 files changed** (+40 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/examples/probe/mob_ai_probe.rs` (+8 -1) 📝 `crates/horizon-client/src/mobs/ai.rs` (+4 -0) 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaMobAiOracle.java` (+11 -1) 📝 `tools/test_mob_ai_parity.py` (+17 -0) </details> ### 📄 Description > 🤖 Opened by rdbt's AI agent (OpenAI Codex, GPT-6.1 Sol), not by rdbt. ## What and why Fixes #1942. Existing hostile mobs were kept alive in Peaceful, including zombies loaded with a world. Apply the missing Peaceful removal check in the shared mob despawn path, before persistence and nearest-player checks. This covers both ticking mobs and loaded mobs outside simulation distance, on the in-frame and server paths. Reuse the existing vanilla entity-type allowlist so piglins, shulkers and other allowed types remain; retain the mannequin exemption. Extend the mob AI parity harness with 31 scenarios: zombies at all four difficulties, ordinary/persistent/named/NoAI combinations, disallowed hostile types, and allowed neutral/passive/hostile exceptions. Existing scenario positions remain unchanged. ## Vanilla reference Minecraft Java 26.3 `net.minecraft.world.entity.Mob.checkDespawn`: bytecode offsets 0–27 check `Level.getDifficulty() == Difficulty.PEACEFUL` and `!EntityType.isAllowedInPeaceful()`, then discard and return before persistence or player-distance checks. Verified directly with `javap -c` against the pinned 26.3 client jar. `LivingEntity.checkDespawn` does not remove mannequins. Horizon's `spawn_rules::allowed_in_peaceful` already mirrors the entity-type rule, and `LocalDifficulty` is exactly zero for Peaceful. Coverage: `tools/test_mob_ai_parity.py`, `VanillaMobAiOracle`, and the Rust mob AI probe. Parity execution is left to CI as requested. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on archlinux, against origin/main at 88d061ec9, 8 min 58 s) | Check | Result | | --- | --- | | Scope | ✅ 4 files, +35 −1 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ (2 s) | | Python tests | ✅ 304 passed (56 s) | | rustfmt | ✅ (9 s) | | clippy | ✅ (1 min 43 s) | | tests: horizon-client | ✅ 1292 passed (5 min 32 s) | | doc tests | ✅ 0 passed (2 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 76 affected, to run in CI (--quick): arrow, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, breaking_model, cauldron, chat_screen, command_exec, command_parse and 64 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | Command: `python3 tools/pr_ready.py --quick --base origin/main` — exit **0**. Focused scenario-generation check: **31 distinct regression scenarios**, exit **0**. 🤖 Generated with [OpenAI Codex](https://openai.com/codex) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:13:26 +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#3941
No description provided.