Class SpellUtil

java.lang.Object
com.binaris.wizardry.api.content.util.SpellUtil

public final class SpellUtil extends Object
General utility methods used for Spell related functionality, normally being used for item creation, retrieval, etc.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static String
    The NBT key used to store spells on items.
  • Method Summary

    Modifier and Type
    Method
    Description
    static net.minecraft.world.item.ItemStack
    Creates an arcane tome ItemStack of the given tier.
    static net.minecraft.world.item.ItemStack
    Given a spell tier, returns the corresponding arcane tome ItemStack.
    static Element
    getRandomElement(net.minecraft.util.RandomSource random)
    Returns a random element from all the elements registered.
    static @NotNull Spell
    getSpell(net.minecraft.world.item.ItemStack stack)
    Retrieves the spell from the given ItemStack.
    static List<Spell>
    Returns a list of all spells that match the given filter.
    static net.minecraft.world.item.ItemStack
    setSpell(net.minecraft.world.item.ItemStack stack, Spell spell)
    Sets a spell to the given ItemStack.
    static net.minecraft.world.item.ItemStack
    Creates a spell book ItemStack containing the given spell.
    static net.minecraft.world.item.ItemStack
    wandItem(SpellTier tier, Element element)
    Creates a wand ItemStack of the given tier and element.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • SPELL_KEY

      public static String SPELL_KEY
      The NBT key used to store spells on items.
  • Method Details

    • getSpells

      public static List<Spell> getSpells(Predicate<Spell> filter)
      Returns a list of all spells that match the given filter.
      Parameters:
      filter - The filter to apply to the spells.
      Returns:
      A list of spells that match the filter.
    • getRandomElement

      public static Element getRandomElement(net.minecraft.util.RandomSource random)
      Returns a random element from all the elements registered.
      Parameters:
      random - The RandomSource to use for selecting the element.
      Returns:
      A random Element.
    • setSpell

      public static net.minecraft.world.item.ItemStack setSpell(net.minecraft.world.item.ItemStack stack, Spell spell)
      Sets a spell to the given ItemStack.
      Parameters:
      stack - The ItemStack to which the spell is to be set.
      spell - The spell to be set to the ItemStack.
      Returns:
      The ItemStack with the spell set.
    • spellBookItem

      public static net.minecraft.world.item.ItemStack spellBookItem(Spell spell)
      Creates a spell book ItemStack containing the given spell.
      Parameters:
      spell - The spell to put in the book.
      Returns:
      The spell book ItemStack.
    • wandItem

      public static net.minecraft.world.item.ItemStack wandItem(SpellTier tier, Element element)
      Creates a wand ItemStack of the given tier and element.
      Parameters:
      tier - The tier of the wand.
      element - The element of the wand.
      Returns:
      The wand ItemStack.
    • createArcaneTome

      public static net.minecraft.world.item.ItemStack createArcaneTome(SpellTier tier)
      Creates an arcane tome ItemStack of the given tier.
      Parameters:
      tier - The tier of the arcane tome.
      Returns:
      The arcane tome ItemStack.
    • getArcaneTome

      public static net.minecraft.world.item.ItemStack getArcaneTome(SpellTier tier)
      Given a spell tier, returns the corresponding arcane tome ItemStack. If the tier is one of the default upgraded tiers (Apprentice, Advanced, Master), it returns the corresponding predefined arcane tome. Otherwise, it creates a new arcane tome with the given tier stored in its NBT. createArcaneTome(SpellTier)
      Parameters:
      tier - The tier of the arcane tome.
      Returns:
      The arcane tome ItemStack.
    • getSpell

      @NotNull public static @NotNull Spell getSpell(net.minecraft.world.item.ItemStack stack)
      Retrieves the spell from the given ItemStack.
      Parameters:
      stack - The ItemStack from which the spell is to be retrieved.
      Returns:
      The spell retrieved from the ItemStack.