From e017fb1b899d27587f74323f18d4599e7e9b3804 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 20 Jan 2024 16:45:22 +0000 Subject: [PATCH] Fix lag when both a dark vortex and hydrophobic (as well as other combinations) of spells are active at once --- .../ability/magic/spell/effect/AttractiveSpell.java | 3 ++- .../ability/magic/spell/effect/DarkVortexSpell.java | 13 ++++++------- .../unicopia/network/datasync/EffectSync.java | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AttractiveSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AttractiveSpell.java index 669411a1..d91970b2 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AttractiveSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AttractiveSpell.java @@ -44,9 +44,10 @@ public class AttractiveSpell extends ShieldSpell implements HomingSpell, TimedSp if (timer.getTicksRemaining() <= 0) { return false; } + + setDirty(); } - setDirty(); target.getOrEmpty(caster.asWorld()) .filter(entity -> entity.distanceTo(caster.asEntity()) > getDrawDropOffRange(caster)) .ifPresent(entity -> { diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DarkVortexSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DarkVortexSpell.java index 9402d692..4e50d13e 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DarkVortexSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DarkVortexSpell.java @@ -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); - accumulatedMass += massOfTarget; - setDirty(); + if (massOfTarget != 0) { + accumulatedMass += massOfTarget; + setDirty(); + } + target.damage(source.damageOf(UDamageTypes.GAVITY_WELL_RECOIL, source), Integer.MAX_VALUE); if (!(target instanceof PlayerEntity)) { target.discard(); diff --git a/src/main/java/com/minelittlepony/unicopia/network/datasync/EffectSync.java b/src/main/java/com/minelittlepony/unicopia/network/datasync/EffectSync.java index f54aebaa..2a4568e9 100644 --- a/src/main/java/com/minelittlepony/unicopia/network/datasync/EffectSync.java +++ b/src/main/java/com/minelittlepony/unicopia/network/datasync/EffectSync.java @@ -136,7 +136,7 @@ public class EffectSync implements SpellContainer, NbtSerialisable { @SuppressWarnings("unchecked") private Stream read(@Nullable SpellPredicate 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) {