From 4aa7838d1ba0434d8f5de4b0b0267b2698dd08e4 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 14:27:48 +0100 Subject: [PATCH 1/3] Shulker bullets make open shulkers teleport and duplicate An open shulker hit by a shulker bullet teleports and may leave a new shulker of its colour behind, like Shulker.hitByShulkerBullet. Levitation from the bullet now needs the hit to have hurt the player. --- crates/horizon-client/src/game/creatures.rs | 10 +++-- crates/horizon-client/src/mobs/shulker.rs | 41 ++++++++++++++++++++- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/crates/horizon-client/src/game/creatures.rs b/crates/horizon-client/src/game/creatures.rs index 194256040..18b5cd9fd 100644 --- a/crates/horizon-client/src/game/creatures.rs +++ b/crates/horizon-client/src/game/creatures.rs @@ -2364,12 +2364,14 @@ impl Game<'_> { // ShulkerBullet.onHitEntity: 4 damage, then levitation for 10 s. (ProjectileKind::ShulkerBullet { .. }, Hit::Entity { who, .. }) => match who { Who::Player => { - if !self.creative { - self.mob_hits_player( + // Only a hit that hurt (`wasHurt`) brings the levitation. + if !self.creative + && self.mob_hits_player( 4.0, [p.previous.x, p.previous.y, p.previous.z], "minecraft:mob_projectile", - ); + ) + { self.give_player_effect("minecraft:levitation", 200, 0); } } @@ -2378,6 +2380,8 @@ impl Game<'_> { && m.damage(4.0, source) { m.extra.levitation = 200; + // Shulker.hurtServer: a shulker hit by a bullet. + horizon_client::mobs::shulker::hit_by_bullet(m); } } }, diff --git a/crates/horizon-client/src/mobs/shulker.rs b/crates/horizon-client/src/mobs/shulker.rs index 11ebdadb4..ccb33fd24 100644 --- a/crates/horizon-client/src/mobs/shulker.rs +++ b/crates/horizon-client/src/mobs/shulker.rs @@ -3,7 +3,7 @@ //! their face is lost or when badly hurt, and shrugging off arrows while //! closed. use super::{ - Damage, DamageKind, Mob, MobEvent, MobWorld, Who, + Damage, DamageKind, Mob, MobEvent, MobWorld, Species, Who, anim::{Poses, State}, goals::{ Cx, Goal, HurtByTarget, LOOK, LookAtPlayer, MOVE, NearestTarget, RandomLookAround, @@ -164,12 +164,49 @@ pub fn after_hurt(m: &mut Mob) { m.extra.flag = true; } } -/// The deferred teleport of `after_hurt`. +/// `Shulker.hurtServer` after a shulker bullet's damage: unless the +/// low-health teleport was drawn instead (`else if`), `hitByShulkerBullet` +/// runs on the next tick. +pub fn hit_by_bullet(m: &mut Mob) { + if m.species() == Species::Shulker && !m.extra.flag { + m.extra.flag2 = true; + } +} +/// The deferred teleport of `after_hurt` and `hitByShulkerBullet`. pub fn ai_step(m: &mut Mob, w: &MobWorld, 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); + } +} +/// `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) { + let old_position = m.position; + let old_box = m.bounds(); + if m.extra.counter == 0 || !teleport(m, w, events) { + return; + } + let area = old_box.inflate(Vec3::new(8.0, 8.0, 8.0)); + // The shulker itself stands within reach of its old box, so it counts. + let others = w + .others_near(area) + .filter(|s| { + s.alive && s.species == Species::Shulker && s.id != m.id && s.bounds.intersects(area) + }) + .count(); + let failure_chance = others as f32 / 5.0; + if m.random.next_float() < failure_chance { + return; + } + let mut baby = Mob::new(0, m.kind.clone(), old_position, 0.0); + baby.extra.color = m.extra.color; + events.push(MobEvent::Spawn(Box::new(baby))); } /// A ProjectileWorld over the mob world, for aiming a new bullet. struct Probe<'a, 'w> { From 7fbfbb5e2b16640613c14601caaeb367676c1216 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Mon, 26 Oct 2026 15:27:12 +0100 Subject: [PATCH 2/3] Shulker bullet split: draw the failure chance from the level's random Shulker.hitByShulkerBullet tests level().getRandom().nextFloat() against the crowding chance, not the shulker's own random. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/mobs/ai.rs | 11 ++++++++--- crates/horizon-client/src/mobs/shulker.rs | 21 ++++++++++++++++----- 2 files changed, 24 insertions(+), 8 deletions(-) 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); From d7ec7b6077b73fa0159597d5f8ebdbf057701978 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 18:55:45 +0100 Subject: [PATCH 3/3] Shulker bullet split: record whether the shell was open at hit time --- crates/horizon-client/src/mobs/shulker.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/horizon-client/src/mobs/shulker.rs b/crates/horizon-client/src/mobs/shulker.rs index 124d1b299..6f0edc2d7 100644 --- a/crates/horizon-client/src/mobs/shulker.rs +++ b/crates/horizon-client/src/mobs/shulker.rs @@ -166,9 +166,10 @@ pub fn after_hurt(m: &mut Mob) { } /// `Shulker.hurtServer` after a shulker bullet's damage: unless the /// low-health teleport was drawn instead (`else if`), `hitByShulkerBullet` -/// runs on the next tick. +/// runs on the next tick. Whether the shell is open is read here, at hurt +/// time, so a goal opening it before that tick cannot change the outcome. pub fn hit_by_bullet(m: &mut Mob) { - if m.species() == Species::Shulker && !m.extra.flag { + if m.species() == Species::Shulker && !m.extra.flag && m.extra.counter != 0 { m.extra.flag2 = true; } } @@ -188,9 +189,10 @@ pub fn ai_step( 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). +/// `Shulker.hitByShulkerBullet` (only queued by an open shulker): it +/// 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, @@ -199,7 +201,7 @@ fn hit_by_shulker_bullet( ) { let old_position = m.position; let old_box = m.bounds(); - if m.extra.counter == 0 || !teleport(m, w, events) { + if !teleport(m, w, events) { return; } let area = old_box.inflate(Vec3::new(8.0, 8.0, 8.0));