Reimplemented the vortex

This commit is contained in:
Sollace 2019-02-01 01:07:51 +02:00
parent 634ab607bf
commit 63c51cae64
3 changed files with 51 additions and 1 deletions

View file

@ -31,6 +31,7 @@ public class SpellRegistry {
registerSpell(SpellFire::new);
registerSpell(SpellIce::new);
registerSpell(SpellPortal::new);
registerSpell(SpellVortex::new);
}
public IMagicEffect getSpellFromName(String name) {

View file

@ -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;
}
}

View file

@ -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