diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/Caster.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/Caster.java index 0a5747b0..f50f3bbe 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/Caster.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/Caster.java @@ -16,6 +16,7 @@ import com.minelittlepony.unicopia.util.VecHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; +import net.minecraft.sound.SoundEvent; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -62,6 +63,10 @@ public interface Caster extends Owned, Levelled, Affi return getEntity().getBlockPos(); } + default void playSound(SoundEvent sound, float volume, float pitch) { + getWorld().playSound(null, getEntity().getX(), getEntity().getY(), getEntity().getZ(), sound, getEntity().getSoundCategory(),volume, pitch); + } + /** * Removes the desired amount of mana or health from this caster in exchange for a spell's benefits. */ diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/ThrowableSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/ThrowableSpell.java index f826b28e..fb0a73cc 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/ThrowableSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/ThrowableSpell.java @@ -13,11 +13,10 @@ import com.minelittlepony.unicopia.projectile.MagicProjectileEntity; import net.minecraft.entity.LivingEntity; import net.minecraft.nbt.NbtCompound; -import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; import net.minecraft.world.World; -public class ThrowableSpell extends AbstractDelegatingSpell { +public final class ThrowableSpell extends AbstractDelegatingSpell { private Spell spell; @@ -45,7 +44,7 @@ public class ThrowableSpell extends AbstractDelegatingSpell { LivingEntity entity = caster.getMaster(); - world.playSound(null, entity.getX(), entity.getY(), entity.getZ(), SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, SoundCategory.NEUTRAL, 0.7F, 0.4F / (world.random.nextFloat() * 0.4F + 0.8F)); + caster.playSound(SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, 0.7F, 0.4F / (world.random.nextFloat() * 0.4F + 0.8F)); if (!caster.isClient()) { MagicProjectileEntity projectile = new MagicProjectileEntity(world, entity); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/FireBoltSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/FireBoltSpell.java new file mode 100644 index 00000000..ea12039c --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/FireBoltSpell.java @@ -0,0 +1,44 @@ +package com.minelittlepony.unicopia.ability.magic.spell.effect; + +import com.minelittlepony.unicopia.ability.magic.Caster; +import com.minelittlepony.unicopia.ability.magic.spell.ProjectileSpell; +import com.minelittlepony.unicopia.ability.magic.spell.Situation; +import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits; +import com.minelittlepony.unicopia.projectile.MagicProjectileEntity; + +import net.minecraft.entity.Entity; +import net.minecraft.item.Items; +import net.minecraft.sound.SoundEvents; + +public class FireBoltSpell extends AbstractSpell implements ProjectileSpell { + + protected FireBoltSpell(SpellType type, SpellTraits traits) { + super(type, traits); + } + + @Override + public void onImpact(MagicProjectileEntity projectile, Entity entity) { + entity.setOnFireFor(90); + } + + @Override + public boolean tick(Caster caster, Situation situation) { + for (int i = 0; i < getNumberOfBalls(caster); i++) { + getType().create(getTraits()).toThrowable().throwProjectile(caster); + caster.playSound(SoundEvents.ENTITY_BLAZE_SHOOT, 0.7F, 0.4F / (caster.getWorld().random.nextFloat() * 0.4F + 0.8F)); + } + + return false; + } + + @Override + public void configureProjectile(MagicProjectileEntity projectile, Caster caster) { + projectile.setItem(Items.FIRE_CHARGE.getDefaultStack()); + projectile.addThrowDamage(9); + projectile.setVelocity(projectile.getVelocity().multiply(1.3)); + } + + protected int getNumberOfBalls(Caster caster) { + return 1 + caster.getWorld().random.nextInt(3); + } +} 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 97b6fd12..85a19585 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 @@ -59,6 +59,7 @@ public final class SpellType implements Affine, SpellPredicate< public static final SpellType TRANSFORMATION = register("transformation", Affinity.GOOD, 0x3A59AA, true, TransformationSpell::new); public static final SpellType FEATHER_FALL = register("feather_fall", Affinity.GOOD, 0x00EEFF, true, FeatherFallSpell.DEFAULT_TRAITS, FeatherFallSpell::new); public static final SpellType CATAPULT = register("catapult", Affinity.GOOD, 0x33FF00, true, CatapultSpell.DEFAULT_TRAITS, CatapultSpell::new); + public static final SpellType FIRE_BOLT = register("fire_bolt", Affinity.GOOD, 0x888800, true, FireBoltSpell::new); private final Identifier id; private final Affinity affinity; diff --git a/src/main/java/com/minelittlepony/unicopia/projectile/MagicProjectileEntity.java b/src/main/java/com/minelittlepony/unicopia/projectile/MagicProjectileEntity.java index 07d87379..027a8a03 100644 --- a/src/main/java/com/minelittlepony/unicopia/projectile/MagicProjectileEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/projectile/MagicProjectileEntity.java @@ -128,6 +128,10 @@ public class MagicProjectileEntity extends ThrownItemEntity implements Caster
  • c.subtractEnergyCost(amount)).isPresent(); } + public void addThrowDamage(float damage) { + setThrowDamage(getThrowDamage() + damage); + } + public void setThrowDamage(float damage) { getDataTracker().set(DAMAGE, Math.max(0, damage)); }