Projectile Spells

Projectile spells are similar to basic spells, except with a 3 extra methods that determine what the projectile does when it is flying, when it hits an entity and when it is removed.

You also need to actually fire the projectile in the class, as that does not happen automatically.

In this tutorial we will create a projectile that causes the hit target to take 25% more damage for 4 seconds.

The Class

The method for creating a projectile class is quite similar to the method for creating a normal class, but instead of extending Spell, you extend ProjectileSpell.

public class DestroyArmorProjectile extends ProjectileSpell {

}

The Constructor

The constructor is the same as a normal spell, but has two extra parameters.

/**
	* Creates a new projectile spell instance
	* @param caster The caster of the spell
  * @param length The total length that the projectile can travel in blocks
  * @param speed The initial velocity of the projectile
  */
public ProjectileSpell(@NotNull LivingEntity caster, int length, float speed)

We want our projectile to travel a maximum of 70 blocks, and move at a speed of 1.

public DestruoArmaProjectilis(@NotNull LivingEntity caster) {
    super(caster, SpellClass.DESTRUOARMAPROJECTILIS, 70, 1f);
}

Once again, we need to create a SpellClass value (which is submitted separately.