From 600d9f7ce9501217269f29a4f38d89484d74a2b3 Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 21 Feb 2019 19:18:47 +0200 Subject: [PATCH] Fixed postal spells --- .../unicopia/spell/SpellPortal.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/spell/SpellPortal.java b/src/main/java/com/minelittlepony/unicopia/spell/SpellPortal.java index e6ed2a24..206beb2c 100644 --- a/src/main/java/com/minelittlepony/unicopia/spell/SpellPortal.java +++ b/src/main/java/com/minelittlepony/unicopia/spell/SpellPortal.java @@ -83,6 +83,8 @@ public class SpellPortal extends AbstractSpell.RangedAreaSpell implements IUseAc getDestinationPortal().ifPresent(IMagicEffect::setDead); } + private SpellPortal bridge; + @Override public void onPlaced(ICaster caster) { world = caster.getWorld(); @@ -93,6 +95,10 @@ public class SpellPortal extends AbstractSpell.RangedAreaSpell implements IUseAc sibling.destinationId = casterId; sibling.destinationPos = position; } + + if (bridge != null) { + bridge.onPlaced(caster); + } } @Override @@ -102,16 +108,18 @@ public class SpellPortal extends AbstractSpell.RangedAreaSpell implements IUseAc IPlayer prop = PlayerSpeciesList.instance().getPlayer(player); - IMagicEffect other = prop.getEffect(); - if (other instanceof SpellPortal && other != this && !other.getDead()) { - ((SpellPortal)other).getActualInstance().setDestinationPortal(this); + SpellPortal other = prop.getEffect(SpellPortal.class, true); + if (other != null) { + other.getActualInstance().setDestinationPortal(this); if (!world.isRemote) { prop.setEffect(null); } } else { if (!world.isRemote) { - prop.setEffect(this); + bridge = (SpellPortal)copy(); + + prop.setEffect(bridge); } }