mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 11:36:43 +01:00
Added the firebolt spell
This commit is contained in:
parent
ab9d266f79
commit
1b82f7e9b5
5 changed files with 56 additions and 3 deletions
|
@ -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<E extends LivingEntity> extends Owned<E>, 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.
|
||||
*/
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -59,6 +59,7 @@ public final class SpellType<T extends Spell> implements Affine, SpellPredicate<
|
|||
public static final SpellType<TransformationSpell> TRANSFORMATION = register("transformation", Affinity.GOOD, 0x3A59AA, true, TransformationSpell::new);
|
||||
public static final SpellType<FeatherFallSpell> FEATHER_FALL = register("feather_fall", Affinity.GOOD, 0x00EEFF, true, FeatherFallSpell.DEFAULT_TRAITS, FeatherFallSpell::new);
|
||||
public static final SpellType<CatapultSpell> CATAPULT = register("catapult", Affinity.GOOD, 0x33FF00, true, CatapultSpell.DEFAULT_TRAITS, CatapultSpell::new);
|
||||
public static final SpellType<FireBoltSpell> FIRE_BOLT = register("fire_bolt", Affinity.GOOD, 0x888800, true, FireBoltSpell::new);
|
||||
|
||||
private final Identifier id;
|
||||
private final Affinity affinity;
|
||||
|
|
|
@ -128,6 +128,10 @@ public class MagicProjectileEntity extends ThrownItemEntity implements Caster<Li
|
|||
return Caster.of(getMaster()).filter(c -> c.subtractEnergyCost(amount)).isPresent();
|
||||
}
|
||||
|
||||
public void addThrowDamage(float damage) {
|
||||
setThrowDamage(getThrowDamage() + damage);
|
||||
}
|
||||
|
||||
public void setThrowDamage(float damage) {
|
||||
getDataTracker().set(DAMAGE, Math.max(0, damage));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue