From 688733132d7e105312337bb21cf8a96ee441ba33 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 22:47:27 +0100 Subject: [PATCH 1/2] 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 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 2/2] 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;