From bca4513187c8697ced3a13d709ae75d74498b5ee Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Tue, 27 Oct 2026 06:37:08 +0100 Subject: [PATCH] Keep withers out of Peaceful, raiders out of the spawn count, and use local difficulty for skeleton traps --- crates/horizon-client/src/game/lightning.rs | 8 ++++++-- crates/horizon-client/src/game/natural_spawning.rs | 4 +++- crates/horizon-client/src/game/wither.rs | 3 ++- crates/horizon-client/src/mobs/raider.rs | 4 ++++ 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/crates/horizon-client/src/game/lightning.rs b/crates/horizon-client/src/game/lightning.rs index 8a3ac2745..ef3bef611 100644 --- a/crates/horizon-client/src/game/lightning.rs +++ b/crates/horizon-client/src/game/lightning.rs @@ -46,8 +46,12 @@ impl Game<'_> { if !self.with_level(|b, level, _| b.is_raining_at(level, p)) { continue; } - // Skeleton trap: effective difficulty / 100 (regional difficulty approximated). - let difficulty = f64::from(self.ui.difficulty) * 0.75; + // Skeleton trap: the local effective difficulty / 100 + // (`getCurrentDifficultyAt(pos)`). + let difficulty = f64::from( + self.local_difficulty([f64::from(pos[0]), f64::from(pos[1]), f64::from(pos[2])]) + .effective, + ); let below = &self .res .facts() diff --git a/crates/horizon-client/src/game/natural_spawning.rs b/crates/horizon-client/src/game/natural_spawning.rs index 0035f5082..6a2cbcb70 100644 --- a/crates/horizon-client/src/game/natural_spawning.rs +++ b/crates/horizon-client/src/game/natural_spawning.rs @@ -504,7 +504,9 @@ impl<'a> Game<'a> { m.position.z.floor() as i32, ], is_mob: true, - persistent: m.persistent, + // isPersistenceRequired or requiresCustomPersistence + // (a raider in a raid). + persistent: m.persistent || horizon_client::mobs::raider::in_raid(m), }) .collect(); let players = players diff --git a/crates/horizon-client/src/game/wither.rs b/crates/horizon-client/src/game/wither.rs index 8084425ca..ed9b97aa9 100644 --- a/crates/horizon-client/src/game/wither.rs +++ b/crates/horizon-client/src/game/wither.rs @@ -29,7 +29,8 @@ impl Game<'_> { /// After a wither skeleton skull is placed: the T of soul sand (or soul /// soil) under three skulls, upright along X or Z, becomes a wither. pub(super) fn check_wither_spawn(&mut self, placed: [i32; 3]) -> horizon_client::Result<()> { - if !self.is_wither_skull(placed) { + // Nothing is built in Peaceful (`level.getDifficulty() != PEACEFUL`). + if self.ui.difficulty == 0 || !self.is_wither_skull(placed) { return Ok(()); } // Pattern rows top to bottom: "^^^", "###", "~#~" ('~' air). diff --git a/crates/horizon-client/src/mobs/raider.rs b/crates/horizon-client/src/mobs/raider.rs index d2ed62374..011ac2006 100644 --- a/crates/horizon-client/src/mobs/raider.rs +++ b/crates/horizon-client/src/mobs/raider.rs @@ -100,6 +100,10 @@ pub fn state(m: &Mob) -> Option<&State> { pub fn state_mut(m: &mut Mob) -> &mut State { m.extra.raider.get_or_insert_with(Box::default) } +/// `Raider.getCurrentRaid() != null`. +pub fn in_raid(m: &Mob) -> bool { + state(m).is_some_and(|s| s.raid_id.is_some()) +} pub fn has_active_raid(m: &Mob) -> bool { state(m).is_some_and(|s| s.active_raid) }