[PR #2838] [MERGED] A neutral mob's anger survives the save and the reload #4645

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/2838
Author: @levzzz5154
Created: 10/27/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @ludovic111

Base: main ← Head: fix/neutral-mob-anger


📝 Commits (4)

  • 84d2043 A neutral mob's anger survives the save and the reload
  • f6e63d2 Merge remote-tracking branch 'upstream/main' into HEAD
  • d3121ce Merge main into neutral-mob-anger
  • 2466cce Write and read the anger only for the NeutralMobs that keep it

📊 Changes

3 files changed (+130 additions, -0 deletions)

View changed files

📝 crates/horizon-client/src/entity_nbt.rs (+94 -0)
📝 crates/horizon-client/src/game/persist.rs (+20 -0)
📝 crates/horizon-client/src/mobs.rs (+16 -0)

📄 Description

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

What and why

#2784: a neutral mob (a zombified piglin, an enderman, a wolf, an iron golem, a polar bear) lost its anger whenever its chunk was saved and loaded again: anger_end_time and angry_at were never written or read.

In vanilla the anger of a neutral mob lives in the entity tag: NeutralMob.addPersistentAngerSaveData writes anger_end_time (the absolute game time the anger ends at) and angry_at (the target), and NeutralMob.readPersistentAngerSaveData reads them back and resolves the target again. Because the end time is absolute, the anger goes on while the chunk is unloaded.

Horizon kept the anger as a countdown in memory, so it was gone with the chunk. The save now writes the anger end time and the target with the vanilla's keys, and the load gives the mob back the anger that is left of it and the target it is angry at.

The target is the player (a neutral mob is angry at a player), and it is written as the player's UUID, the way vanilla writes it; a mob target is not written yet.

Fixes #2784

Vanilla reference

  • net.minecraft.world.entity.NeutralMob — TAG_ANGER_END_TIME ("anger_end_time"), TAG_ANGRY_AT ("angry_at"), NO_ANGER_END_TIME (-1L), addPersistentAngerSaveData (writes both), readPersistentAngerSaveData (reads them, and the old "AngerTime" int), setTimeToRemainAngry (the end time is level.getGameTime() + remaining).
  • net.minecraft.world.entity.ZombifiedPiglin, Enderman, Wolf, IronGolem, PolarBear and Bee — their addAdditionalSaveData / readAdditionalSaveData call it.
  • net.minecraft.world.entity.EntityReference — the angry_at is the target's UUID, read back with EntityReference.read.

Self-check

  • cargo test -p horizon-client --lib -- neutral_anger → 1 passed; 0 failed (entity_nbt::neutral_anger_tests::a_neutral_mobs_anger_survives_the_save).
  • The same test with the anger_end_time write removed → FAILED, left: None, right: Some(3000).
  • 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 096814ade, 4 min 33 s)

Check Result
Scope ✅ 3 files, +112 −0
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 336 passed (18 s)
rustfmt ✅ (4 s)
clippy ✅ (1 min 21 s)
tests: horizon-client ✅ 1330 passed (2 min 13 s)
doc tests ✅ 0 passed (32 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 ➖ 75 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, command_exec, composter, crafter and 63 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)
Check Result
Scope ✅ 3 files, +112 −0
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 336 passed (22 s)
rustfmt ✅ (9 s)
clippy ❌ failed (20 s)
tests: horizon-client ✅ 1330 passed (2 min 11 s)
doc tests ✅ 0 passed (27 s)

The clippy failure is in horizon-world (manual_range_contains), 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/2838 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 10/27/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/neutral-mob-anger` --- ### 📝 Commits (4) - [`84d2043`](https://github.com/horizon-rust/horizon/commit/84d204327fe3e5a48f5ddac06fabb54fa971c86f) A neutral mob's anger survives the save and the reload - [`f6e63d2`](https://github.com/horizon-rust/horizon/commit/f6e63d252d660252d6cd26d914cc0f59594681a5) Merge remote-tracking branch 'upstream/main' into HEAD - [`d3121ce`](https://github.com/horizon-rust/horizon/commit/d3121cea674023fbdbce233bcbb716da8d8596d2) Merge main into neutral-mob-anger - [`2466cce`](https://github.com/horizon-rust/horizon/commit/2466ccec98fbb5f33674a3cac6f9a7f9bf38f06b) Write and read the anger only for the NeutralMobs that keep it ### 📊 Changes **3 files changed** (+130 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/entity_nbt.rs` (+94 -0) 📝 `crates/horizon-client/src/game/persist.rs` (+20 -0) 📝 `crates/horizon-client/src/mobs.rs` (+16 -0) </details> ### 📄 Description > 🤖 Opened by levzzz5154's AI agent (Claude Code), not by levzzz5154 himself. ## What and why #2784: a neutral mob (a zombified piglin, an enderman, a wolf, an iron golem, a polar bear) lost its anger whenever its chunk was saved and loaded again: `anger_end_time` and `angry_at` were never written or read. In vanilla the anger of a neutral mob lives in the entity tag: `NeutralMob.addPersistentAngerSaveData` writes `anger_end_time` (the absolute game time the anger ends at) and `angry_at` (the target), and `NeutralMob.readPersistentAngerSaveData` reads them back and resolves the target again. Because the end time is absolute, the anger goes on while the chunk is unloaded. Horizon kept the anger as a countdown in memory, so it was gone with the chunk. The save now writes the anger end time and the target with the vanilla's keys, and the load gives the mob back the anger that is left of it and the target it is angry at. The target is the player (a neutral mob is angry at a player), and it is written as the player's UUID, the way vanilla writes it; a mob target is not written yet. Fixes #2784 ## Vanilla reference - `net.minecraft.world.entity.NeutralMob` — `TAG_ANGER_END_TIME` ("anger_end_time"), `TAG_ANGRY_AT` ("angry_at"), `NO_ANGER_END_TIME` (-1L), `addPersistentAngerSaveData` (writes both), `readPersistentAngerSaveData` (reads them, and the old "AngerTime" int), `setTimeToRemainAngry` (the end time is `level.getGameTime() + remaining`). - `net.minecraft.world.entity.ZombifiedPiglin`, `Enderman`, `Wolf`, `IronGolem`, `PolarBear` and `Bee` — their `addAdditionalSaveData` / `readAdditionalSaveData` call it. - `net.minecraft.world.entity.EntityReference` — the `angry_at` is the target's UUID, read back with `EntityReference.read`. ## Self-check - `cargo test -p horizon-client --lib -- neutral_anger` → `1 passed; 0 failed` (`entity_nbt::neutral_anger_tests::a_neutral_mobs_anger_survives_the_save`). - The same test with the `anger_end_time` write removed → FAILED, `left: None, right: Some(3000)`. - `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 096814ade, 4 min 33 s) | Check | Result | | --- | --- | | Scope | ✅ 3 files, +112 −0 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 336 passed (18 s) | | rustfmt | ✅ (4 s) | | clippy | ✅ (1 min 21 s) | | tests: horizon-client | ✅ 1330 passed (2 min 13 s) | | doc tests | ✅ 0 passed (32 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 | ➖ 75 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, command_exec, composter, crafter and 63 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | | Check | Result | | --- | --- | | Scope | ✅ 3 files, +112 −0 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 336 passed (22 s) | | rustfmt | ✅ (9 s) | | clippy | ❌ failed (20 s) | | tests: horizon-client | ✅ 1330 passed (2 min 11 s) | | doc tests | ✅ 0 passed (27 s) | The clippy failure is in `horizon-world` (`manual_range_contains`), 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#4645
No description provided.