From 57e8de0007d63eee598d96c3f9a305659f39327d Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 22:42:59 +0100 Subject: [PATCH 1/4] Send the drowning entity event (67) and draw the bubbles on clients --- crates/horizon-client/src/game.rs | 23 +++------- crates/horizon-client/src/game/combat.rs | 43 ++++++++++++++++++- crates/horizon-client/src/game/creatures.rs | 9 ++++ crates/horizon-client/src/game/lan_actions.rs | 9 ++++ crates/horizon-client/src/game/remote.rs | 3 ++ crates/horizon-client/src/mobs.rs | 6 +++ crates/horizon-client/src/mobs/ai.rs | 4 ++ 7 files changed, 78 insertions(+), 19 deletions(-) diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index 7596ee871..96da5c51c 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -4555,25 +4555,12 @@ impl Game<'_> { .play("minecraft:entity.player.swim", Some(feet), volume, pitch); } MotionEvent::Drown => { - // LivingEntity.makeDrownParticles: eight bubbles moving - // with the player. - use horizon_client::particles::{ParticleOptions, ParticleType}; - for _ in 0..8 { - let mut triangle = || { - let r = self.particles.random(); - r.next_double() - r.next_double() - }; - let p = [ - feet[0] + triangle(), - feet[1] + triangle(), - feet[2] + triangle(), - ]; - self.particles.add( - &ParticleOptions::simple(ParticleType::Bubble), - p, - player_velocity, - ); + // The guests see the entity event 67 too. + if let Some(host) = &self.lan { + host.hub + .entity_event(host.host_entity, combat::DROWN_EVENT, feet); } + self.drown_particles(feet, player_velocity); } MotionEvent::BubbleColumnParticle { bubble, position } => { // ServerLevel.sendParticles: SPLASH (speed 1) or BUBBLE diff --git a/crates/horizon-client/src/game/combat.rs b/crates/horizon-client/src/game/combat.rs index 6e1d5d82b..1ae609587 100644 --- a/crates/horizon-client/src/game/combat.rs +++ b/crates/horizon-client/src/game/combat.rs @@ -1,7 +1,16 @@ //! The player's `CombatTracker`: the damage taken lately, who dealt it and //! where the player fell from, turned into the vanilla death message. use super::{Game, chat::PLAYER_NAME}; -use horizon_client::{health::HealthEvent, motion::MotionEvent, text::Text}; +use horizon_client::{ + health::HealthEvent, + motion::MotionEvent, + particles::{ParticleOptions, ParticleType}, + text::Text, +}; +use horizon_core::random::RandomSource; + +/// `EntityEvent.DROWN_PARTICLES`: broadcast with the drowning damage. +pub(super) const DROWN_EVENT: i8 = 67; struct Entry { damage_type: String, @@ -40,6 +49,38 @@ pub(super) struct CombatTracker { fall_before: f64, } impl Game<'_> { + /// `LivingEntity.makeDrownParticles`: eight bubbles around the entity, + /// moving with it. + pub(super) fn drown_particles(&mut self, at: [f64; 3], velocity: [f64; 3]) { + let bubble = ParticleOptions::simple(ParticleType::Bubble); + for _ in 0..8 { + let mut triangle = || { + let r = self.particles.random(); + r.next_double() - r.next_double() + }; + let p = [at[0] + triangle(), at[1] + triangle(), at[2] + triangle()]; + self.particles.add(&bubble, p, velocity); + } + } + /// Entity event 67 from a server, for this client's own player or an + /// entity it draws. + pub(super) fn remote_drown(&mut self, id: i32) { + let own = self.remote.as_ref().is_some_and(|r| r.entity_id == id); + let body = if own { + self.player.as_ref().map(|p| { + let (at, v) = (p.position, p.velocity); + ([at.x, at.y, at.z], [v.x, v.y, v.z]) + }) + } else { + self.mobs.iter().find(|m| m.id == id as u32).map(|m| { + let (at, v) = (m.position, m.velocity); + ([at.x, at.y, at.z], [v.x, v.y, v.z]) + }) + }; + if let Some((at, v)) = body { + self.drown_particles(at, v); + } + } /// The display name of a mob: its custom name or its type's name. pub(super) fn mob_display_name(&self, id: u32) -> Option { let m = self.mobs.iter().find(|m| m.id == id)?; diff --git a/crates/horizon-client/src/game/creatures.rs b/crates/horizon-client/src/game/creatures.rs index f6961ab13..6fcbc7166 100644 --- a/crates/horizon-client/src/game/creatures.rs +++ b/crates/horizon-client/src/game/creatures.rs @@ -897,6 +897,15 @@ impl Game<'_> { match e { MobEvent::SquidCycle { mob, at } => self.lan_entity_event(mob as i32, 19, at), MobEvent::RabbitHop { mob, at } => self.lan_entity_event(mob as i32, 1, at), + MobEvent::Drown { mob, at } => { + self.lan_entity_event(mob as i32, super::combat::DROWN_EVENT, at); + let v = self + .mobs + .iter() + .find(|m| m.id == mob) + .map_or([0.0; 3], |m| [m.velocity.x, m.velocity.y, m.velocity.z]); + self.drown_particles(at, v); + } MobEvent::Sound(name, at, volume, pitch) | MobEvent::LocalSound(name, at, volume, pitch) => { self.audio diff --git a/crates/horizon-client/src/game/lan_actions.rs b/crates/horizon-client/src/game/lan_actions.rs index 98162ae46..6c7f76e16 100644 --- a/crates/horizon-client/src/game/lan_actions.rs +++ b/crates/horizon-client/src/game/lan_actions.rs @@ -2312,6 +2312,15 @@ impl Game<'_> { match event { MotionEvent::HurtSound(sound) => self.player_hurt_sound(sound, at), MotionEvent::Fall(event) => self.landing_block_updates(&event), + // LivingEntity.baseTick's entity event 67, to every client + // around, the guest's own included; this window draws it too. + MotionEvent::Drown => { + if let Some(g) = host.hub.guest(conn) { + host.hub + .entity_event(g.entity_id, super::combat::DROWN_EVENT, at); + } + self.drown_particles(at, [0.0; 3]); + } _ => {} } } diff --git a/crates/horizon-client/src/game/remote.rs b/crates/horizon-client/src/game/remote.rs index 945af4585..845b1880d 100644 --- a/crates/horizon-client/src/game/remote.rs +++ b/crates/horizon-client/src/game/remote.rs @@ -2138,6 +2138,9 @@ impl Game<'_> { if p.event == super::totem::TOTEM_EVENT { self.remote_totem(p.id); } + if p.event == super::combat::DROWN_EVENT { + self.remote_drown(p.id); + } } C::Animate(p) => self.remote_animate(p.id, p.action), // ClientPacketListener.handleSwingAnimation: the entity swings diff --git a/crates/horizon-client/src/mobs.rs b/crates/horizon-client/src/mobs.rs index f4086216d..53a62fe3c 100644 --- a/crates/horizon-client/src/mobs.rs +++ b/crates/horizon-client/src/mobs.rs @@ -885,6 +885,12 @@ pub enum MobEvent { mob: u32, at: [f64; 3], }, + /// `LivingEntity.baseTick`'s drowning damage: entity event 67, the + /// clients' `makeDrownParticles`. + Drown { + mob: u32, + at: [f64; 3], + }, Sound(&'static str, [f64; 3], f32, f32), /// `ChestBlockEntity.startOpen` / `stopOpen` by a copper golem: the /// chest's opener count goes up or down (interaction range 3). diff --git a/crates/horizon-client/src/mobs/ai.rs b/crates/horizon-client/src/mobs/ai.rs index 258c1ccc7..8eacdd732 100644 --- a/crates/horizon-client/src/mobs/ai.rs +++ b/crates/horizon-client/src/mobs/ai.rs @@ -517,6 +517,10 @@ fn base_tick(m: &mut Mob, w: &MobWorld, events: &mut Vec) { m.air -= 1; if m.air == -20 { m.air = 0; + events.push(MobEvent::Drown { + mob: m.id, + at: [m.position.x, m.position.y, m.position.z], + }); m.damage(2.0, Damage::of(DamageKind::Drown)); } } else if m.air < 300 { From 688733132d7e105312337bb21cf8a96ee441ba33 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 22:47:27 +0100 Subject: [PATCH 2/4] Freeze mobs in powder snow and shake frozen mobs and cold striders --- .../src/game/commands/world_cmds.rs | 1 + crates/horizon-client/src/game/creatures.rs | 1 + crates/horizon-client/src/game/lan.rs | 21 ++++++++ crates/horizon-client/src/game/remote.rs | 16 ++++++ crates/horizon-client/src/mobs.rs | 17 ++++++ crates/horizon-client/src/mobs/ai.rs | 52 +++++++++++++++++++ crates/horizon-client/src/mobs/render.rs | 9 +++- crates/horizon-client/src/mobs/sulfur_cube.rs | 1 + 8 files changed, 116 insertions(+), 2 deletions(-) diff --git a/crates/horizon-client/src/game/commands/world_cmds.rs b/crates/horizon-client/src/game/commands/world_cmds.rs index 687eb3f88..103211dd2 100644 --- a/crates/horizon-client/src/game/commands/world_cmds.rs +++ b/crates/horizon-client/src/game/commands/world_cmds.rs @@ -118,6 +118,7 @@ impl Game<'_> { "magic" | "indirect_magic" | "dragon_breath" => DamageKind::Magic, "sting" => DamageKind::Sting, "cactus" | "sweet_berry_bush" => DamageKind::Cactus, + "freeze" => DamageKind::Freeze, "in_wall" => DamageKind::InWall, "thorns" => DamageKind::Thorns, _ => DamageKind::Generic, diff --git a/crates/horizon-client/src/game/creatures.rs b/crates/horizon-client/src/game/creatures.rs index f6961ab13..a19b2c7c5 100644 --- a/crates/horizon-client/src/game/creatures.rs +++ b/crates/horizon-client/src/game/creatures.rs @@ -3531,6 +3531,7 @@ pub(super) fn damage_type(kind: horizon_client::mobs::DamageKind, player: bool) K::InWall => "minecraft:in_wall", K::Thorns => "minecraft:thorns", K::SonicBoom => "minecraft:sonic_boom", + K::Freeze => "minecraft:freeze", K::OutOfWorld => "minecraft:out_of_world", } } diff --git a/crates/horizon-client/src/game/lan.rs b/crates/horizon-client/src/game/lan.rs index e39fa3a68..967d29e40 100644 --- a/crates/horizon-client/src/game/lan.rs +++ b/crates/horizon-client/src/game/lan.rs @@ -371,6 +371,26 @@ fn mob_meta( } } +/// What a client shakes a mob by: Entity.DATA_TICKS_FROZEN (7), whose full +/// count is `isFullyFrozen`, and Strider.DATA_SUFFOCATING (18, after +/// AgeableMob's baby flag and DATA_BOOST_TIME). +fn mob_freeze_meta( + m: &Mob, + meta: &mut Vec<(u8, i32, Value)>, + defaults: &mut Vec<(u8, i32, Value)>, +) { + if m.ticks_frozen > 0 { + meta.push((7, serializer::INT, Value::Int(m.ticks_frozen))); + } + defaults.push((7, serializer::INT, Value::Int(0))); + if m.kind.id == "minecraft:strider" { + if m.extra.flag { + meta.push((18, serializer::BOOLEAN, Value::Bool(true))); + } + defaults.push((18, serializer::BOOLEAN, Value::Bool(false))); + } +} + /// The equipment a mob shows (ClientboundSetEquipmentPacket slots: main hand, /// off hand, feet, legs, chest, head, body, saddle). fn mob_equipment( @@ -878,6 +898,7 @@ impl Game<'_> { e.velocity = [m.velocity.x, m.velocity.y, m.velocity.z]; e.needs_sync = m.needs_sync; mob_meta(m, hub, player_entity, &mut e.meta, &mut e.defaults); + mob_freeze_meta(m, &mut e.meta, &mut e.defaults); mob_equipment(m, hub, &mut e.equipment); self.mob_attributes(m, &mut e.attributes); e.leash = leash; diff --git a/crates/horizon-client/src/game/remote.rs b/crates/horizon-client/src/game/remote.rs index 945af4585..08f76033a 100644 --- a/crates/horizon-client/src/game/remote.rs +++ b/crates/horizon-client/src/game/remote.rs @@ -1916,6 +1916,22 @@ impl Game<'_> { } } } + if let Some(m) = self.mobs.iter_mut().find(|m| m.id == p.id as u32) { + for (index, _, value) in &p.values { + match (index, value) { + // Entity.DATA_TICKS_FROZEN: isFullyFrozen shakes it. + (7, Value::Int(ticks)) => m.ticks_frozen = *ticks, + // Strider.DATA_SUFFOCATING (after AgeableMob's baby + // flag and DATA_BOOST_TIME): a cold strider shakes. + (18, Value::Bool(cold)) + if m.species() == horizon_client::mobs::Species::Strider => + { + m.extra.flag = *cold; + } + _ => {} + } + } + } // LivingEntity.DATA_LIVING_ENTITY_FLAGS: for another player // too, remote_mob_data's apply reads index 8 above. let mannequin = self diff --git a/crates/horizon-client/src/mobs.rs b/crates/horizon-client/src/mobs.rs index f4086216d..13d282eba 100644 --- a/crates/horizon-client/src/mobs.rs +++ b/crates/horizon-client/src/mobs.rs @@ -524,6 +524,8 @@ pub enum DamageKind { InWall, Thorns, SonicBoom, + /// `freeze`: a fully frozen mob in powder snow. + Freeze, /// `fell_out_of_world`: below the world's floor. OutOfWorld, } @@ -589,6 +591,7 @@ impl Damage { | DamageKind::InWall | DamageKind::Generic | DamageKind::SonicBoom + | DamageKind::Freeze | DamageKind::OutOfWorld ) } @@ -612,6 +615,7 @@ impl Damage { | DamageKind::Cactus | DamageKind::Generic | DamageKind::InWall + | DamageKind::Freeze | DamageKind::OutOfWorld ) } @@ -1330,6 +1334,10 @@ impl Mob { .max((f64::from(ticks) * self.burning_time()).ceil() as i32); self.ticks_frozen = 0; } + /// `Entity.isFullyFrozen`. + pub fn is_fully_frozen(&self) -> bool { + self.ticks_frozen >= crate::motion::PlayerMotion::TICKS_REQUIRED_TO_FREEZE + } /// What other mobs see of this one this tick (`player`: the player's /// UUID, which villagers' reputation is keyed by). @@ -1808,6 +1816,15 @@ impl Mob { { amount *= 0.75; } + // LivingEntity.hurtServer: `#freeze_hurts_extra_types` take five times. + if source.kind == DamageKind::Freeze + && matches!( + self.species(), + Species::Strider | Species::Blaze | Species::MagmaCube + ) + { + amount *= 5.0; + } let (worn, worn_toughness) = self.worn_armor(); if !source.bypasses_armor() && self.kind.armor + worn > 0.0 { // CombatRules.getDamageAfterAbsorb diff --git a/crates/horizon-client/src/mobs/ai.rs b/crates/horizon-client/src/mobs/ai.rs index 258c1ccc7..1163c24c1 100644 --- a/crates/horizon-client/src/mobs/ai.rs +++ b/crates/horizon-client/src/mobs/ai.rs @@ -528,6 +528,7 @@ fn base_tick(m: &mut Mob, w: &MobWorld, events: &mut Vec) { { m.damage(1.0, Damage::of(DamageKind::Drown)); } + freeze_tick(m, w); } tick_effects(m); if m.species() == Species::Illusioner { @@ -557,6 +558,57 @@ fn base_tick(m: &mut Mob, w: &MobWorld, events: &mut Vec) { // Entity.baseTick ends with Leashable.tickLeash. super::leash::tick(m, w, events); } +/// `LivingEntity.aiStep`'s "freezing" with `InsideBlockEffectType.FREEZE`: +/// powder snow builds `ticks_frozen` up, anywhere else it melts twice as +/// fast, and a fully frozen mob takes one freeze damage every 40 ticks. +fn freeze_tick(m: &mut Mob, w: &MobWorld) { + let in_snow = in_powder_snow(m, w); + if !in_snow && m.ticks_frozen == 0 { + return; + } + let can_freeze = can_freeze(m, w); + if in_snow && can_freeze { + m.ticks_frozen = + (m.ticks_frozen + 1).min(crate::motion::PlayerMotion::TICKS_REQUIRED_TO_FREEZE); + } else { + m.ticks_frozen = (m.ticks_frozen - 2).max(0); + } + if m.age.is_multiple_of(40) && m.is_fully_frozen() && can_freeze { + m.damage(1.0, Damage::of(DamageKind::Freeze)); + } +} +/// Whether the mob's box (shrunk by `1.0E-5`, as in `Entity.checkInsideBlocks`) +/// touches powder snow. +fn in_powder_snow(m: &Mob, w: &MobWorld) -> bool { + let b = m.bounds().deflate(Vec3::new(1e-5, 1e-5, 1e-5)); + let (min, max) = (b.min_position(), b.max_position()); + for x in min.x.floor() as i32..=max.x.floor() as i32 { + for y in min.y.floor() as i32..=max.y.floor() as i32 { + for z in min.z.floor() as i32..=max.z.floor() as i32 { + if &*w.facts.get(w.world.block(x, y, z)).name == "minecraft:powder_snow" { + return true; + } + } + } + } + false +} +/// `LivingEntity.canFreeze`: not a `#freeze_immune_entity_types` mob and no +/// worn piece in `#freeze_immune_wearables`. +fn can_freeze(m: &Mob, w: &MobWorld) -> bool { + if w.data + .entity_has("minecraft:freeze_immune_entity_types", &m.kind.id) + { + return false; + } + let immune = w + .items + .and_then(|i| i.item_tags.get("minecraft:freeze_immune_wearables")); + ![&m.extra.head, &m.extra.chest, &m.extra.legs, &m.extra.feet] + .into_iter() + .flatten() + .any(|item| immune.is_some_and(|t| t.contains(&**item))) +} /// `Mob.playAmbientSound` on demand: a spawn egg or a mob bucket just placed `m`. pub fn ambient_sound(m: &mut Mob, w: &MobWorld, events: &mut Vec) { play_ambient(m, w, events); diff --git a/crates/horizon-client/src/mobs/render.rs b/crates/horizon-client/src/mobs/render.rs index 077fd38a6..0a6622cab 100644 --- a/crates/horizon-client/src/mobs/render.rs +++ b/crates/horizon-client/src/mobs/render.rs @@ -833,10 +833,15 @@ pub fn base_transform_at(m: &Mob, alpha: f32, origin: glam::Mat4) -> glam::Mat4 base *= species_scale(m, alpha); base * glam::Mat4::from_translation(glam::Vec3::new(0.0, -1.501, 0.0)) } -/// `LivingEntityRenderer.isShaking`: converting zombies, piglins and -/// hoglins, and a zombie villager being cured. +/// `LivingEntityRenderer.isShaking`: a fully frozen mob (the skeleton's own +/// `isShaking` is its stray conversion only), converting zombies, piglins +/// and hoglins, a zombie villager being cured and a cold strider. fn shaking(m: &Mob) -> bool { + if m.is_fully_frozen() && m.species() != Species::Skeleton { + return true; + } match m.species() { + Species::Strider => super::strider::suffocating(m), Species::ZombieVillager => super::zombie_villager::is_converting(m), Species::Zombie | Species::Husk => m.extra.counter2 > 0, Species::Piglin | Species::PiglinBrute | Species::Hoglin => { diff --git a/crates/horizon-client/src/mobs/sulfur_cube.rs b/crates/horizon-client/src/mobs/sulfur_cube.rs index 00b846b86..e97134505 100644 --- a/crates/horizon-client/src/mobs/sulfur_cube.rs +++ b/crates/horizon-client/src/mobs/sulfur_cube.rs @@ -297,6 +297,7 @@ pub fn accepts_damage(m: &mut Mob, source: &Damage, amount: f32) -> bool { | DamageKind::Fall | DamageKind::Sting | DamageKind::Cactus + | DamageKind::Freeze ); if immune { if let Some(from) = source.from { From 909f15b90979c4339575e4011c37f2d0588f3464 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 23:22:03 +0100 Subject: [PATCH 3/4] Count the warden tendril and heart animations down again --- crates/horizon-client/src/mobs/warden.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/horizon-client/src/mobs/warden.rs b/crates/horizon-client/src/mobs/warden.rs index 9092c9e8f..747443577 100644 --- a/crates/horizon-client/src/mobs/warden.rs +++ b/crates/horizon-client/src/mobs/warden.rs @@ -796,6 +796,12 @@ pub fn client_tick(m: &mut Mob) { animate(m, &mut Vec::new()); } fn animate(m: &mut Mob, events: &mut Vec) { + // The animation values count down after the sync of the last tick. + for slot in [TENDRIL, HEART] { + if m.anim.v[slot] > 0.0 { + m.anim.v[slot] -= 1.0; + } + } let digging_clock = |m: &Mob, slot: usize| { m.anim.states[slot] .millis(m.age as f32) From 5435eb0f17d6f655604ba9cec75a6d2a829ad0fa Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Tue, 27 Oct 2026 06:30:07 +0100 Subject: [PATCH 4/4] Send a cold strider's shiver at index 19 AgeableMob has two entries in 26.3 (DATA_BABY_ID 16, AGE_LOCKED 17), so Strider's DATA_BOOST_TIME is 18 and DATA_SUFFOCATING 19. A boolean at 18 is the wrong type for that slot on a vanilla client. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/game/lan.rs | 8 ++++---- crates/horizon-client/src/game/remote.rs | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/horizon-client/src/game/lan.rs b/crates/horizon-client/src/game/lan.rs index 967d29e40..8bed065a8 100644 --- a/crates/horizon-client/src/game/lan.rs +++ b/crates/horizon-client/src/game/lan.rs @@ -372,8 +372,8 @@ fn mob_meta( } /// What a client shakes a mob by: Entity.DATA_TICKS_FROZEN (7), whose full -/// count is `isFullyFrozen`, and Strider.DATA_SUFFOCATING (18, after -/// AgeableMob's baby flag and DATA_BOOST_TIME). +/// count is `isFullyFrozen`, and Strider.DATA_SUFFOCATING (19, after +/// AgeableMob's two and DATA_BOOST_TIME). fn mob_freeze_meta( m: &Mob, meta: &mut Vec<(u8, i32, Value)>, @@ -385,9 +385,9 @@ fn mob_freeze_meta( defaults.push((7, serializer::INT, Value::Int(0))); if m.kind.id == "minecraft:strider" { if m.extra.flag { - meta.push((18, serializer::BOOLEAN, Value::Bool(true))); + meta.push((19, serializer::BOOLEAN, Value::Bool(true))); } - defaults.push((18, serializer::BOOLEAN, Value::Bool(false))); + defaults.push((19, serializer::BOOLEAN, Value::Bool(false))); } } diff --git a/crates/horizon-client/src/game/remote.rs b/crates/horizon-client/src/game/remote.rs index 08f76033a..d05d21651 100644 --- a/crates/horizon-client/src/game/remote.rs +++ b/crates/horizon-client/src/game/remote.rs @@ -1921,9 +1921,9 @@ impl Game<'_> { match (index, value) { // Entity.DATA_TICKS_FROZEN: isFullyFrozen shakes it. (7, Value::Int(ticks)) => m.ticks_frozen = *ticks, - // Strider.DATA_SUFFOCATING (after AgeableMob's baby - // flag and DATA_BOOST_TIME): a cold strider shakes. - (18, Value::Bool(cold)) + // Strider.DATA_SUFFOCATING (after AgeableMob's two + // and DATA_BOOST_TIME): a cold strider shakes. + (19, Value::Bool(cold)) if m.species() == horizon_client::mobs::Species::Strider => { m.extra.flag = *cold;