[PR #2836] [MERGED] A summoned or egg-spawned mob is not persistent #4646

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2836
Author: @levzzz5154
Created: 10/27/2026
Status: ✅ Merged
Merged: 10/28/2026
Merged by: @ludovic111

Base: main ← Head: fix/spawn-egg-persistence


📝 Commits (2)

  • f8f2f90 A summoned or egg-spawned mob is not persistent
  • 28f906c Merge remote-tracking branch 'upstream/main' into HEAD

📊 Changes

3 files changed (+22 additions, -4 deletions)

View changed files

📝 crates/horizon-client/src/game/commands.rs (+1 -1)
📝 crates/horizon-client/src/game/creatures.rs (+16 -3)
📝 tools/command_exec_corpus.py (+5 -0)

📄 Description

🤖 Opened by levzzz5154's AI agent (Claude Code), not by levzzz5154 himself.

What and why

#2787: a mob summoned with /summon or spawned with a spawn egg came with PersistenceRequired: 1b, so it never despawned and it was left out of the natural mob cap.

In vanilla the persistence is Mob.setPersistenceRequired, and no spawn reason sets it: a mob that a command or a spawn egg spawns is left to the despawn rule, and only its NBT can make it persistent (/summon with {PersistenceRequired:1b} still is). Horizon's spawn_mob_for wrote the persistent flag it was given into the mob's data, and /summon and the spawn eggs passed true.

The three paths now spawn the mob without the persistence flag, and the command execution corpus checks it against vanilla: a summoned zombie is not selected by nbt={PersistenceRequired:1b}.

The other spawn_mob(.., true) callers (the sniffer, the turtle and the chicken hatching, the happy ghast, the allay, the wandering trader, the dispenser) keep their behaviour here; each of them belongs to its own vanilla class and is worth a look of its own.

Fixes #2787

Vanilla reference

  • net.minecraft.world.entity.Mob.setPersistenceRequired (Mob.java:1093) and isPersistenceRequired (Mob.java:1116) — the flag. It is set when a mob picks up an item (Mob.java:871), and by a name tag and a lead; no spawn reason sets it.
  • net.minecraft.world.entity.Mob.checkDespawn (Mob.java:689) — a persistent mob is never removed.
  • net.minecraft.world.level.levelgen.NaturalSpawner (NaturalSpawner.java:76) — the persistent mobs are left out of the mob cap.
  • net.minecraft.server.commands.SummonCommand — the mob comes from the NBT (EntityType.loadEntityRecursive), so PersistenceRequired is the NBT's say.
  • net.minecraft.world.item.SpawnEggItem.spawnOffspringFromSpawnEgg (SpawnEggItem.java:153) and net.minecraft.world.entity.Mob.checkAndHandleImportantInteractions (Mob.java:1155) — the offspring is a new mob, not a persistent one.
  • net.minecraft.world.entity.EntitySpawnReason — why a mob was spawned; none of the reasons makes it persistent.

Self-check

  • python3 tools/parity.py command_exec → PASS command_exec 23s (884 commands compared with vanilla, the new corpus case among them).
  • The same harness with the fix reverted → 883/884 commands match; the mismatch is the new case: vanilla {"messages": ["Test failed"], "results": [[false, 0]]} against Horizon {"messages": ["Test passed. Count: 1"], "results": [[true, 1]]}.
  • cargo fmt -p horizon-client → clean.
  • python3 tools/check_public_tree.py → "Public tree check passed." (the commit hook).

pr_ready (tools/pr_ready.py --quick --base upstream/main on cachyos-x8664, against upstream/main at 21123aaa3, 5 min 7 s)

Check Result
Scope ✅ 3 files, +22 −4
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 336 passed (17 s)
rustfmt ✅ (4 s)
clippy ✅ (1 min 30 s)
tests: horizon-client ✅ 1329 passed (2 min 34 s)
doc tests ✅ 0 passed (39 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 ➖ 34 affected, to run in CI (--quick): block_removal, command_exec, composter, crafter, cursor_death, dedicated_server, dispenser, forced_end, friends_integration, hardcore_respawn, lan_integration, locator_bar and 22 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)
Check Result
Scope ✅ 3 files, +22 −4
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 336 passed (18 s)
rustfmt ✅ (4 s)
clippy ❌ failed (41 s)
tests: horizon-client ✅ 1329 passed (2 min 50 s)
doc tests ✅ 0 passed (45 s)

The clippy failure is in horizon-world (manual_range_contains, twelve hits), which this branch does not touch: it is the same on upstream/main with the stable toolchain.

🤖 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/2836 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 10/27/2026 **Status:** ✅ Merged **Merged:** 10/28/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/spawn-egg-persistence` --- ### 📝 Commits (2) - [`f8f2f90`](https://github.com/horizon-rust/horizon/commit/f8f2f904bc4bb4018b61c51ac9edb39b278e750b) A summoned or egg-spawned mob is not persistent - [`28f906c`](https://github.com/horizon-rust/horizon/commit/28f906c37dcc9195ac3c8a42f570dd156782eab0) Merge remote-tracking branch 'upstream/main' into HEAD ### 📊 Changes **3 files changed** (+22 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/commands.rs` (+1 -1) 📝 `crates/horizon-client/src/game/creatures.rs` (+16 -3) 📝 `tools/command_exec_corpus.py` (+5 -0) </details> ### 📄 Description > 🤖 Opened by levzzz5154's AI agent (Claude Code), not by levzzz5154 himself. ## What and why #2787: a mob summoned with `/summon` or spawned with a spawn egg came with `PersistenceRequired: 1b`, so it never despawned and it was left out of the natural mob cap. In vanilla the persistence is `Mob.setPersistenceRequired`, and no spawn reason sets it: a mob that a command or a spawn egg spawns is left to the despawn rule, and only its NBT can make it persistent (`/summon` with `{PersistenceRequired:1b}` still is). Horizon's `spawn_mob_for` wrote the `persistent` flag it was given into the mob's data, and `/summon` and the spawn eggs passed `true`. The three paths now spawn the mob without the persistence flag, and the command execution corpus checks it against vanilla: a summoned zombie is not selected by `nbt={PersistenceRequired:1b}`. The other `spawn_mob(.., true)` callers (the sniffer, the turtle and the chicken hatching, the happy ghast, the allay, the wandering trader, the dispenser) keep their behaviour here; each of them belongs to its own vanilla class and is worth a look of its own. Fixes #2787 ## Vanilla reference - `net.minecraft.world.entity.Mob.setPersistenceRequired` (Mob.java:1093) and `isPersistenceRequired` (Mob.java:1116) — the flag. It is set when a mob picks up an item (Mob.java:871), and by a name tag and a lead; no spawn reason sets it. - `net.minecraft.world.entity.Mob.checkDespawn` (Mob.java:689) — a persistent mob is never removed. - `net.minecraft.world.level.levelgen.NaturalSpawner` (NaturalSpawner.java:76) — the persistent mobs are left out of the mob cap. - `net.minecraft.server.commands.SummonCommand` — the mob comes from the NBT (`EntityType.loadEntityRecursive`), so `PersistenceRequired` is the NBT's say. - `net.minecraft.world.item.SpawnEggItem.spawnOffspringFromSpawnEgg` (SpawnEggItem.java:153) and `net.minecraft.world.entity.Mob.checkAndHandleImportantInteractions` (Mob.java:1155) — the offspring is a new mob, not a persistent one. - `net.minecraft.world.entity.EntitySpawnReason` — why a mob was spawned; none of the reasons makes it persistent. ## Self-check - `python3 tools/parity.py command_exec` → `PASS command_exec 23s` (884 commands compared with vanilla, the new corpus case among them). - The same harness with the fix reverted → `883/884 commands match`; the mismatch is the new case: vanilla `{"messages": ["Test failed"], "results": [[false, 0]]}` against Horizon `{"messages": ["Test passed. Count: 1"], "results": [[true, 1]]}`. - `cargo fmt -p horizon-client` → clean. - `python3 tools/check_public_tree.py` → "Public tree check passed." (the commit hook). **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on cachyos-x8664, against upstream/main at 21123aaa3, 5 min 7 s) | Check | Result | | --- | --- | | Scope | ✅ 3 files, +22 −4 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 336 passed (17 s) | | rustfmt | ✅ (4 s) | | clippy | ✅ (1 min 30 s) | | tests: horizon-client | ✅ 1329 passed (2 min 34 s) | | doc tests | ✅ 0 passed (39 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 | ➖ 34 affected, to run in CI (--quick): block_removal, command_exec, composter, crafter, cursor_death, dedicated_server, dispenser, forced_end, friends_integration, hardcore_respawn, lan_integration, locator_bar and 22 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | | Check | Result | | --- | --- | | Scope | ✅ 3 files, +22 −4 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 336 passed (18 s) | | rustfmt | ✅ (4 s) | | clippy | ❌ failed (41 s) | | tests: horizon-client | ✅ 1329 passed (2 min 50 s) | | doc tests | ✅ 0 passed (45 s) | The clippy failure is in `horizon-world` (`manual_range_contains`, twelve hits), which this branch does not touch: it is the same on `upstream/main` with the stable toolchain. 🤖 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:06:54 +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#4646
No description provided.