From 7e5e469783dc63de53e88a21d7925a75fc8b3197 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Fri, 23 Oct 2026 09:19:48 +0200 Subject: [PATCH] InLove only for vanilla's Animal subclasses (not allays) save_roundtrip found an allay saved with InLove 0: Horizon's `animal` flag is broader than vanilla's Animal class. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/entity_nbt.rs | 45 +++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/crates/horizon-client/src/entity_nbt.rs b/crates/horizon-client/src/entity_nbt.rs index 7faa94e21..298b54088 100644 --- a/crates/horizon-client/src/entity_nbt.rs +++ b/crates/horizon-client/src/entity_nbt.rs @@ -89,6 +89,47 @@ impl Base<'_> { } /// `LivingEntity` + `Mob` (+ `AgeableMob`, creeper and skeleton specifics). +/// The mobs whose class extends vanilla's `Animal` (and so save `InLove`): +/// not allays, villagers, golems, dolphins or fish. +fn is_animal(id: &str) -> bool { + matches!( + id.strip_prefix("minecraft:").unwrap_or(id), + "pig" + | "cow" + | "mooshroom" + | "sheep" + | "chicken" + | "rabbit" + | "horse" + | "donkey" + | "mule" + | "zombie_horse" + | "skeleton_horse" + | "llama" + | "trader_llama" + | "goat" + | "panda" + | "polar_bear" + | "fox" + | "wolf" + | "cat" + | "ocelot" + | "parrot" + | "bee" + | "turtle" + | "armadillo" + | "frog" + | "axolotl" + | "hoglin" + | "strider" + | "camel" + | "camel_husk" + | "sniffer" + | "happy_ghast" + | "nautilus" + | "zombie_nautilus" + ) +} pub fn mob_to_nbt(m: &Mob, uuid: [i32; 4], raw: Option<&Tag>) -> Tag { let base = Base { id: &m.kind.id, @@ -181,7 +222,7 @@ pub fn mob_to_nbt(m: &Mob, uuid: [i32; 4], raw: Option<&Tag>) -> Tag { } } // Animal.addAdditionalSaveData: the love ticks left, whatever the save had. - if m.kind.flags.animal { + if is_animal(id) { map.insert("InLove".into(), Tag::Int(m.extra.in_love.max(0))); } match id { @@ -624,7 +665,7 @@ pub fn mob_from_nbt(tag: &Tag, types: &HashMap>, id: u32) - m.extra.forced_age = number(tag.get("ForcedAge")).unwrap_or(0) as i32; m.extra.age_locked = flag(tag, "AgeLocked"); } - if m.kind.flags.animal { + if is_animal(&m.kind.id) { m.extra.in_love = number(tag.get("InLove")).unwrap_or(0) as i32; } m.name_visible = flag(tag, "CustomNameVisible");