diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AttractiveSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AttractiveSpell.java index 20d7893f..c0ef2470 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AttractiveSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AttractiveSpell.java @@ -3,6 +3,7 @@ package com.minelittlepony.unicopia.ability.magic.spell.effect; import java.util.List; import com.minelittlepony.unicopia.ability.magic.Caster; +import com.minelittlepony.unicopia.ability.magic.spell.ProjectileSpell; import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits; import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait; import com.minelittlepony.unicopia.entity.player.Pony; @@ -17,14 +18,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; -public class AttractiveSpell extends ShieldSpell { - public static final SpellTraits DEFAULT_TRAITS = new SpellTraits.Builder() - .with(Trait.FOCUS, 5) - .with(Trait.KNOWLEDGE, 1) - .with(Trait.STRENGTH, 50) - .with(Trait.AIR, 9) - .build(); - +public class AttractiveSpell extends ShieldSpell implements ProjectileSpell { protected AttractiveSpell(SpellType type, SpellTraits traits) { super(type, traits); } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/CatapultSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/CatapultSpell.java index e0278629..2147971b 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/CatapultSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/CatapultSpell.java @@ -3,6 +3,8 @@ package com.minelittlepony.unicopia.ability.magic.spell.effect; import java.util.Optional; import java.util.function.Consumer; +import org.jetbrains.annotations.Nullable; + import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.spell.ProjectileSpell; import com.minelittlepony.unicopia.ability.magic.spell.Situation; @@ -94,7 +96,7 @@ public class CatapultSpell extends AbstractSpell implements ProjectileSpell { } } - static void createBlockEntity(World world, BlockPos bpos, Consumer apply) { + static void createBlockEntity(World world, BlockPos bpos, @Nullable Consumer apply) { Vec3d pos = Vec3d.ofBottomCenter(bpos); FallingBlockEntity e = new FallingBlockEntity(world, pos.x, pos.y, pos.z, world.getBlockState(bpos)); world.removeBlock(bpos, true); @@ -102,7 +104,9 @@ public class CatapultSpell extends AbstractSpell implements ProjectileSpell { e.timeFalling = Integer.MIN_VALUE; e.setHurtEntities(1 + (world.random.nextFloat() * 10), 100); - apply.accept(e); + if (apply != null) { + apply.accept(e); + } world.spawnEntity(e); } } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DarkVortexSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DarkVortexSpell.java new file mode 100644 index 00000000..acc248fa --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DarkVortexSpell.java @@ -0,0 +1,103 @@ +package com.minelittlepony.unicopia.ability.magic.spell.effect; + +import com.minelittlepony.unicopia.ability.magic.Caster; +import com.minelittlepony.unicopia.ability.magic.spell.Situation; +import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits; +import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait; +import com.minelittlepony.unicopia.particle.MagicParticleEffect; +import com.minelittlepony.unicopia.particle.SphereParticleEffect; +import com.minelittlepony.unicopia.util.MagicalDamageSource; +import com.minelittlepony.unicopia.util.PosHelper; +import com.minelittlepony.unicopia.util.shape.Sphere; + +import net.minecraft.entity.Entity; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.explosion.Explosion; + +public class DarkVortexSpell extends AttractiveSpell { + public static final SpellTraits DEFAULT_TRAITS = new SpellTraits.Builder() + .with(Trait.CHAOS, 5) + .with(Trait.KNOWLEDGE, 1) + .with(Trait.STRENGTH, 70) + .with(Trait.DARKNESS, 100) + .build(); + + private int accumulatedMass = 10; + + protected DarkVortexSpell(SpellType type, SpellTraits traits) { + super(type, traits); + } + + @Override + public boolean tick(Caster source, Situation situation) { + if (accumulatedMass > 20) { + Vec3d pos = source.getOriginVector(); + source.getWorld().createExplosion( + source.getMaster(), + MagicalDamageSource.create("super_nova"), + null, + pos.getX(), pos.getY(), pos.getZ(), 17, true, Explosion.DestructionType.DESTROY + ); + return false; + } + return super.tick(source, situation); + } + + @Override + public void generateParticles(Caster source) { + int range = 4 + (source.getLevel().get() * 2); + Vec3d pos = source.getOriginVector(); + + source.spawnParticles(new Sphere(false, range), range * 9, p -> { + source.addParticle(new MagicParticleEffect(getType().getColor()), p, p.subtract(pos)); + }); + + float radius = (float)getDrawDropOffRange(source) / 2; + + particlEffect.ifAbsent(source, spawner -> { + spawner.addParticle(new SphereParticleEffect(getType().getColor(), 0.99F, radius), source.getOriginVector(), Vec3d.ZERO); + }).ifPresent(p -> { + p.attach(source); + p.setAttribute(0, radius); + }); + } + + @Override + public double getDrawDropOffRange(Caster caster) { + return accumulatedMass + (caster.getLevel().get() * 2); + } + + @Override + protected long applyEntities(Caster source) { + PosHelper.getAllInRegionMutable(source.getOrigin(), new Sphere(false, ((int)getDrawDropOffRange(source) / 2F))).forEach(i -> { + CatapultSpell.createBlockEntity(source.getWorld(), i, null); + }); + + return super.applyEntities(source); + } + + @Override + protected void applyRadialEffect(Caster source, Entity target, double distance, double radius) { + + if (distance < 1) { + accumulatedMass += 1 + getTraits().get(Trait.CHAOS, 0, 2); + target.damage(MagicalDamageSource.create("black_hole"), Integer.MAX_VALUE); + } else { + super.applyRadialEffect(source, target, distance, radius); + } + } + + + @Override + public void toNBT(NbtCompound compound) { + super.toNBT(compound); + compound.putInt("accumulatedMass", accumulatedMass); + } + + @Override + public void fromNBT(NbtCompound compound) { + super.fromNBT(compound); + accumulatedMass = compound.getInt("accumulatedMass"); + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/FireSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/FireSpell.java index 1d85dc87..cf842a83 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/FireSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/FireSpell.java @@ -37,6 +37,10 @@ import net.minecraft.world.explosion.Explosion.DestructionType; * Simple fire spell that triggers an effect when used on a block. */ public class FireSpell extends AbstractAreaEffectSpell implements ProjectileSpell { + public static final SpellTraits DEFAULT_TRAITS = new SpellTraits.Builder() + .with(Trait.FIRE, 15) + .build(); + protected FireSpell(SpellType type, SpellTraits traits) { super(type, traits); } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/IceSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/IceSpell.java index 432992f6..392238d4 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/IceSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/IceSpell.java @@ -3,6 +3,7 @@ package com.minelittlepony.unicopia.ability.magic.spell.effect; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.spell.Situation; import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits; +import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait; import com.minelittlepony.unicopia.block.state.StateMaps; import com.minelittlepony.unicopia.particle.ParticleUtils; import com.minelittlepony.unicopia.util.MagicalDamageSource; @@ -27,6 +28,9 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; public class IceSpell extends AbstractSpell { + public static final SpellTraits DEFAULT_TRAITS = new SpellTraits.Builder() + .with(Trait.ICE, 15) + .build(); private final int rad = 3; private final Shape effect_range = new Sphere(false, rad); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/ShieldSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/ShieldSpell.java index 2cf5bca7..971ed3a4 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/ShieldSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/ShieldSpell.java @@ -11,7 +11,6 @@ import com.minelittlepony.unicopia.EquinePredicates; import com.minelittlepony.unicopia.Unicopia; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.spell.Situation; -import com.minelittlepony.unicopia.ability.magic.spell.ProjectileSpell; import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits; import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait; import com.minelittlepony.unicopia.entity.player.Pony; @@ -37,7 +36,13 @@ import net.minecraft.entity.vehicle.BoatEntity; import net.minecraft.sound.SoundEvents; import net.minecraft.util.math.Vec3d; -public class ShieldSpell extends AbstractSpell implements ProjectileSpell { +public class ShieldSpell extends AbstractSpell { + public static final SpellTraits DEFAULT_TRAITS = new SpellTraits.Builder() + .with(Trait.FOCUS, 5) + .with(Trait.KNOWLEDGE, 1) + .with(Trait.STRENGTH, 50) + .with(Trait.AIR, 9) + .build(); protected final ParticleHandle particlEffect = new ParticleHandle(); 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 2e7be221..7eda7047 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 @@ -46,12 +46,13 @@ public final class SpellType implements Affine, SpellPredicate< public static final SpellType CHANGELING_DISGUISE = register("disguise", Affinity.BAD, 0x19E48E, false, ChangelingDisguiseSpell::new); public static final SpellType RAINBOOM = register("rainboom", Affinity.GOOD, 0xBDBDF9, false, JoustingSpell::new); - public static final SpellType FROST = register("frost", Affinity.GOOD, 0xBDBDF9, true, IceSpell::new); - public static final SpellType SCORCH = register("scorch", Affinity.BAD, 0, true, ScorchSpell::new); - public static final SpellType FLAME = register("flame", Affinity.GOOD, 0xFF5D00, true, FireSpell::new); - public static final SpellType INFERNAL = register("infernal", Affinity.BAD, 0xF00F00, true, InfernoSpell::new); - public static final SpellType SHIELD = register("shield", Affinity.NEUTRAL, 0x66CDAA, true, ShieldSpell::new); + public static final SpellType FROST = register("frost", Affinity.GOOD, 0xBDBDF9, true, IceSpell.DEFAULT_TRAITS, IceSpell::new); + public static final SpellType SCORCH = register("scorch", Affinity.BAD, 0, true, ScorchSpell.DEFAULT_TRAITS, ScorchSpell::new); + public static final SpellType FLAME = register("flame", Affinity.GOOD, 0xFF5D00, true, FireSpell.DEFAULT_TRAITS, FireSpell::new); + public static final SpellType INFERNAL = register("infernal", Affinity.BAD, 0xF00F00, true, InfernoSpell.DEFAULT_TRAITS, InfernoSpell::new); + public static final SpellType SHIELD = register("shield", Affinity.NEUTRAL, 0x66CDAA, true, ShieldSpell.DEFAULT_TRAITS, ShieldSpell::new); public static final SpellType VORTEX = register("vortex", Affinity.NEUTRAL, 0x4CDEE7, true, AttractiveSpell.DEFAULT_TRAITS, AttractiveSpell::new); + public static final SpellType DARK_VORTEX = register("dark_vortex", Affinity.BAD, 0, true, DarkVortexSpell.DEFAULT_TRAITS, DarkVortexSpell::new); public static final SpellType NECROMANCY = register("necromancy", Affinity.BAD, 0x8A3A3A, true, NecromancySpell::new); public static final SpellType SIPHONING = register("siphoning", Affinity.NEUTRAL, 0xe308ab, true, SiphoningSpell::new); public static final SpellType REVEALING = register("reveal", Affinity.GOOD, 0x5CE81F, true, RevealingSpell::new);