Class WorkbenchUtils

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

public final class WorkbenchUtils extends Object
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 Type
    Method
    Description
    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.
    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.
    static int
    getManaValuePerCrystal(net.minecraft.world.item.ItemStack crystal)
    Returns the amount of mana contained in a single crystal item.
    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.
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 recharged
      crystals - 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 wand
      spellBooks - The slots containing the spell books
      ctx - 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 check
      spells - The list of spells currently bound to the wand
      origin - The tier of the wand
      slot - The slot to which the spell would be bound
      ctx - 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 stack
      spells - The list of spells on the wand
      slot - The slot to update
      spell - The new spell to set