[PR #292] [MERGED] Copper golems keep the persistence vanilla saved (#289) #2462

Closed
opened 2026-11-02 15:56:22 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix/golem-persistence


📝 Commits (1)

  • fb15822 Load PersistenceRequired as vanilla does: copper golems save 0 again

📊 Changes

2 files changed (+5 additions, -2 deletions)

View changed files

📝 crates/horizon-client/src/entity_nbt.rs (+3 -1)
📝 crates/horizon-world/src/worldgen/structure/monument.rs (+2 -1)

📄 Description

Fixes #289

What

A copper golem from a vanilla world is saved again with PersistenceRequired: 0b, the value vanilla saves.

Why

Vanilla's Mob.readAdditionalSaveData assigns persistenceRequired = input.getBooleanOr("PersistenceRequired", false). The value saved in the file replaces what the constructor set: CopperGolem and ElderGuardian call setPersistenceRequired() in their constructors. Horizon ORed the saved flag into the value from registration instead. Registration makes copper golems persistent, as vanilla's constructor does, so a golem saved with 0b came back as 1b.

How

  • entity_nbt::mob_from_nbt: m.persistent = flag(tag, "PersistenceRequired"), as vanilla does. Every caller is a path where vanilla also calls load: saved chunks, structure templates, spawner spawn data and /data merge. Bucket data keeps its own OR rule (load_bucket_data).
  • monument.rs: Horizon builds the monument's elder guardian from spawn NBT (spawn_nbt), where vanilla calls the ElderGuardian constructor (OceanMonumentPiece.spawnElder). The NBT now carries PersistenceRequired, so the elder stays persistent under the new load rule. All other spawn_nbt callers already match their vanilla constructors: shulkers aren't persistent; drowned, witch huts and mansions pass true.

How tested

  • tools/parity.py on the Mac mini: save_roundtrip PASS (the full vanilla → Horizon → vanilla round trip, no differences left), spawner PASS, finalize_spawn PASS.
  • Self-check:
cargo fmt --all -- --check                                   OK
cargo clippy --workspace --all-targets -- -D warnings        OK
cargo test -p horizon-client --lib                           627 passed
cargo test -p horizon-world --lib                            86 passed
parity: save_roundtrip, spawner, finalize_spawn              3 passed

Nothing needs Ludovic.

🤖 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/292 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/15/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/golem-persistence` --- ### 📝 Commits (1) - [`fb15822`](https://github.com/horizon-rust/horizon/commit/fb15822b3b959712c4752e51953ccc7be0fe0c18) Load PersistenceRequired as vanilla does: copper golems save 0 again ### 📊 Changes **2 files changed** (+5 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/entity_nbt.rs` (+3 -1) 📝 `crates/horizon-world/src/worldgen/structure/monument.rs` (+2 -1) </details> ### 📄 Description Fixes #289 ## What A copper golem from a vanilla world is saved again with `PersistenceRequired: 0b`, the value vanilla saves. ## Why Vanilla's `Mob.readAdditionalSaveData` **assigns** `persistenceRequired = input.getBooleanOr("PersistenceRequired", false)`. The value saved in the file replaces what the constructor set: `CopperGolem` and `ElderGuardian` call `setPersistenceRequired()` in their constructors. Horizon ORed the saved flag into the value from registration instead. Registration makes copper golems persistent, as vanilla's constructor does, so a golem saved with `0b` came back as `1b`. ## How - `entity_nbt::mob_from_nbt`: `m.persistent = flag(tag, "PersistenceRequired")`, as vanilla does. Every caller is a path where vanilla also calls `load`: saved chunks, structure templates, spawner spawn data and `/data merge`. Bucket data keeps its own OR rule (`load_bucket_data`). - `monument.rs`: Horizon builds the monument's elder guardian from spawn NBT (`spawn_nbt`), where vanilla calls the `ElderGuardian` constructor (`OceanMonumentPiece.spawnElder`). The NBT now carries `PersistenceRequired`, so the elder stays persistent under the new load rule. All other `spawn_nbt` callers already match their vanilla constructors: shulkers aren't persistent; drowned, witch huts and mansions pass `true`. ## How tested - `tools/parity.py` on the Mac mini: **save_roundtrip PASS** (the full vanilla → Horizon → vanilla round trip, no differences left), spawner PASS, finalize_spawn PASS. - Self-check: ``` cargo fmt --all -- --check OK cargo clippy --workspace --all-targets -- -D warnings OK cargo test -p horizon-client --lib 627 passed cargo test -p horizon-world --lib 86 passed parity: save_roundtrip, spawner, finalize_spawn 3 passed ``` Nothing needs Ludovic. 🤖 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-02 15:56:22 +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#2462
No description provided.