Fixed postal spells

This commit is contained in:
Sollace 2019-02-21 19:18:47 +02:00
parent a0fa404767
commit 600d9f7ce9

View file

@ -83,6 +83,8 @@ public class SpellPortal extends AbstractSpell.RangedAreaSpell implements IUseAc
getDestinationPortal().ifPresent(IMagicEffect::setDead); getDestinationPortal().ifPresent(IMagicEffect::setDead);
} }
private SpellPortal bridge;
@Override @Override
public void onPlaced(ICaster<?> caster) { public void onPlaced(ICaster<?> caster) {
world = caster.getWorld(); world = caster.getWorld();
@ -93,6 +95,10 @@ public class SpellPortal extends AbstractSpell.RangedAreaSpell implements IUseAc
sibling.destinationId = casterId; sibling.destinationId = casterId;
sibling.destinationPos = position; sibling.destinationPos = position;
} }
if (bridge != null) {
bridge.onPlaced(caster);
}
} }
@Override @Override
@ -102,16 +108,18 @@ public class SpellPortal extends AbstractSpell.RangedAreaSpell implements IUseAc
IPlayer prop = PlayerSpeciesList.instance().getPlayer(player); IPlayer prop = PlayerSpeciesList.instance().getPlayer(player);
IMagicEffect other = prop.getEffect(); SpellPortal other = prop.getEffect(SpellPortal.class, true);
if (other instanceof SpellPortal && other != this && !other.getDead()) { if (other != null) {
((SpellPortal)other).getActualInstance().setDestinationPortal(this); other.getActualInstance().setDestinationPortal(this);
if (!world.isRemote) { if (!world.isRemote) {
prop.setEffect(null); prop.setEffect(null);
} }
} else { } else {
if (!world.isRemote) { if (!world.isRemote) {
prop.setEffect(this); bridge = (SpellPortal)copy();
prop.setEffect(bridge);
} }
} }