diff --git a/crates/horizon-client/src/mobs/ai.rs b/crates/horizon-client/src/mobs/ai.rs index 8335cb745..5fce47b37 100644 --- a/crates/horizon-client/src/mobs/ai.rs +++ b/crates/horizon-client/src/mobs/ai.rs @@ -746,7 +746,7 @@ fn ai_step(m: &mut Mob, w: &MobWorld, level_random: &mut LegacyRandom, events: & if m.kind.flags.burns_in_day && m.alive() && sun_burn_tick(m, w) && m.extra.head.is_none() { m.ignite_for_ticks(160); } - species_ai_step(m, w, events); + species_ai_step(m, w, level_random, events); } impl Mob { /// LivingEntity.isPushable (and the push it takes from `Entity.push(Entity)`): @@ -955,7 +955,12 @@ fn custom_server_ai_step(m: &mut Mob, cx: &mut Cx) { _ => {} } } -fn species_ai_step(m: &mut Mob, w: &MobWorld, events: &mut Vec) { +fn species_ai_step( + m: &mut Mob, + w: &MobWorld, + level_random: &mut LegacyRandom, + events: &mut Vec, +) { if family(m.species()) == Family::Aquatic { aquatic::ai_step(m, w, events); } @@ -988,7 +993,7 @@ fn species_ai_step(m: &mut Mob, w: &MobWorld, events: &mut Vec) { } Species::Shulker => { super::shulker::tick(m, w, events); - super::shulker::ai_step(m, w, events); + super::shulker::ai_step(m, w, level_random, events); } Species::SnowGolem => super::golem::snow_ai_step(m, w, events), Species::CopperGolem => super::copper_golem::ai_step(m, w, events), diff --git a/crates/horizon-client/src/mobs/shulker.rs b/crates/horizon-client/src/mobs/shulker.rs index ccb33fd24..124d1b299 100644 --- a/crates/horizon-client/src/mobs/shulker.rs +++ b/crates/horizon-client/src/mobs/shulker.rs @@ -14,7 +14,7 @@ use crate::projectiles::{Projectile, ProjectileWorld, STEPS}; use horizon_core::geometry::trig::Mth; use horizon_core::{ geometry::{Aabb, Vec3}, - random::RandomSource, + random::{LegacyRandom, RandomSource}, }; use std::f32::consts::PI; @@ -173,20 +173,30 @@ pub fn hit_by_bullet(m: &mut Mob) { } } /// The deferred teleport of `after_hurt` and `hitByShulkerBullet`. -pub fn ai_step(m: &mut Mob, w: &MobWorld, events: &mut Vec) { +pub fn ai_step( + m: &mut Mob, + w: &MobWorld, + level_random: &mut LegacyRandom, + events: &mut Vec, +) { if m.extra.flag { m.extra.flag = false; teleport(m, w, events); } if m.extra.flag2 { m.extra.flag2 = false; - hit_by_shulker_bullet(m, w, events); + hit_by_shulker_bullet(m, w, level_random, events); } } /// `Shulker.hitByShulkerBullet`: an open shulker teleports, and leaves a /// new one of its colour behind unless shulkers crowd the place (one in /// five fewer chances for every other shulker within 8 blocks). -fn hit_by_shulker_bullet(m: &mut Mob, w: &MobWorld, events: &mut Vec) { +fn hit_by_shulker_bullet( + m: &mut Mob, + w: &MobWorld, + level_random: &mut LegacyRandom, + events: &mut Vec, +) { let old_position = m.position; let old_box = m.bounds(); if m.extra.counter == 0 || !teleport(m, w, events) { @@ -201,7 +211,8 @@ fn hit_by_shulker_bullet(m: &mut Mob, w: &MobWorld, events: &mut Vec) }) .count(); let failure_chance = others as f32 / 5.0; - if m.random.next_float() < failure_chance { + // The level's random, not the shulker's. + if level_random.next_float() < failure_chance { return; } let mut baby = Mob::new(0, m.kind.clone(), old_position, 0.0);