public interface ISpellHelper
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    consumeReagents(net.minecraft.world.entity.LivingEntity entity, Collection<ItemFilter> reagents)
    Consumes the reagents.
    float
    getModifiedStat(float baseValue, ISpellPartStat stat, List<ISpellModifier> modifiers, ISpell spell, net.minecraft.world.entity.LivingEntity caster, @Nullable net.minecraft.world.phys.HitResult target)
    Get the stat value modified by the modifiers.
    @Nullable net.minecraft.world.entity.Entity
    getPointedEntity(net.minecraft.world.entity.Entity entity, net.minecraft.world.level.Level level, double range, boolean clipFluids)
    Performs a ray trace and returns the entity the given entity is currently looking at.
    getSpell(net.minecraft.world.item.ItemStack stack)
     
    Optional<net.minecraft.resources.ResourceLocation>
    getSpellIcon(net.minecraft.world.item.ItemStack stack)
     
    Optional<net.minecraft.network.chat.Component>
    getSpellName(net.minecraft.world.item.ItemStack stack)
     
    boolean
    hasReagents(net.minecraft.world.entity.LivingEntity entity, Collection<ItemFilter> reagents)
     
    invoke(ISpell spell, net.minecraft.world.entity.LivingEntity caster, net.minecraft.world.level.Level level, @Nullable net.minecraft.world.phys.HitResult target, int castingTicks, int index, boolean awardXp)
    Casts the spell.
    void
    nextShapeGroup(net.minecraft.world.item.ItemStack stack)
    Selects the next shape group of the given spell item stack, wrapping around.
    void
    setSpell(net.minecraft.world.item.ItemStack stack, ISpell spell)
    Sets the given spell to the given stack.
    void
    setSpellIcon(net.minecraft.world.item.ItemStack stack, net.minecraft.resources.ResourceLocation icon)
    Sets the given icon to the given stack.
    void
    setSpellName(net.minecraft.world.item.ItemStack stack, String name)
    Sets the given name to the given stack.
    void
    setSpellName(net.minecraft.world.item.ItemStack stack, net.minecraft.network.chat.Component name)
    Sets the given name to the given stack.
    net.minecraft.world.phys.HitResult
    trace(net.minecraft.world.entity.Entity entity, net.minecraft.world.level.Level level, double range, boolean entities, boolean targetNonSolid)
    Performs a ray trace.
  • Method Details

    • getSpell

      ISpell getSpell(net.minecraft.world.item.ItemStack stack)
      Parameters:
      stack - The stack to get the spell for.
      Returns:
      An optional containing the spell, or an empty optional if the given stack does not have a spell.
    • setSpell

      void setSpell(net.minecraft.world.item.ItemStack stack, ISpell spell)
      Sets the given spell to the given stack.
      Parameters:
      stack - The stack to set the spell on.
      spell - The spell to set.
    • getSpellName

      Optional<net.minecraft.network.chat.Component> getSpellName(net.minecraft.world.item.ItemStack stack)
      Parameters:
      stack - The stack to get the spell name for.
      Returns:
      An optional containing the spell name, or an empty optional if the given stack does not have a spell name.
    • setSpellName

      void setSpellName(net.minecraft.world.item.ItemStack stack, String name)
      Sets the given name to the given stack.
      Parameters:
      stack - The stack to set the name on.
      name - The name to set.
    • setSpellName

      void setSpellName(net.minecraft.world.item.ItemStack stack, net.minecraft.network.chat.Component name)
      Sets the given name to the given stack.
      Parameters:
      stack - The stack to set the name on.
      name - The name to set.
    • getSpellIcon

      Optional<net.minecraft.resources.ResourceLocation> getSpellIcon(net.minecraft.world.item.ItemStack stack)
      Parameters:
      stack - The stack to get the spell icon for.
      Returns:
      An optional containing the spell icon id, or an empty optional if the given stack does not have a spell icon.
    • setSpellIcon

      void setSpellIcon(net.minecraft.world.item.ItemStack stack, net.minecraft.resources.ResourceLocation icon)
      Sets the given icon to the given stack.
      Parameters:
      stack - The stack to set the icon on.
      icon - The icon to set.
    • hasReagents

      boolean hasReagents(net.minecraft.world.entity.LivingEntity entity, Collection<ItemFilter> reagents)
      Parameters:
      entity - The entity to check on.
      reagents - The reagents to search for.
      Returns:
      Whether the given entity has the required reagents in their inventory or not.
    • consumeReagents

      void consumeReagents(net.minecraft.world.entity.LivingEntity entity, Collection<ItemFilter> reagents)
      Consumes the reagents.
      Parameters:
      entity - The entity to consume the ingredients from.
      reagents - The reagents to consume.
    • getPointedEntity

      @Nullable @Nullable net.minecraft.world.entity.Entity getPointedEntity(net.minecraft.world.entity.Entity entity, net.minecraft.world.level.Level level, double range, boolean clipFluids)
      Performs a ray trace and returns the entity the given entity is currently looking at.
      Parameters:
      entity - The entity to start the ray trace from.
      level - The level to perform the ray trace in.
      range - The range of the ray trace.
      clipFluids - False if fluids should block the ray trace, true if fluids should be ignored.
      Returns:
      The entity the given entity is currently looking at, or null if no entity was found.
    • trace

      net.minecraft.world.phys.HitResult trace(net.minecraft.world.entity.Entity entity, net.minecraft.world.level.Level level, double range, boolean entities, boolean targetNonSolid)
      Performs a ray trace.
      Parameters:
      entity - The entity to start the ray trace from.
      level - The level to perform the ray trace in.
      range - The range of the ray trace.
      entities - Whether to include entities. If false, only checks blocks.
      targetNonSolid - False if non-solid blocks and fluids should block the ray trace, true if non-solid blocks and fluids should be ignored.
      Returns:
      A hit result, representing the ray trace.
    • getModifiedStat

      float getModifiedStat(float baseValue, ISpellPartStat stat, List<ISpellModifier> modifiers, ISpell spell, net.minecraft.world.entity.LivingEntity caster, @Nullable @Nullable net.minecraft.world.phys.HitResult target)
      Get the stat value modified by the modifiers.
      Parameters:
      baseValue - The base value for the stat.
      stat - The stat that is modified.
      spell - The spell that the part belongs to.
      caster - The entity casting the spell.
      target - The target of the spell cast.
      Returns:
      The modified value of the stat.
    • invoke

      SpellCastResult invoke(ISpell spell, net.minecraft.world.entity.LivingEntity caster, net.minecraft.world.level.Level level, @Nullable @Nullable net.minecraft.world.phys.HitResult target, int castingTicks, int index, boolean awardXp)
      Casts the spell.
      Parameters:
      spell - The spell to cast.
      caster - The entity casting the spell.
      level - The level the spell is cast in.
      target - The target of the spell cast.
      castingTicks - How long the spell has already been cast.
      index - The shape group index.
      awardXp - The magic xp awarded for casting this spell.
      Returns:
      A SpellCastResult that represents the spell casting outcome.
    • nextShapeGroup

      void nextShapeGroup(net.minecraft.world.item.ItemStack stack)
      Selects the next shape group of the given spell item stack, wrapping around.
      Parameters:
      stack - The spell item stack to select the next shape group of.