Interface SpellHelper


public interface SpellHelper
Helper for spell-related operations.
  • Method Details

    • cast

      SpellCastResult cast(Spell spell, net.minecraft.world.level.Level level, @Nullable net.minecraft.world.entity.LivingEntity caster, boolean consume, boolean awardXp)
      Casts the given Spell.
      Parameters:
      spell - The Spell to cast.
      level - The Level the Spell is cast in.
      caster - The LivingEntity casting the Spell.
      consume - Whether to consume mana and burnout or not.
      awardXp - Whether to award xp or not.
      Returns:
      null if the cast was successful, or an error message if not.
    • castPrimary

      SpellCastResult castPrimary(SpellCastContext context)
      Casts the given Spell's primary shape. Note that SpellCastContext.directEntity() and SpellCastContext.hitResult() are guaranteed to return null here.
      Parameters:
      context - The SpellCastContext to use.
      Returns:
      A SpellCastResult representing the result of the cast.
      See Also:
    • castSecondary

      SpellCastResult castSecondary(SpellCastContext context)
      Casts the given Spell's secondary shape.
      Parameters:
      context - The SpellCastContext to use.
      Returns:
      A SpellCastResult representing the result of the cast.
      See Also:
    • castGrammar

      SpellCastResult castGrammar(SpellCastContext context)
      Casts the given Spell's grammar.
      Parameters:
      context - The SpellCastContext to use.
      Returns:
      A SpellCastResult representing the result of the cast.
    • castSecondaryOrGrammar

      SpellCastResult castSecondaryOrGrammar(SpellCastContext context)
      If present, casts the given Spell's secondary shape. Otherwise, casts the given Spell's grammar.
      Parameters:
      context - The SpellCastContext to use.
      Returns:
      A SpellCastResult representing the result of the cast.
    • getModifiedStat

      double getModifiedStat(double base, SpellStat stat, List<SpellModifier> modifiers, SpellCastContext context)
      Calculates the modifier-changed value from the base value.
      Parameters:
      base - The base value to use.
      stat - The SpellStat that is modified.
      modifiers - The SpellModifiers to check.
      context - The SpellCastContext to use.
      Returns:
      A modifier-changed value.
    • getColor

      int getColor(List<SpellModifier> modifiers, Spell spell, int shapeGroupIndex)
      Parameters:
      modifiers - The SpellModifiers to check.
      spell - The Spell to cast.
      shapeGroupIndex - The index of the shape group to query the data components for. Pass a negative to use the grammar's data components instead.
      Returns:
      The color of the Spell's visual effects.
    • getModifiers

      List<SpellModifier> getModifiers(SpellPart part)
      Parameters:
      part - The SpellPart to query.
      Returns:
      A list of SpellModifier that can modify the given part.
    • setContingency

      void setContingency(net.minecraft.world.entity.LivingEntity entity, net.minecraft.resources.Identifier contingency, Spell spell)
      Sets a contingency Spell.
      Parameters:
      entity - The LivingEntity to set the contingency Spell on.
      contingency - The name of the contingency to trigger the contingency Spell for.
      spell - The Spell to cast when the contingency is triggered.
    • triggerContingency

      void triggerContingency(net.minecraft.world.entity.LivingEntity entity, net.minecraft.resources.Identifier contingency)
      Triggers a contingency.
      Parameters:
      entity - The LivingEntity to trigger the contingency for.
      contingency - The name of the contingency to trigger.
    • getIncorrectTagForToolTier

      net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block> getIncorrectTagForToolTier(int toolTier)
      Parameters:
      toolTier - The tool tier to get the incorrect block tag for.
      Returns:
      A tag specifying which blocks are not breakable by the given tool tier.
    • getMaxSummons

      int getMaxSummons(net.minecraft.world.entity.LivingEntity entity)
      Parameters:
      entity - The LivingEntity to get the max summons for.
      Returns:
      The maximum amount of summoned minions for the given LivingEntity.
    • getManaToBurnoutRatio

      double getManaToBurnoutRatio()
      Returns:
      The mana to burnout conversion ratio, used in spell cost calculation.
    • getRecipe

      List<SpellIngredient> getRecipe(Spell spell, net.minecraft.core.RegistryAccess registryAccess)
      Calculates a Spell's recipe.
      Parameters:
      spell - The Spell to calculate the recipe for.
      registryAccess - The RegistryAccess to use.
      Returns:
      The recipe for the Spell.
    • getFlatRecipe

      List<SpellIngredient> getFlatRecipe(Spell spell, net.minecraft.core.RegistryAccess registryAccess)
      Calculates a Spell's recipe and combines the ingredients where possible.
      Parameters:
      spell - The Spell to calculate the recipe for.
      registryAccess - The RegistryAccess to use.
      Returns:
      The recipe for the Spell.
    • spawnParticles

      void spawnParticles(net.minecraft.resources.Identifier part, List<SpellModifier> modifiers, SpellCastContext context)
      On the client, spawns particles for the given SpellPart. On the server, does nothing.
      Parameters:
      part - The id of the spell part to spawn the particles for.
      modifiers - The SpellModifiers to consider.
      context - The SpellCastContext to use.