diff --git a/crates/horizon-client/src/game/creatures.rs b/crates/horizon-client/src/game/creatures.rs index e059a7f20..6e33ac8e5 100644 --- a/crates/horizon-client/src/game/creatures.rs +++ b/crates/horizon-client/src/game/creatures.rs @@ -1944,6 +1944,7 @@ impl Game<'_> { let mut hits = Vec::new(); let mut deflections: Vec<[f64; 3]> = Vec::new(); let mut arrow_events = Vec::new(); + let mut trails = Vec::new(); { let mut targets: Vec<(Who, Aabb)> = self .mobs @@ -2035,6 +2036,10 @@ impl Game<'_> { if shooter.is_some() { p.owner = Some(Who::Player); } + // AbstractHurtingProjectile.tick ends with createParticleTrail. + if super::remote_projectiles::has_smoke_trail(&p.kind) { + trails.push(p.position); + } if let Some(a) = p.arrow.as_mut() { arrow_events.extend(a.events.drain(..).map(|e| (p.position, e))); } @@ -2077,6 +2082,7 @@ impl Game<'_> { keep }); } + self.smoke_trails(trails); for at in deflections { self.audio .play("minecraft:entity.breeze.deflect", Some(at), 1.0, 1.0); diff --git a/crates/horizon-client/src/game/remote.rs b/crates/horizon-client/src/game/remote.rs index 0df029cab..663983443 100644 --- a/crates/horizon-client/src/game/remote.rs +++ b/crates/horizon-client/src/game/remote.rs @@ -3577,11 +3577,15 @@ impl Game<'_> { let head_lerps = &mut r.head_lerps; let players = &r.level_players; let mut using = Vec::new(); + let mut wither_heads = Vec::new(); for m in &mut self.mobs { let player = players.contains_key(&(m.id as i32)); if !running && !player { continue; } + if m.species() == horizon_client::mobs::Species::Wither { + wither_heads.extend((0..3).map(|i| horizon_client::mobs::wither::head_pos(m, i))); + } m.previous = m.position; m.previous_yaw = m.yaw; m.previous_body_yaw = m.body_yaw; @@ -3712,6 +3716,19 @@ impl Game<'_> { d.tick(world, facts, collision, false, &self.res.motion().fluids); } head_lerps.retain(|_, (_, steps)| *steps > 0); + // WitherBoss.aiStep runs on a client too: smoke around each head. + let smoke = horizon_client::particles::ParticleOptions::simple( + horizon_client::particles::ParticleType::Smoke, + ); + for h in wither_heads { + let r = self.particles.random(); + let at = [ + h[0] + r.next_gaussian() * 0.3, + h[1] + r.next_gaussian() * 0.3, + h[2] + r.next_gaussian() * 0.3, + ]; + self.particles.add(&smoke, at, [0.0; 3]); + } for (item, ticks, at, eye, pitch, yaw) in using { self.remote_player_eating(&item, ticks, at, eye, pitch, yaw); } diff --git a/crates/horizon-client/src/game/remote_projectiles.rs b/crates/horizon-client/src/game/remote_projectiles.rs index 14dc13545..474c85d70 100644 --- a/crates/horizon-client/src/game/remote_projectiles.rs +++ b/crates/horizon-client/src/game/remote_projectiles.rs @@ -86,7 +86,27 @@ pub(super) fn remote_projectile_tick(p: &mut Projectile, w: &impl ProjectileWorl } } +/// `AbstractHurtingProjectile.getTrailParticle`: smoke for every one of them +/// but the wind charges (no trail) and the dragon's fireball (its own). +pub(super) fn has_smoke_trail(kind: &ProjectileKind) -> bool { + matches!( + kind, + ProjectileKind::SmallFireball + | ProjectileKind::LargeFireball { .. } + | ProjectileKind::WitherSkull { .. } + ) +} + impl Game<'_> { + /// `AbstractHurtingProjectile.createParticleTrail`: one smoke puff half a + /// block above each position. + pub(super) fn smoke_trails(&mut self, at: impl IntoIterator) { + let smoke = ParticleOptions::simple(ParticleType::Smoke); + for p in at { + self.particles.add(&smoke, [p.x, p.y + 0.5, p.z], [0.0; 3]); + } + } + /// `handleAddEntity` for these types; false when `kind` isn't one. pub(super) fn spawn_remote_projectile( &mut self, @@ -360,6 +380,14 @@ impl Game<'_> { } } self.creatures.projectiles = projectiles; + let trails: Vec = self + .creatures + .projectiles + .iter() + .filter(|p| has_smoke_trail(&p.kind)) + .map(|p| p.position) + .collect(); + self.smoke_trails(trails); for t in &mut self.tridents { let id = t.id; t.remote_step(|at| step(id, at)); diff --git a/crates/horizon-client/src/mobs/wither.rs b/crates/horizon-client/src/mobs/wither.rs index 6702686c5..6c3316ac7 100644 --- a/crates/horizon-client/src/mobs/wither.rs +++ b/crates/horizon-client/src/mobs/wither.rs @@ -96,7 +96,7 @@ pub fn make_invulnerable(m: &mut Mob) { pub fn powered(m: &Mob) -> bool { m.health <= m.attrs.max_health / 2.0 } -fn head_pos(m: &Mob, i: usize) -> [f64; 3] { +pub fn head_pos(m: &Mob, i: usize) -> [f64; 3] { if i == 0 { return [m.position.x, m.position.y + 3.0, m.position.z]; }