From fe8565b8740eb6b1282a390a9e6ee4a8d8caf9d4 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 18:50:05 +0100 Subject: [PATCH] Scale cave spider poison and husk hunger with the difficulty --- crates/horizon-client/src/mobs/ai.rs | 31 ++++++++++++++-------- crates/horizon-client/src/mobs/spawning.rs | 4 +++ 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/crates/horizon-client/src/mobs/ai.rs b/crates/horizon-client/src/mobs/ai.rs index 2676c3a37..2e950079a 100644 --- a/crates/horizon-client/src/mobs/ai.rs +++ b/crates/horizon-client/src/mobs/ai.rs @@ -1359,17 +1359,26 @@ pub fn do_hurt_target(m: &mut Mob, who: Who, cx: &mut Cx) { let from = [m.position.x, m.position.y, m.position.z]; let source = Damage::mob(m.id, from); match m.species() { - // Difficulty NORMAL: cave spiders poison for 7 seconds. - Species::CaveSpider if who == Who::Player => cx.events.push(MobEvent::EffectPlayer { - effect: "minecraft:poison", - ticks: 7 * 20, - amplifier: 0, - }), - Species::Husk if who == Who::Player => cx.events.push(MobEvent::EffectPlayer { - effect: "minecraft:hunger", - ticks: 140, - amplifier: 0, - }), + // CaveSpider.doHurtTarget: poison for 7 s on normal, 15 s on hard. + Species::CaveSpider if who == Who::Player && cx.w.difficulty.base >= 2 => { + cx.events.push(MobEvent::EffectPlayer { + effect: "minecraft:poison", + ticks: if cx.w.difficulty.base == 2 { 7 } else { 15 } * 20, + amplifier: 0, + }) + } + // Husk.doHurtTarget: hunger for 140 ticks per whole point of the + // local difficulty, only with an empty main hand. + Species::Husk if who == Who::Player && m.extra.main_hand.is_none() => { + let ticks = 140 * cx.w.difficulty.effective as i32; + if ticks > 0 { + cx.events.push(MobEvent::EffectPlayer { + effect: "minecraft:hunger", + ticks, + amplifier: 0, + }) + } + } Species::WitherSkeleton if who == Who::Player => cx.events.push(MobEvent::EffectPlayer { effect: "minecraft:wither", ticks: 200, diff --git a/crates/horizon-client/src/mobs/spawning.rs b/crates/horizon-client/src/mobs/spawning.rs index 93e3fe119..46ac6f0ee 100644 --- a/crates/horizon-client/src/mobs/spawning.rs +++ b/crates/horizon-client/src/mobs/spawning.rs @@ -34,6 +34,8 @@ pub fn placement_ok(species: Species, w: &MobWorld, x: i32, y: i32, z: i32) -> b /// `DifficultyInstance`: the local difficulty at a position. #[derive(Clone, Copy, Debug)] pub struct LocalDifficulty { + /// The world difficulty id, 0 peaceful to 3 hard. + pub base: u8, pub effective: f32, /// The world difficulty is hard. pub hard: bool, @@ -47,6 +49,7 @@ impl LocalDifficulty { let hard = base == 3; if base == 0 { return Self { + base, effective: 0.0, hard, }; @@ -59,6 +62,7 @@ impl LocalDifficulty { local *= 0.5; } Self { + base, effective: f32::from(base) * (0.75 + global + local), hard, }