Keep withers out of Peaceful, raiders out of the spawn count, and use local difficulty for skeleton traps

This commit is contained in:
Kacpherek
2026-10-27 06:37:08 +01:00
parent 6044c6ff88
commit bca4513187
4 changed files with 15 additions and 4 deletions
+6 -2
View File
@@ -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()
@@ -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
+2 -1
View File
@@ -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).
+4
View File
@@ -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)
}