Match vanilla wither tick order, underwater checks and gravity

The wither's customServerAiStep (charging, side heads, block breaking,
healing) now runs inside serverAiStep, and aiStep draws the heads' smoke
particle offsets after travel as vanilla does; its steering uses the 0.6F
and Mth.atan2 float maths, and its level-event sounds (shoot, spawn, block
break) no longer draw from its random: MobEvent::LevelEventSound lets the
client pick their pitch. Entity.getGravity is zero while isNoGravity, which
the flying move control sets. Drowned swim with isUnderWater (the previous
tick's eye state, Entity.wasEyeInWater), and the eyes count as in water per
26.3's EntityFluidInteraction (between a water block's bottom and its camera
height) rather than the older 0.11 offset.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-11 19:18:23 +02:00
parent a466af6adc
commit c7a2fbb182
7 changed files with 127 additions and 43 deletions
+13
View File
@@ -595,6 +595,9 @@ pub struct Mob {
pub ai: Box<ai::Ai>,
pub extra: Extra,
pub fluids: living::Fluids,
/// Entity.wasEyeInWater: the eyes were in water before this tick's fluid
/// update (`isUnderWater` reads it).
pub was_eye_in_water: bool,
pub no_gravity: bool,
/// `NoAI`: no goals and no movement.
pub no_ai: bool,
@@ -626,6 +629,15 @@ pub enum MobEvent {
Sound(&'static str, [f64; 3], f32, f32),
/// A sound event id that is not a static string (variant sounds).
SoundId(String, [f64; 3], f32, f32),
/// A level event's sound (`levelEvent`/`globalLevelEvent`): the client
/// plays it with its own random pitch spread (`(a - b) * spread + 1`),
/// nothing is drawn from the mob.
LevelEventSound {
sound: &'static str,
at: [f64; 3],
volume: f32,
spread: f32,
},
AttackPlayer(f32, [f64; 3]),
/// Damage of a given type to the player (guardian lasers, thorns).
DamagePlayer {
@@ -1009,6 +1021,7 @@ impl Mob {
ai: Box::default(),
extra: Extra::default(),
fluids: living::Fluids::default(),
was_eye_in_water: false,
no_gravity: false,
no_ai: false,
silent: false,