diff --git a/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java index 935f297c..fd7bafad 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java @@ -179,7 +179,7 @@ public class UnicornTeleportAbility implements Ability { destination.z() + offset.getZ() ); - participant.setPosition(dest); + participant.requestTeleport(dest.x, dest.y, dest.z); if (participant.getWorld().getBlockCollisions(participant, participant.getBoundingBox()).iterator().hasNext()) { dest = destination.vec(); participant.requestTeleport(dest.x, participant.getY(), dest.z); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DisplacementSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DisplacementSpell.java index 5382fb0c..08336123 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DisplacementSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DisplacementSpell.java @@ -89,13 +89,22 @@ public class DisplacementSpell extends AbstractSpell implements HomingSpell, Pro Vec3d sourcePos = originator.getOriginVector(); Vec3d sourceVel = originator.asEntity().getVelocity(); - teleport(originator, target, sourcePos, sourceVel); - teleport(originator, originator.asEntity(), destinationPos, destinationVel); + Entity targetVehicle = teleport(originator, target, sourcePos, sourceVel); + Entity sourceVehicle = teleport(originator, originator.asEntity(), destinationPos, destinationVel); + + if (targetVehicle != null) { + originator.asEntity().startRiding(targetVehicle); + } + if (sourceVehicle != null) { + target.startRiding(sourceVehicle); + } + originator.subtractEnergyCost(destinationPos.distanceTo(sourcePos) / 20F); } - private void teleport(Caster source, Entity entity, Vec3d pos, Vec3d vel) { - entity.setPosition(pos); + private Entity teleport(Caster source, Entity entity, Vec3d pos, Vec3d vel) { + Entity oldVehicle = entity.getVehicle(); + entity.requestTeleportAndDismount(pos.x, pos.y, pos.z); entity.setVelocity(vel); entity.setGlowing(false); entity.playSound(USounds.SPELL_DISPLACEMENT_TELEPORT, 1, 1); @@ -104,6 +113,7 @@ public class DisplacementSpell extends AbstractSpell implements HomingSpell, Pro if (damage > 0) { entity.damage(source.damageOf(UDamageTypes.EXHAUSTION, source), damage); } + return oldVehicle; } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/MindSwapSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/MindSwapSpell.java index bea32dec..eeca0e00 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/MindSwapSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/MindSwapSpell.java @@ -277,14 +277,3 @@ public class MindSwapSpell extends MimicSpell implements ProjectileDelegate.Enti return clone; } } - - - - - - - - - - -