Class WorkbenchUtils
java.lang.Object
com.binaris.wizardry.api.content.util.WorkbenchUtils
Utility class for workbench-related operations, such as recharging mana and applying spell books to wands. This is
saved as a separate class to have a clear separation between workbench logic and actual workbench block/menu implementations
and also give the possibility for other workbench-like blocks/menus to reuse this logic on addons/mods.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanapplySpellBooks(net.minecraft.world.inventory.Slot centre, net.minecraft.world.inventory.Slot[] spellBooks, SpellContext ctx) Applies the spell books in the given slots to the wand in the centre slot.static booleancanBindSpell(Spell spell, List<Spell> spells, SpellTier origin, int slot, SpellContext ctx) Determines whether the given spell can be bound to the specified slot on a wand of the given tier.static intgetManaValuePerCrystal(net.minecraft.world.item.ItemStack crystal) Returns the amount of mana contained in a single crystal item.static booleanrechargeManaFromCrystals(net.minecraft.world.inventory.Slot centre, net.minecraft.world.inventory.Slot crystals) Recharges the mana of the item in the centre slot using the crystals in the crystals slot.static voidupdateSpellSlot(net.minecraft.world.item.ItemStack wand, List<Spell> spells, int slot, Spell spell) Updates the spell in the given slot, taking care to preserve the currently selected spell if necessary.
-
Method Details
-
rechargeManaFromCrystals
public static boolean rechargeManaFromCrystals(net.minecraft.world.inventory.Slot centre, net.minecraft.world.inventory.Slot crystals) Recharges the mana of the item in the centre slot using the crystals in the crystals slot.- Parameters:
centre- The slot containing the item to be rechargedcrystals- The slot containing the mana crystals- Returns:
- True if the item was recharged, false otherwise
-
getManaValuePerCrystal
public static int getManaValuePerCrystal(net.minecraft.world.item.ItemStack crystal) Returns the amount of mana contained in a single crystal item.- Parameters:
crystal- The crystal item stack- Returns:
- The amount of mana contained in a single crystal item
-
applySpellBooks
public static boolean applySpellBooks(net.minecraft.world.inventory.Slot centre, net.minecraft.world.inventory.Slot[] spellBooks, SpellContext ctx) Applies the spell books in the given slots to the wand in the centre slot.- Parameters:
centre- The slot containing the wandspellBooks- The slots containing the spell booksctx- The spell context- Returns:
- True if any spells were bound, false otherwise
-
canBindSpell
public static boolean canBindSpell(Spell spell, List<Spell> spells, SpellTier origin, int slot, SpellContext ctx) Determines whether the given spell can be bound to the specified slot on a wand of the given tier.- Parameters:
spell- The spell to checkspells- The list of spells currently bound to the wandorigin- The tier of the wandslot- The slot to which the spell would be boundctx- The spell context- Returns:
- True if the spell can be bound, false otherwise
-
updateSpellSlot
public static void updateSpellSlot(net.minecraft.world.item.ItemStack wand, List<Spell> spells, int slot, Spell spell) Updates the spell in the given slot, taking care to preserve the currently selected spell if necessary.- Parameters:
wand- The wand item stackspells- The list of spells on the wandslot- The slot to updatespell- The new spell to set
-