From 613b39436fe685c29fd835850eae44852ac52fe7 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sun, 26 Dec 2021 10:50:16 +0200 Subject: [PATCH] Fixed placed spells not functioning correctly and slot.contains not matching delegated spells --- .../ability/magic/spell/AbstractDelegatingSpell.java | 5 +++++ .../unicopia/ability/magic/spell/PlaceableSpell.java | 8 ++++++-- .../unicopia/ability/magic/spell/Spell.java | 9 +++++++++ .../ability/magic/spell/effect/DarkVortexSpell.java | 2 +- .../unicopia/network/datasync/EffectSync.java | 2 +- 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/AbstractDelegatingSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/AbstractDelegatingSpell.java index cbd66661..0e314d9d 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/AbstractDelegatingSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/AbstractDelegatingSpell.java @@ -31,6 +31,11 @@ public abstract class AbstractDelegatingSpell implements ProjectileSpell { protected abstract Collection getDelegates(); + @Override + public boolean equalsOrContains(UUID id) { + return ProjectileSpell.super.equalsOrContains(id) || getDelegates().stream().anyMatch(s -> s.equalsOrContains(id)); + } + @Override public Affinity getAffinity() { return Affinity.NEUTRAL; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/PlaceableSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/PlaceableSpell.java index 50ef1743..5fea4509 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/PlaceableSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/PlaceableSpell.java @@ -79,13 +79,17 @@ public class PlaceableSpell extends AbstractDelegatingSpell { } } - return super.tick(source, Situation.GROUND); - } else if (situation == Situation.GROUND_ENTITY) { + return !isDead(); + } + + if (situation == Situation.GROUND_ENTITY) { particlEffect.ifAbsent(getUuid(), source, spawner -> { spawner.addParticle(new OrientedBillboardParticleEffect(UParticles.MAGIC_RUNES, 90, 0), source.getOriginVector(), Vec3d.ZERO); }).ifPresent(p -> { p.setAttribute(1, spell.getType().getColor()); }); + + return super.tick(source, Situation.GROUND); } return !isDead(); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/Spell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/Spell.java index 7adf2981..ee5b3820 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/Spell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/Spell.java @@ -2,6 +2,8 @@ package com.minelittlepony.unicopia.ability.magic.spell; import java.util.UUID; +import org.spongepowered.include.com.google.common.base.Objects; + import com.minelittlepony.unicopia.ability.magic.Affine; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType; @@ -23,6 +25,13 @@ public interface Spell extends NbtSerialisable, Affine { */ UUID getUuid(); + /** + * Determines whether this spell is a valid surrogate for the given spell's id. + */ + default boolean equalsOrContains(UUID id) { + return Objects.equal(getUuid(), id); + } + /** * Sets this effect as dead. */ 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 2e4380ff..a74dbfd8 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 @@ -42,7 +42,7 @@ public class DarkVortexSpell extends AttractiveSpell { return true; } - if (!source.isClient()) { + if (!source.isClient() && source.getWorld().random.nextInt(200) == 0) { accumulatedMass += 0.001F * (1 + getTraits().get(Trait.STRENGTH, 70, 120) - 70); } 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 e3f38291..41ad2122 100644 --- a/src/main/java/com/minelittlepony/unicopia/network/datasync/EffectSync.java +++ b/src/main/java/com/minelittlepony/unicopia/network/datasync/EffectSync.java @@ -42,7 +42,7 @@ public class EffectSync implements SpellContainer { @Override public boolean contains(UUID id) { - return spells.containsReference(id); + return spells.containsReference(id) || spells.getReferences().anyMatch(s -> s.equalsOrContains(id)); } @Override