From 087b2526c66b87a80be52618e53812a146524fa0 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Wed, 14 Oct 2026 23:12:32 +0200 Subject: [PATCH] Creepers swell for LAN guests and load ignited from NBT The host sends Creeper.DATA_SWELL_DIR and DATA_IS_IGNITED with the creeper's entity data, and a guest runs the client half of Creeper.tick on them, so the swell and white flash CreeperRenderer draws now show on the guest too. Creeper.readAdditionalSaveData's ignited lights the fuse (summon creeper ~ ~ ~ {ignited:1b}). Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/entity_nbt.rs | 9 ++++----- crates/horizon-client/src/game/lan.rs | 14 +++++++++++--- crates/horizon-client/src/game/remote.rs | 16 ++++++++++++++++ crates/horizon-client/src/mobs/hostile.rs | 13 +++++++++++++ 4 files changed, 44 insertions(+), 8 deletions(-) diff --git a/crates/horizon-client/src/entity_nbt.rs b/crates/horizon-client/src/entity_nbt.rs index 082967726..fe4bc3c9f 100644 --- a/crates/horizon-client/src/entity_nbt.rs +++ b/crates/horizon-client/src/entity_nbt.rs @@ -168,14 +168,11 @@ pub fn mob_to_nbt(m: &Mob, uuid: [i32; 4], raw: Option<&Tag>) -> Tag { } match id { "minecraft:creeper" => { - for (key, value) in [ - ("Fuse", Tag::Short(30)), - ("ExplosionRadius", Tag::Byte(3)), - ("ignited", Tag::Byte(0)), - ] { + for (key, value) in [("Fuse", Tag::Short(30)), ("ExplosionRadius", Tag::Byte(3))] { map.entry(key.into()).or_insert(value); } map.insert("powered".into(), Tag::Byte(i8::from(m.extra.charged))); + map.insert("ignited".into(), Tag::Byte(i8::from(m.extra.flag))); } "minecraft:cat" => { if let Some(owner) = m.extra.owner { @@ -600,6 +597,8 @@ pub fn mob_from_nbt(tag: &Tag, types: &HashMap>, id: u32) - m.no_gravity = m.no_gravity || flag(tag, "NoGravity"); if m.species() == crate::mobs::Species::Creeper { m.extra.charged = flag(tag, "powered"); + // Creeper.readAdditionalSaveData: `ignited` lights the fuse. + m.extra.flag = flag(tag, "ignited"); } if matches!( m.species(), diff --git a/crates/horizon-client/src/game/lan.rs b/crates/horizon-client/src/game/lan.rs index 7e6a1a59a..ed29d0305 100644 --- a/crates/horizon-client/src/game/lan.rs +++ b/crates/horizon-client/src/game/lan.rs @@ -225,9 +225,17 @@ fn mob_meta(m: &Mob, hub: &Hub) -> Vec<(u8, i32, Value)> { meta.push((18, serializer::INT, Value::Int(e.size))); } } - // Creeper.DATA_IS_POWERED. - "minecraft:creeper" if e.charged => { - meta.push((17, serializer::BOOLEAN, Value::Bool(true))); + // Creeper.DATA_SWELL_DIR, DATA_IS_POWERED and DATA_IS_IGNITED: the + // guest swells the creeper from them. The direction always goes in, + // as only changed entries are sent and it drops back to -1. + "minecraft:creeper" => { + meta.push((16, serializer::INT, Value::Int(e.counter))); + if e.charged { + meta.push((17, serializer::BOOLEAN, Value::Bool(true))); + } + if e.flag { + meta.push((18, serializer::BOOLEAN, Value::Bool(true))); + } } // Enderman.DATA_CARRY_STATE. "minecraft:enderman" => { diff --git a/crates/horizon-client/src/game/remote.rs b/crates/horizon-client/src/game/remote.rs index 8e3f9a074..0517274ae 100644 --- a/crates/horizon-client/src/game/remote.rs +++ b/crates/horizon-client/src/game/remote.rs @@ -947,6 +947,19 @@ impl Game<'_> { } } } + if let Some(m) = self.mobs.iter_mut().find(|m| m.id == p.id as u32) + && m.species() == horizon_client::mobs::Species::Creeper + { + for (index, _, value) in &p.values { + match (index, value) { + // Creeper.DATA_SWELL_DIR, DATA_IS_POWERED, DATA_IS_IGNITED. + (16, Value::Int(dir)) => m.extra.counter = *dir, + (17, Value::Bool(powered)) => m.extra.charged = *powered, + (18, Value::Bool(ignited)) => m.extra.flag = *ignited, + _ => {} + } + } + } for (index, _, value) in &p.values { if *index == ITEM_ENTITY_ITEM && let Value::Item(stack) = value @@ -1759,6 +1772,9 @@ impl Game<'_> { if m.species() == horizon_client::mobs::Species::Rabbit { horizon_client::mobs::rabbit::base_tick(m); } + if m.species() == horizon_client::mobs::Species::Creeper { + horizon_client::mobs::hostile::creeper_client_tick(m); + } if m.hurt_time > 0 { m.hurt_time -= 1; } diff --git a/crates/horizon-client/src/mobs/hostile.rs b/crates/horizon-client/src/mobs/hostile.rs index 403eaa3c7..0d3feaa6c 100644 --- a/crates/horizon-client/src/mobs/hostile.rs +++ b/crates/horizon-client/src/mobs/hostile.rs @@ -142,6 +142,19 @@ impl Goal for Swell { m.extra.counter = dir; } } +/// Creeper.tick on a client of a server: the synced fuse direction +/// (DATA_SWELL_DIR, DATA_IS_IGNITED) swells the creeper the renderer draws; +/// the server explodes it. +pub fn creeper_client_tick(m: &mut Mob) { + if !m.alive() { + return; + } + m.previous_swell = m.swell; + if m.extra.flag { + m.extra.counter = 1; + } + m.swell = (m.swell + m.extra.counter).clamp(0, 30); +} /// Creeper.tick: advance the fuse and explode at 30. pub fn creeper_tick(m: &mut Mob, events: &mut Vec) { if !m.alive() {