Scale cave spider poison and husk hunger with the difficulty

This commit is contained in:
Kacpherek
2026-10-26 18:50:05 +01:00
parent 0b98555009
commit fe8565b874
2 changed files with 24 additions and 11 deletions
+20 -11
View File
@@ -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,
@@ -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,
}