Keep hideParticles of mob effects: no swirls drawn or sent for them
This commit is contained in:
@@ -81,6 +81,7 @@ impl Game<'_> {
|
||||
.extra
|
||||
.effects
|
||||
.iter()
|
||||
.filter(|e| !m.extra.hidden_effects.contains(&e.0))
|
||||
.filter_map(|e| effect_particle(e.0, false))
|
||||
.collect();
|
||||
swirl(
|
||||
|
||||
@@ -91,7 +91,12 @@ impl Game<'_> {
|
||||
}
|
||||
Target::Mob(id) => match self.mobs.iter_mut().find(|m| m.id == id) {
|
||||
Some(m) => {
|
||||
m.add_effect(namespaced(effect.id), duration, amplifier);
|
||||
let name = namespaced(effect.id);
|
||||
m.add_effect(name, duration, amplifier);
|
||||
m.extra.hidden_effects.retain(|h| *h != name);
|
||||
if !particles {
|
||||
m.extra.hidden_effects.push(name);
|
||||
}
|
||||
true
|
||||
}
|
||||
None => false,
|
||||
@@ -154,6 +159,10 @@ impl Game<'_> {
|
||||
m.extra
|
||||
.effects
|
||||
.retain(|x| e.is_some_and(|e| x.0 != namespaced(e.id)));
|
||||
let left = &m.extra.effects;
|
||||
m.extra
|
||||
.hidden_effects
|
||||
.retain(|h| left.iter().any(|x| x.0 == *h));
|
||||
m.extra.effects.len() != before
|
||||
}
|
||||
None => false,
|
||||
|
||||
@@ -180,7 +180,13 @@ fn mob_meta(
|
||||
defaults.push((9, serializer::FLOAT, Value::Float(1.0)));
|
||||
// LivingEntity.DATA_EFFECT_PARTICLES and DATA_EFFECT_AMBIENCE_ID: the
|
||||
// swirls of its effects (the ones a mob has are visible, not ambient).
|
||||
meta.extend(hub.effect_meta(m.extra.effects.iter().map(|e| (e.0, false))));
|
||||
meta.extend(
|
||||
hub.effect_meta(
|
||||
(m.extra.effects.iter())
|
||||
.filter(|e| !m.extra.hidden_effects.contains(&e.0))
|
||||
.map(|e| (e.0, false)),
|
||||
),
|
||||
);
|
||||
defaults.push((10, serializer::PARTICLES, Value::Particles(Vec::new())));
|
||||
defaults.push((11, serializer::BOOLEAN, Value::Bool(false)));
|
||||
// Mob.DATA_MOB_FLAGS_ID: no AI 1, left-handed 2, aggressive 4 (what
|
||||
|
||||
@@ -715,6 +715,8 @@ pub struct Extra {
|
||||
pub vector: [f64; 3],
|
||||
/// Active status effects: (effect id, ticks left, amplifier).
|
||||
pub effects: Vec<(&'static str, i32, i32)>,
|
||||
/// The effects above given with `hideParticles`: no swirls for them.
|
||||
pub hidden_effects: Vec<&'static str>,
|
||||
/// `LivingEntity.DATA_EFFECT_PARTICLES` and `DATA_EFFECT_AMBIENCE_ID` as a
|
||||
/// server gave them: the swirls around it, and whether they are all faint.
|
||||
pub effect_particles: Vec<crate::particles::ParticleOptions>,
|
||||
|
||||
@@ -1488,6 +1488,9 @@ fn tick_effects(m: &mut Mob) {
|
||||
*ticks -= 1;
|
||||
}
|
||||
effects.retain(|e| e.1 > 0);
|
||||
m.extra
|
||||
.hidden_effects
|
||||
.retain(|h| effects.iter().any(|e| e.0 == *h));
|
||||
m.extra.effects = effects;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user