Class MinionSpell<T extends net.minecraft.world.entity.Mob>

java.lang.Object
com.binaris.wizardry.api.content.spell.Spell
com.binaris.wizardry.content.spell.abstr.MinionSpell<T>
Type Parameters:
T - The type of mob that is summoned by this spell.
Direct Known Subclasses:
SummonIceGiant, SummonSkeleton, SummonSkeletonLegion, SummonWitherSkeleton, SummonZombie

public class MinionSpell<T extends net.minecraft.world.entity.Mob> extends Spell
Base class for spells that summon minions. Handles the common functionality such as spawning the minions, setting their lifetime and applying modifiers. The actual type of minion is specified by a factory function passed to the constructor.

Minions are spawned on the ground near the caster by default, but this can be changed to midair by calling flying(boolean) with true as the argument. In this case, if no suitable ground position can be found within the summon radius, they will be spawned at y=2 at a random horizontal position within the summon radius instead.

The process of creating the minion data and overwriting the original entity logic is handled by the MinionData

  • Field Details

    • HEALTH_MODIFIER

      public static final String HEALTH_MODIFIER
      Attribute Modifier id
      See Also:
    • POTENCY_ATTRIBUTE_MODIFIER

      public static final String POTENCY_ATTRIBUTE_MODIFIER
      Attribute Modifier id
      See Also:
    • minionFactory

      protected final Function<net.minecraft.world.level.Level,T extends net.minecraft.world.entity.Mob> minionFactory
      A factory that creates the minions.
    • flying

      protected boolean flying
      Whether the minions are spawned in midair. Defaults to false.
    • shouldFollowOwner

      protected boolean shouldFollowOwner
      When the created minion should follow the owner
  • Constructor Details

    • MinionSpell

      public MinionSpell(Function<net.minecraft.world.level.Level,T> minionFactory)
  • Method Details

    • setShouldFollowOwner

      public MinionSpell<T> setShouldFollowOwner(boolean shouldFollowOwner)
    • flying

      public MinionSpell<T> flying(boolean flying)
      Sets whether the minions are spawned in midair.
      Parameters:
      flying - True to spawn the minions in midair, false to spawn them on the ground.
      Returns:
      The spell instance, allowing this method to be chained onto the constructor.
    • canCastByLocation

      public boolean canCastByLocation()
      Overrides:
      canCastByLocation in class Spell
    • canCastByEntity

      public boolean canCastByEntity()
      Overrides:
      canCastByEntity in class Spell
    • cast

      public boolean cast(PlayerCastContext ctx)
      Specified by:
      cast in class Spell
    • cast

      public boolean cast(EntityCastContext ctx)
      Overrides:
      cast in class Spell
    • cast

      public boolean cast(LocationCastContext ctx)
      Overrides:
      cast in class Spell
    • spawnMinions

      protected boolean spawnMinions(CastContext ctx)
    • createMinion

      protected T createMinion(net.minecraft.world.level.Level world, @Nullable @Nullable net.minecraft.world.entity.LivingEntity caster, SpellModifiers modifiers)
    • addMinionExtras

      protected void addMinionExtras(T minion, CastContext ctx, int alreadySpawned)
    • extraConditions

      protected boolean extraConditions(CastContext ctx, net.minecraft.core.BlockPos containing)
    • requiresPacket

      public boolean requiresPacket()
      Description copied from class: Spell
      Whether this spell requires a packet to be sent when it is cast. Returns true by default, but can be overridden to return false if the spell's cast() method does not use any code that must be executed client-side (i.e. particle spawning). This is not checked for continuous spells, because they never need to send packets.

      If in doubt, leave this method as is; it is purely an optimisation.

      Overrides:
      requiresPacket in class Spell
      Returns:
      true if the spell code should be run on the server and all clients in the dimension, false if the spell code should only be run on the server and the client of the player casting it.
    • properties

      @NotNull protected @NotNull SpellProperties properties()
      Specified by:
      properties in class Spell