mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-12-01 00:37:59 +01:00
Added dark vortex spell and add default traits to more spells
This commit is contained in:
parent
996181c097
commit
3806799cf2
7 changed files with 132 additions and 17 deletions
|
@ -3,6 +3,7 @@ package com.minelittlepony.unicopia.ability.magic.spell.effect;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
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.SpellTraits;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait;
|
import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
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.MathHelper;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
public class AttractiveSpell extends ShieldSpell {
|
public class AttractiveSpell extends ShieldSpell implements ProjectileSpell {
|
||||||
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 AttractiveSpell(SpellType<?> type, SpellTraits traits) {
|
protected AttractiveSpell(SpellType<?> type, SpellTraits traits) {
|
||||||
super(type, traits);
|
super(type, traits);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ package com.minelittlepony.unicopia.ability.magic.spell.effect;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.ProjectileSpell;
|
import com.minelittlepony.unicopia.ability.magic.spell.ProjectileSpell;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.Situation;
|
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<Entity> apply) {
|
static void createBlockEntity(World world, BlockPos bpos, @Nullable Consumer<Entity> apply) {
|
||||||
Vec3d pos = Vec3d.ofBottomCenter(bpos);
|
Vec3d pos = Vec3d.ofBottomCenter(bpos);
|
||||||
FallingBlockEntity e = new FallingBlockEntity(world, pos.x, pos.y, pos.z, world.getBlockState(bpos));
|
FallingBlockEntity e = new FallingBlockEntity(world, pos.x, pos.y, pos.z, world.getBlockState(bpos));
|
||||||
world.removeBlock(bpos, true);
|
world.removeBlock(bpos, true);
|
||||||
|
@ -102,7 +104,9 @@ public class CatapultSpell extends AbstractSpell implements ProjectileSpell {
|
||||||
e.timeFalling = Integer.MIN_VALUE;
|
e.timeFalling = Integer.MIN_VALUE;
|
||||||
e.setHurtEntities(1 + (world.random.nextFloat() * 10), 100);
|
e.setHurtEntities(1 + (world.random.nextFloat() * 10), 100);
|
||||||
|
|
||||||
|
if (apply != null) {
|
||||||
apply.accept(e);
|
apply.accept(e);
|
||||||
|
}
|
||||||
world.spawnEntity(e);
|
world.spawnEntity(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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");
|
||||||
|
}
|
||||||
|
}
|
|
@ -37,6 +37,10 @@ import net.minecraft.world.explosion.Explosion.DestructionType;
|
||||||
* Simple fire spell that triggers an effect when used on a block.
|
* Simple fire spell that triggers an effect when used on a block.
|
||||||
*/
|
*/
|
||||||
public class FireSpell extends AbstractAreaEffectSpell implements ProjectileSpell {
|
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) {
|
protected FireSpell(SpellType<?> type, SpellTraits traits) {
|
||||||
super(type, traits);
|
super(type, traits);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.Caster;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.Situation;
|
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.SpellTraits;
|
||||||
|
import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait;
|
||||||
import com.minelittlepony.unicopia.block.state.StateMaps;
|
import com.minelittlepony.unicopia.block.state.StateMaps;
|
||||||
import com.minelittlepony.unicopia.particle.ParticleUtils;
|
import com.minelittlepony.unicopia.particle.ParticleUtils;
|
||||||
import com.minelittlepony.unicopia.util.MagicalDamageSource;
|
import com.minelittlepony.unicopia.util.MagicalDamageSource;
|
||||||
|
@ -27,6 +28,9 @@ import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class IceSpell extends AbstractSpell {
|
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 int rad = 3;
|
||||||
private final Shape effect_range = new Sphere(false, rad);
|
private final Shape effect_range = new Sphere(false, rad);
|
||||||
|
|
|
@ -11,7 +11,6 @@ import com.minelittlepony.unicopia.EquinePredicates;
|
||||||
import com.minelittlepony.unicopia.Unicopia;
|
import com.minelittlepony.unicopia.Unicopia;
|
||||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.Situation;
|
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.SpellTraits;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait;
|
import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
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.sound.SoundEvents;
|
||||||
import net.minecraft.util.math.Vec3d;
|
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();
|
protected final ParticleHandle particlEffect = new ParticleHandle();
|
||||||
|
|
||||||
|
|
|
@ -46,12 +46,13 @@ public final class SpellType<T extends Spell> implements Affine, SpellPredicate<
|
||||||
public static final SpellType<AbstractDisguiseSpell> CHANGELING_DISGUISE = register("disguise", Affinity.BAD, 0x19E48E, false, ChangelingDisguiseSpell::new);
|
public static final SpellType<AbstractDisguiseSpell> CHANGELING_DISGUISE = register("disguise", Affinity.BAD, 0x19E48E, false, ChangelingDisguiseSpell::new);
|
||||||
public static final SpellType<JoustingSpell> RAINBOOM = register("rainboom", Affinity.GOOD, 0xBDBDF9, false, JoustingSpell::new);
|
public static final SpellType<JoustingSpell> RAINBOOM = register("rainboom", Affinity.GOOD, 0xBDBDF9, false, JoustingSpell::new);
|
||||||
|
|
||||||
public static final SpellType<IceSpell> FROST = register("frost", Affinity.GOOD, 0xBDBDF9, true, IceSpell::new);
|
public static final SpellType<IceSpell> FROST = register("frost", Affinity.GOOD, 0xBDBDF9, true, IceSpell.DEFAULT_TRAITS, IceSpell::new);
|
||||||
public static final SpellType<ScorchSpell> SCORCH = register("scorch", Affinity.BAD, 0, true, ScorchSpell::new);
|
public static final SpellType<ScorchSpell> SCORCH = register("scorch", Affinity.BAD, 0, true, ScorchSpell.DEFAULT_TRAITS, ScorchSpell::new);
|
||||||
public static final SpellType<FireSpell> FLAME = register("flame", Affinity.GOOD, 0xFF5D00, true, FireSpell::new);
|
public static final SpellType<FireSpell> FLAME = register("flame", Affinity.GOOD, 0xFF5D00, true, FireSpell.DEFAULT_TRAITS, FireSpell::new);
|
||||||
public static final SpellType<InfernoSpell> INFERNAL = register("infernal", Affinity.BAD, 0xF00F00, true, InfernoSpell::new);
|
public static final SpellType<InfernoSpell> INFERNAL = register("infernal", Affinity.BAD, 0xF00F00, true, InfernoSpell.DEFAULT_TRAITS, InfernoSpell::new);
|
||||||
public static final SpellType<ShieldSpell> SHIELD = register("shield", Affinity.NEUTRAL, 0x66CDAA, true, ShieldSpell::new);
|
public static final SpellType<ShieldSpell> SHIELD = register("shield", Affinity.NEUTRAL, 0x66CDAA, true, ShieldSpell.DEFAULT_TRAITS, ShieldSpell::new);
|
||||||
public static final SpellType<AttractiveSpell> VORTEX = register("vortex", Affinity.NEUTRAL, 0x4CDEE7, true, AttractiveSpell.DEFAULT_TRAITS, AttractiveSpell::new);
|
public static final SpellType<AttractiveSpell> VORTEX = register("vortex", Affinity.NEUTRAL, 0x4CDEE7, true, AttractiveSpell.DEFAULT_TRAITS, AttractiveSpell::new);
|
||||||
|
public static final SpellType<DarkVortexSpell> DARK_VORTEX = register("dark_vortex", Affinity.BAD, 0, true, DarkVortexSpell.DEFAULT_TRAITS, DarkVortexSpell::new);
|
||||||
public static final SpellType<NecromancySpell> NECROMANCY = register("necromancy", Affinity.BAD, 0x8A3A3A, true, NecromancySpell::new);
|
public static final SpellType<NecromancySpell> NECROMANCY = register("necromancy", Affinity.BAD, 0x8A3A3A, true, NecromancySpell::new);
|
||||||
public static final SpellType<SiphoningSpell> SIPHONING = register("siphoning", Affinity.NEUTRAL, 0xe308ab, true, SiphoningSpell::new);
|
public static final SpellType<SiphoningSpell> SIPHONING = register("siphoning", Affinity.NEUTRAL, 0xe308ab, true, SiphoningSpell::new);
|
||||||
public static final SpellType<RevealingSpell> REVEALING = register("reveal", Affinity.GOOD, 0x5CE81F, true, RevealingSpell::new);
|
public static final SpellType<RevealingSpell> REVEALING = register("reveal", Affinity.GOOD, 0x5CE81F, true, RevealingSpell::new);
|
||||||
|
|
Loading…
Reference in a new issue