Throw a burst of spit particles when a llama spits

This commit is contained in:
Kacpherek
2026-10-26 19:58:51 +01:00
parent 46150ba08c
commit 29eae3a1af
3 changed files with 21 additions and 0 deletions
@@ -1013,6 +1013,11 @@ impl Game<'_> {
self.next_entity += 1;
p.id = self.next_entity;
let (owner, at) = (p.owner, [p.position.x, p.position.y, p.position.z]);
// LlamaSpit.recreateFromPacket: the spit's burst on the client.
if p.kind == ProjectileKind::LlamaSpit {
let v = p.velocity;
self.particles.llama_spit_burst(at, [v.x, v.y, v.z]);
}
self.creatures.projectiles.push(p);
self.projectile_event("minecraft:projectile_shoot", owner, at);
}
@@ -161,6 +161,10 @@ impl Game<'_> {
let Some(k) = projectile_kind(kind) else {
return false;
};
if k == ProjectileKind::LlamaSpit {
self.particles
.llama_spit_burst(position, [velocity.x, velocity.y, velocity.z]);
}
let mut p = Projectile::new(k, at, None);
p.id = id;
p.velocity = velocity;
+12
View File
@@ -1398,6 +1398,18 @@ impl ParticleEngine {
self.add(&ParticleOptions::simple(ty), center, [1.0, 0.0, 0.0]);
self.explosion_blocks(center, radius, block_count, is_air);
}
/// `LlamaSpit.recreateFromPacket`: seven spit particles thrown ahead of a
/// new spit, each faster than the last along x and z.
pub fn llama_spit_burst(&mut self, at: [f64; 3], movement: [f64; 3]) {
for i in 0..7 {
let k = 0.4 + 0.1 * f64::from(i);
self.add(
&ParticleOptions::simple(ParticleType::Spit),
at,
[movement[0] * k, movement[1], movement[2] * k],
);
}
}
/// `ClientExplosionTracker` with `Level.DEFAULT_EXPLOSION_BLOCK_PARTICLES`.
pub fn explosion_blocks(
&mut self,