Class RegistryUtils
java.lang.Object
com.binaris.wizardry.api.content.util.RegistryUtils
General utility methods used for Spell related functionality, normally being used for item creation, retrieval, etc.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic net.minecraft.world.item.ItemStackcreateArcaneTome(SpellTier tier) Creates an arcane tome ItemStack of the given tier.static net.minecraft.world.item.ItemStackgetArcaneTome(SpellTier tier) Given a spell tier, returns the corresponding arcane tome ItemStack.static net.minecraft.world.item.ItemgetArmor(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.ItemgetArmor(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.ItemgetCrystal(Element element) static ElementgetRandomElement(net.minecraft.util.RandomSource random) Returns a random element from all the elements registered.static @NotNull SpellgetSpell(net.minecraft.world.item.ItemStack stack) Gets the spell from the given ItemStack.static @NotNull SpellgetSpellFromNbt(net.minecraft.nbt.CompoundTag tag) Gets the spell from the given CompoundTag.Returns a list of all spells that match the given filter.static net.minecraft.world.item.ItemReturns the wand Item corresponding to the given tier and element.static net.minecraft.world.item.ItemStackSets a spell to the given ItemStack.static net.minecraft.world.item.ItemStackspellBookItem(Spell spell) Creates a spell book ItemStack containing the given spell.
-
Field Details
-
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 toElements.MAGIC.- Returns:
- The wand Item.
-
getCrystal
-
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
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
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
Creates a spell book ItemStack containing the given spell.- Parameters:
spell- The spell to put in the book.- Returns:
- The spell book ItemStack.
-
createArcaneTome
Creates an arcane tome ItemStack of the given tier.- Parameters:
tier- The tier of the arcane tome.- Returns:
- The arcane tome ItemStack.
-
getArcaneTome
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
Gets the spell from the given ItemStack.- Parameters:
stack- The ItemStack to get the spell from.- Returns:
- The spell from the ItemStack, or
Spells.NONEif the stack has no tag or the spell is not found.
-
getSpellFromNbt
Gets the spell from the given CompoundTag.- Parameters:
tag- The CompoundTag to get the spell from.- Returns:
- The spell from the CompoundTag, or
Spells.NONEif the tag is null or the spell is not found.
-