Class RegistryUtils

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

public final class RegistryUtils 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 net.minecraft.world.item.Item
    getArmor(WizardArmorType type, Element element, net.minecraft.util.RandomSource randomSource)
    Gets a random wizard armor item of the given type and element.
    static net.minecraft.world.item.Item
    getArmor(WizardArmorType wizardArmorType, Element element, net.minecraft.world.entity.EquipmentSlot slot)
    Gets a wizard armor item based on the given parameters, searching for its implementation in the item registry by constructing its registry name accordingly.
    static net.minecraft.world.item.Item
     
    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)
    Gets the spell from the given ItemStack.
    static @NotNull Spell
    getSpellFromNbt(net.minecraft.nbt.CompoundTag tag)
    Gets the spell from the given CompoundTag.
    static List<Spell>
    Returns a list of all spells that match the given filter.
    static net.minecraft.world.item.Item
    getWand(@NotNull SpellTier tier, @Nullable Element element)
    Returns the wand Item corresponding to the given tier and element.
    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.

    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

    • getWand

      public static net.minecraft.world.item.Item getWand(@NotNull @NotNull SpellTier tier, @Nullable @Nullable Element element)
      Returns the wand Item corresponding to the given tier and element.
      Parameters:
      tier - The tier of the wand.
      element - The element of the wand. If null, defaults to Elements.MAGIC.
      Returns:
      The wand Item.
    • getCrystal

      public static net.minecraft.world.item.Item getCrystal(Element element)
    • getArmor

      public static net.minecraft.world.item.Item getArmor(WizardArmorType type, Element element, net.minecraft.util.RandomSource randomSource)
      Gets a random wizard armor item of the given type and element.
      Parameters:
      type - The type of wizard armor.
      element - The element of the armor. If null, defaults to magic.
      Returns:
      The corresponding wizard armor item.
    • getArmor

      public static net.minecraft.world.item.Item getArmor(WizardArmorType wizardArmorType, Element element, net.minecraft.world.entity.EquipmentSlot slot)
      Gets a wizard armor item based on the given parameters, searching for its implementation in the item registry by constructing its registry name accordingly.
      Parameters:
      wizardArmorType - The type of wizard armor.
      element - The element of the armor. If null, defaults to magic.
      slot - The equipment slot for the armor piece.
      Returns:
      The corresponding wizard armor item.
      Throws:
      IllegalArgumentException - if the slot is null or not an armor slot. (this should never happen if used correctly)
    • 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.
    • 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)
      Gets the spell from the given ItemStack.
      Parameters:
      stack - The ItemStack to get the spell from.
      Returns:
      The spell from the ItemStack, or Spells.NONE if the stack has no tag or the spell is not found.
    • getSpellFromNbt

      @NotNull public static @NotNull Spell getSpellFromNbt(net.minecraft.nbt.CompoundTag tag)
      Gets the spell from the given CompoundTag.
      Parameters:
      tag - The CompoundTag to get the spell from.
      Returns:
      The spell from the CompoundTag, or Spells.NONE if the tag is null or the spell is not found.