Draw the smoke trail behind wither skulls and fireballs, and the wither's head smoke on a client
This commit is contained in:
@@ -1850,6 +1850,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
|
||||
@@ -1941,6 +1942,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)));
|
||||
}
|
||||
@@ -1983,6 +1988,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);
|
||||
|
||||
@@ -3492,11 +3492,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;
|
||||
@@ -3613,6 +3617,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);
|
||||
}
|
||||
|
||||
@@ -78,7 +78,27 @@ fn remote_arrow_tick(p: &mut Projectile, w: &impl ProjectileWorld) {
|
||||
p.velocity.y -= 0.05;
|
||||
}
|
||||
|
||||
/// `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<Item = Vec3>) {
|
||||
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,
|
||||
@@ -350,6 +370,14 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
self.creatures.projectiles = projectiles;
|
||||
let trails: Vec<Vec3> = 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));
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user