Merge pull request #2606 from socksprox/t3/fix-zombie-stuck-flowing-water

🤖 Agent: verified by Ludovic's AI agent (contrib gate 20): jumpOutOfFluid needs a dry box and no collidable entity (Entity.isFree). It passed in this wave's union with main on the Mac mini: the selected parity harnesses (332/332, then 122/122 on the final union), clippy -D warnings and the tests, and lan_e2e with the host on its server thread and in-frame (18/18 each). Thanks @socksprox!
This commit is contained in:
Ludovic Marie
2026-10-27 08:46:43 +01:00
committed by GitHub
+36 -6
View File
@@ -235,6 +235,26 @@ impl MobWorld<'_> {
};
scene.unobstructed(b).unwrap_or(false)
}
/// `LevelReader.containsAnyLiquid`: the blocks from the box's minimum
/// corner to the block holding its maximum corner.
pub fn contains_any_liquid(&self, b: Aabb) -> bool {
let (lo, hi) = (b.min_position(), b.max_position());
let (x0, y0, z0) = (
lo.x.floor() as i32,
lo.y.floor() as i32,
lo.z.floor() as i32,
);
let (x1, y1, z1) = (
hi.x.floor() as i32,
hi.y.floor() as i32,
hi.z.floor() as i32,
);
(x0..=x1).any(|x| {
(y0..=y1).any(|y| {
(z0..=z1).any(|z| self.facts.get(self.world.block(x, y, z)).fluid != Fluid::None)
})
})
}
}
impl Mob {
/// `Entity.refreshDimensions` after growing from `old_w` by `old_h`:
@@ -813,14 +833,24 @@ impl Mob {
self.velocity.y -= gravity / 4.0;
}
}
// jumpOutOfFluid
// jumpOutOfFluid: Entity.isFree wants the box dry and clear of the
// entities a mob collides with (canBeCollidedWith: living shulkers).
let m = self.velocity;
let ahead = self.bounds().move_by(Vec3::new(
m.x,
m.y + f64::from(0.6_f32) - self.position.y + old_y,
m.z,
));
let wide = ahead.inflate(Vec3::new(1.0e-7, 1.0e-7, 1.0e-7));
if self.horizontal_collision
&& w.no_collision(self.bounds().move_by(Vec3::new(
m.x,
m.y + f64::from(0.6_f32) - self.position.y + old_y,
m.z,
)))
&& w.no_collision(ahead)
&& !w.contains_any_liquid(ahead)
&& !w.others_near(wide).any(|s| {
s.id != self.id
&& s.alive
&& s.species == super::Species::Shulker
&& s.bounds.intersects(wide)
})
{
self.velocity.y = f64::from(0.3_f32);
}