Class SpellUtil
java.lang.Object
com.binaris.wizardry.api.content.util.SpellUtil
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 ElementgetRandomElement(net.minecraft.util.RandomSource random) Returns a random element from all the elements registered.static @NotNull SpellgetSpell(net.minecraft.world.item.ItemStack stack) Retrieves the spell from the given ItemStack.Returns a list of all spells that match the given filter.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.static net.minecraft.world.item.ItemStackCreates a wand ItemStack of the given tier and element.
-
Field Details
-
SPELL_KEY
The NBT key used to store spells on items.
-
-
Method Details
-
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.
-
wandItem
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
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
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.
-