From 63c51cae64d7b3bcbd2706134d75d43f83a32506 Mon Sep 17 00:00:00 2001 From: Sollace Date: Fri, 1 Feb 2019 01:07:51 +0200 Subject: [PATCH] Reimplemented the vortex --- .../unicopia/spell/SpellRegistry.java | 1 + .../unicopia/spell/SpellVortex.java | 49 +++++++++++++++++++ .../resources/assets/unicopia/lang/en_US.lang | 2 +- 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/minelittlepony/unicopia/spell/SpellVortex.java diff --git a/src/main/java/com/minelittlepony/unicopia/spell/SpellRegistry.java b/src/main/java/com/minelittlepony/unicopia/spell/SpellRegistry.java index b4f83996..80c0df2e 100644 --- a/src/main/java/com/minelittlepony/unicopia/spell/SpellRegistry.java +++ b/src/main/java/com/minelittlepony/unicopia/spell/SpellRegistry.java @@ -31,6 +31,7 @@ public class SpellRegistry { registerSpell(SpellFire::new); registerSpell(SpellIce::new); registerSpell(SpellPortal::new); + registerSpell(SpellVortex::new); } public IMagicEffect getSpellFromName(String name) { diff --git a/src/main/java/com/minelittlepony/unicopia/spell/SpellVortex.java b/src/main/java/com/minelittlepony/unicopia/spell/SpellVortex.java new file mode 100644 index 00000000..97cf2464 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/spell/SpellVortex.java @@ -0,0 +1,49 @@ +package com.minelittlepony.unicopia.spell; + +import com.minelittlepony.unicopia.UParticles; +import com.minelittlepony.unicopia.particle.Particles; +import com.minelittlepony.unicopia.player.PlayerSpeciesList; +import com.minelittlepony.util.shape.Sphere; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.math.Vec3d; + +public class SpellVortex extends SpellShield { + + @Override + public String getName() { + return "vortex"; + } + + @Override + protected void spawnParticles(ICaster source, int strength) { + Vec3d pos = source.getOriginVector(); + + source.spawnParticles(new Sphere(false, strength), strength * 9, p -> { + Particles.instance().spawnParticle(UParticles.MAGIC_PARTICLE, false, p, p.subtract(pos)); + }); + } + + @Override + protected void applyRadialEffect(ICaster source, Entity target, double distance, double radius) { + Vec3d pos = source.getOriginVector(); + + double force = 4 / distance; + + if (source.getAffinity() != SpellAffinity.BAD && target instanceof EntityPlayer) { + force *= calculateAdjustedForce(PlayerSpeciesList.instance().getPlayer((EntityPlayer)target)); + } + + applyForce(pos, target, -force, 0); + + float maxVel = source.getAffinity() != SpellAffinity.BAD ? 1.6f : 1; + + if (target.motionX > maxVel) target.motionX = maxVel; + if (target.motionX < -maxVel) target.motionX = -maxVel; + if (target.motionY > maxVel) target.motionY = maxVel; + if (target.motionY < -maxVel) target.motionY = -maxVel; + if (target.motionZ > maxVel) target.motionZ = maxVel; + if (target.motionZ < -maxVel) target.motionZ = -maxVel; + } +} diff --git a/src/main/resources/assets/unicopia/lang/en_US.lang b/src/main/resources/assets/unicopia/lang/en_US.lang index d59c0ac7..27bdd8f4 100644 --- a/src/main/resources/assets/unicopia/lang/en_US.lang +++ b/src/main/resources/assets/unicopia/lang/en_US.lang @@ -34,7 +34,7 @@ spell.fire.name=Flame spell.infero.name=Burning spell.ice.name=Frost spell.portal.name=Transportation -spell.attract.name=Retention +spell.vortex.name=Retention spell.minion.name=Obedience curse.shield.name=Repulsion