From 38fb168ac00b92f5710ab4538b0ee61e5d9988a5 Mon Sep 17 00:00:00 2001 From: Sollace Date: Wed, 17 May 2023 20:23:48 +0100 Subject: [PATCH] Added the dispel evil spell --- .../magic/spell/effect/DispellEvilSpell.java | 54 +++++++++++++++++++ .../ability/magic/spell/effect/SpellType.java | 1 + .../resources/assets/unicopia/lang/en_us.json | 2 + 3 files changed, 57 insertions(+) create mode 100644 src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DispellEvilSpell.java diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DispellEvilSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DispellEvilSpell.java new file mode 100644 index 00000000..db71768f --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DispellEvilSpell.java @@ -0,0 +1,54 @@ +package com.minelittlepony.unicopia.ability.magic.spell.effect; + +import com.minelittlepony.unicopia.ability.magic.Caster; +import com.minelittlepony.unicopia.ability.magic.spell.*; +import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits; +import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait; +import com.minelittlepony.unicopia.particle.UParticles; +import com.minelittlepony.unicopia.projectile.MagicProjectileEntity; +import com.minelittlepony.unicopia.projectile.ProjectileDelegate; +import com.minelittlepony.unicopia.util.MagicalDamageSource; + +import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; +import net.minecraft.util.math.Vec3d; + +public class DispellEvilSpell extends AbstractSpell implements ProjectileDelegate.HitListener { + public static final SpellTraits DEFAULT_TRAITS = new SpellTraits.Builder() + .with(Trait.POWER, 10) + .build(); + + protected DispellEvilSpell(CustomisedSpellType type) { + super(type); + } + + @Override + public boolean tick(Caster source, Situation situation) { + if (situation == Situation.PROJECTILE) { + return !isDead(); + } + + source.findAllEntitiesInRange(getTraits().get(Trait.POWER) * 10, e -> e.getType() == EntityType.PHANTOM).forEach(entity -> { + entity.damage(MagicalDamageSource.MAGIC, 50); + if (entity instanceof LivingEntity l) { + double d = source.getOriginVector().getX() - entity.getX(); + double e = source.getOriginVector().getZ() - entity.getZ(); + while (d * d + e * e < 1.0E-4) { + d = (Math.random() - Math.random()) * 0.01; + e = (Math.random() - Math.random()) * 0.01; + } + l.takeKnockback(1, d, e); + } + + source.addParticle(UParticles.LIGHTNING_BOLT, entity.getPos(), Vec3d.ZERO); + }); + source.subtractEnergyCost(1000); + + return false; + } + + @Override + public void onImpact(MagicProjectileEntity projectile) { + tick(projectile, Situation.GROUND); + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/SpellType.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/SpellType.java index 58b1458a..53dfc899 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/SpellType.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/SpellType.java @@ -73,6 +73,7 @@ public final class SpellType implements Affine, SpellPredicate< public static final SpellType MIND_SWAP = register("mind_swap", Affinity.BAD, 0xF9FF99, true, SpellTraits.EMPTY, MindSwapSpell::new); public static final SpellType HYDROPHOBIC = register("hydrophobic", Affinity.NEUTRAL, 0xF999FF, true, SpellTraits.EMPTY, s -> new HydrophobicSpell(s, FluidTags.WATER)); public static final SpellType BUBBLE = register("bubble", Affinity.NEUTRAL, 0xF999FF, true, BubbleSpell.DEFAULT_TRAITS, BubbleSpell::new); + public static final SpellType DISPEL_EVIL = register("dispel_evil", Affinity.GOOD, 0x00FF00, true, DispellEvilSpell.DEFAULT_TRAITS, DispellEvilSpell::new); public static void bootstrap() {} diff --git a/src/main/resources/assets/unicopia/lang/en_us.json b/src/main/resources/assets/unicopia/lang/en_us.json index 4c0c1c45..48e0f660 100644 --- a/src/main/resources/assets/unicopia/lang/en_us.json +++ b/src/main/resources/assets/unicopia/lang/en_us.json @@ -247,6 +247,8 @@ "spell.unicopia.feather_fall.lore": "Slows the descent of the caster and surrounding allies", "spell.unicopia.catapult": "Catapult", "spell.unicopia.catapult.lore": "Grabs a nearby block or entity and throws it into the air", + "spell.unicopia.dispel_evil": "Dispel Evil", + "spell.unicopia.dispel_evil.lore": "Casts away any nearby unearthly forces.", "gui.unicopia.trait.label": "Element of %s", "gui.unicopia.trait.group": "\n %s",