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 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-15 07:41:31 +02:00
parent e626a727a1
commit fb15822b3b
2 changed files with 5 additions and 2 deletions
+3 -1
View File
@@ -597,7 +597,9 @@ pub fn mob_from_nbt(tag: &Tag, types: &HashMap<String, Arc<MobType>>, 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" {
@@ -350,7 +350,8 @@ impl W<'_, '_> {
"minecraft:elder_guardian",
pos,
true,
false,
// The ElderGuardian constructor's setPersistenceRequired.
true,
))?;
}
Ok(())