From fb15822b3b959712c4752e51953ccc7be0fe0c18 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Thu, 15 Oct 2026 07:41:31 +0200 Subject: [PATCH] Load PersistenceRequired as vanilla does: copper golems save 0 again Mob.readAdditionalSaveData assigns persistenceRequired from the tag, overriding the constructor's setPersistenceRequired (copper golems, elder guardians). Horizon ORed it in, so a copper golem vanilla saved with 0 came back with 1. The monument's elder guardian, which Horizon builds from NBT where vanilla calls the constructor, now carries the flag in its spawn NBT. Fixes #289 Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/entity_nbt.rs | 4 +++- crates/horizon-world/src/worldgen/structure/monument.rs | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/horizon-client/src/entity_nbt.rs b/crates/horizon-client/src/entity_nbt.rs index 8428a9410..72562f699 100644 --- a/crates/horizon-client/src/entity_nbt.rs +++ b/crates/horizon-client/src/entity_nbt.rs @@ -597,7 +597,9 @@ pub fn mob_from_nbt(tag: &Tag, types: &HashMap>, id: u32) - m.extra.main_hand = None; } m.death_time = number(tag.get("DeathTime")).unwrap_or(0) as i32; - m.persistent |= flag(tag, "PersistenceRequired"); + // Mob.readAdditionalSaveData overrides what the constructor set (copper + // golems and elder guardians start persistent). + m.persistent = flag(tag, "PersistenceRequired"); m.extra.pick_up_loot = flag(tag, "CanPickUpLoot"); m.custom_name = custom_name(tag); if m.kind.category == "creature" { diff --git a/crates/horizon-world/src/worldgen/structure/monument.rs b/crates/horizon-world/src/worldgen/structure/monument.rs index 3cc08964d..39959557e 100644 --- a/crates/horizon-world/src/worldgen/structure/monument.rs +++ b/crates/horizon-world/src/worldgen/structure/monument.rs @@ -350,7 +350,8 @@ impl W<'_, '_> { "minecraft:elder_guardian", pos, true, - false, + // The ElderGuardian constructor's setPersistenceRequired. + true, ))?; } Ok(())