diff --git a/crates/horizon-client/src/entity_nbt.rs b/crates/horizon-client/src/entity_nbt.rs index 7f3565067..3e22145fb 100644 --- a/crates/horizon-client/src/entity_nbt.rs +++ b/crates/horizon-client/src/entity_nbt.rs @@ -458,6 +458,9 @@ pub fn mob_to_nbt(m: &Mob, uuid: [i32; 4], raw: Option<&Tag>) -> Tag { map.insert("life_ticks".into(), Tag::Int(m.extra.egg_time)); } } + "minecraft:endermite" => { + map.insert("Lifetime".into(), Tag::Int(m.extra.counter)); + } "minecraft:shulker" => { map.insert("AttachFace".into(), Tag::Byte(m.extra.variant3 as i8)); map.insert("Peek".into(), Tag::Byte(m.extra.counter as i8)); @@ -881,6 +884,9 @@ pub fn mob_from_nbt(tag: &Tag, types: &HashMap>, id: u32) - m.extra.counter2 = number(tag.get("StunTick")).unwrap_or(0) as i32; m.extra.anim_ticks = number(tag.get("RoarTick")).unwrap_or(0) as i32; } + if m.species() == crate::mobs::Species::Endermite { + m.extra.counter = number(tag.get("Lifetime")).unwrap_or(0) as i32; + } if m.species() == crate::mobs::Species::Vex { if let Some(Tag::IntArray(v)) = tag.get("bound_pos") && v.len() == 3 diff --git a/crates/horizon-client/src/mobs/ai.rs b/crates/horizon-client/src/mobs/ai.rs index 2676c3a37..560afe08c 100644 --- a/crates/horizon-client/src/mobs/ai.rs +++ b/crates/horizon-client/src/mobs/ai.rs @@ -961,6 +961,16 @@ fn species_ai_step(m: &mut Mob, w: &MobWorld, events: &mut Vec) { } match m.species() { Species::Enderman => super::enderman::ai_step(m, w, events), + // Endermite.aiStep: `counter` is the life; an endermite not required + // to persist is discarded at 2400. + Species::Endermite => { + if !m.persistent { + m.extra.counter += 1; + } + if m.extra.counter >= 2400 { + m.removed = true; + } + } Species::Wolf => super::tame::ai_step(m, w, events), Species::Cat => super::tame::cat_ai_step(m, events), Species::Blaze => super::nether::blaze_ai_step(m, events),