Fix lag when both a dark vortex and hydrophobic (as well as other combinations) of spells are active at once

This commit is contained in:
Sollace 2024-01-20 16:45:22 +00:00
parent 7b1f5ce0db
commit e017fb1b89
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
3 changed files with 9 additions and 9 deletions

View file

@ -44,9 +44,10 @@ public class AttractiveSpell extends ShieldSpell implements HomingSpell, TimedSp
if (timer.getTicksRemaining() <= 0) {
return false;
}
}
setDirty();
}
target.getOrEmpty(caster.asWorld())
.filter(entity -> entity.distanceTo(caster.asEntity()) > getDrawDropOffRange(caster))
.ifPresent(entity -> {

View file

@ -80,10 +80,7 @@ public class DarkVortexSpell extends AttractiveSpell implements ProjectileDelega
return true;
}
age++;
setDirty();
if (age % 20 == 0) {
if (++age % 20 == 0) {
source.asWorld().playSound(null, source.getOrigin(), USounds.AMBIENT_DARK_VORTEX_ADDITIONS, SoundCategory.AMBIENT, 1, 1);
}
@ -162,7 +159,6 @@ public class DarkVortexSpell extends AttractiveSpell implements ProjectileDelega
applyRadialEffect(source, e, e.getPos().distanceTo(origin), radius);
});
}
setDirty();
});
}
}
@ -221,8 +217,11 @@ public class DarkVortexSpell extends AttractiveSpell implements ProjectileDelega
double massOfTarget = AttractionUtils.getMass(target);
if (massOfTarget != 0) {
accumulatedMass += massOfTarget;
setDirty();
}
target.damage(source.damageOf(UDamageTypes.GAVITY_WELL_RECOIL, source), Integer.MAX_VALUE);
if (!(target instanceof PlayerEntity)) {
target.discard();

View file

@ -136,7 +136,7 @@ public class EffectSync implements SpellContainer, NbtSerialisable {
@SuppressWarnings("unchecked")
private <T extends Spell> Stream<T> read(@Nullable SpellPredicate<T> type, boolean synchronize, boolean sendUpdate) {
if (synchronize && spells.fromNbt(owner.asEntity().getDataTracker().get(param)) && sendUpdate) {
owner.asEntity().getDataTracker().set(param, spells.toNbt());
write();
}
if (type == null) {