Interface ISpellCastingItem

All Known Implementing Classes:
ScrollItem, WandItem

public interface ISpellCastingItem
This helps items to hold and cast spells that could be consumables (like scrolls) or they may be durability-based (like wands), it could also handle custom behaviours outside the mod like items that are special for certain spells, unlock new modifiers, exclusive effects and much more. Custom spell casting items should implement this to integrate properly with Electroblob's Wizardry Ecosystem.

Used for the following:
  • Display of the arcane workbench tooltip (in conjunction with IManaStoringItem)
  • Supplying information to the spell HUD
  • Spell switching controls for different spells (Controlled by packets by main mod, don't worry)
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    canCast(net.minecraft.world.item.ItemStack stack, Spell spell, PlayerCastContext ctx)
    The items implementing this interface are responsible about how to use this.
    boolean
    cast(net.minecraft.world.item.ItemStack stack, Spell spell, PlayerCastContext ctx)
    The items implementing this interface are responsible about how to use this.
    default int
    getCurrentCooldown(net.minecraft.world.item.ItemStack stack, net.minecraft.world.level.Level level)
    Returns the current cooldown to display on the spell HUD for the given ItemStack.
    default int
    getCurrentMaxCooldown(net.minecraft.world.item.ItemStack stack)
    Returns the max cooldown of the current spell to display on the spell HUD for the given ItemStack.
    @NotNull Spell
    getCurrentSpell(net.minecraft.world.item.ItemStack stack)
    This gets the actual item that's on the ItemStack, normally you won't use this.
    default @NotNull Spell
    getNextSpell(net.minecraft.world.item.ItemStack stack)
    If your item will have more than just one spell loaded you need to override this in order to have a next spell on list, by default it just gets the current spell saved.
    default @NotNull Spell
    getPreviousSpell(net.minecraft.world.item.ItemStack stack)
    If your item will have more than just one spell loaded you need to override this in order to have a previous spell on list, by default it just gets the current spell saved.
    default Spell[]
    getSpells(net.minecraft.world.item.ItemStack stack)
    If your item will have more than just one spell loaded you need to override this in order to have a list of spells saved, by default it just sends a list with just the current spell.
    default void
    selectNextSpell(net.minecraft.world.item.ItemStack stack)
    Selects the next spell bound to the given ItemStack.
    default void
    selectPreviousSpell(net.minecraft.world.item.ItemStack stack)
    Selects the previous spell bound to the given itemstack.
    default boolean
    selectSpell(net.minecraft.world.item.ItemStack stack, int index)
    If your item will have more than just one spell loaded you need to override this in order to have the possibility to switch between the spell list.
    boolean
    showSpellHUD(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack stack)
    Returns whether the spell HUD should be shown when a player is holding this item.
    default boolean
    showSpellsInWorkbench(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack stack)
    Returns whether this item's spells should be displayed in the arcane workbench tooltip.
  • Method Details

    • canCast

      boolean canCast(net.minecraft.world.item.ItemStack stack, Spell spell, PlayerCastContext ctx)
      The items implementing this interface are responsible about how to use this. Normally you would call the events SpellCastEvent.Pre and SpellCastEvent.Tick in order to know when to allow the spell to run.

      You could also add some custom to logic (like special cooldowns or handling specific spells) if you want to.

    • cast

      boolean cast(net.minecraft.world.item.ItemStack stack, Spell spell, PlayerCastContext ctx)
      The items implementing this interface are responsible about how to use this. This is where you make all the spell cast handling (normally just instant spells). For doing the continuous spells you should use Item.onUseTick(Level, LivingEntity, ItemStack, int)
    • getCurrentSpell

      @NotNull @NotNull Spell getCurrentSpell(net.minecraft.world.item.ItemStack stack)
      This gets the actual item that's on the ItemStack, normally you won't use this. Used by the Spell GUI to get the actual spell icon and some client related features
    • getNextSpell

      @NotNull default @NotNull Spell getNextSpell(net.minecraft.world.item.ItemStack stack)
      If your item will have more than just one spell loaded you need to override this in order to have a next spell on list, by default it just gets the current spell saved. Used by the Spell GUI to get the actual spell icon and some client related features
    • getPreviousSpell

      @NotNull default @NotNull Spell getPreviousSpell(net.minecraft.world.item.ItemStack stack)
      If your item will have more than just one spell loaded you need to override this in order to have a previous spell on list, by default it just gets the current spell saved. Used by the Spell GUI to get the actual spell icon and some client related features
    • getSpells

      default Spell[] getSpells(net.minecraft.world.item.ItemStack stack)
      If your item will have more than just one spell loaded you need to override this in order to have a list of spells saved, by default it just sends a list with just the current spell. Used by the Spell GUI to get all the needed spells to show
    • selectNextSpell

      default void selectNextSpell(net.minecraft.world.item.ItemStack stack)
      Selects the next spell bound to the given ItemStack. The given ItemStack will be of this item.
    • selectPreviousSpell

      default void selectPreviousSpell(net.minecraft.world.item.ItemStack stack)
      Selects the previous spell bound to the given itemstack. The given itemstack will be of this item.
    • selectSpell

      default boolean selectSpell(net.minecraft.world.item.ItemStack stack, int index)
      If your item will have more than just one spell loaded you need to override this in order to have the possibility to switch between the spell list.
    • getCurrentCooldown

      default int getCurrentCooldown(net.minecraft.world.item.ItemStack stack, net.minecraft.world.level.Level level)
      Returns the current cooldown to display on the spell HUD for the given ItemStack.
    • getCurrentMaxCooldown

      default int getCurrentMaxCooldown(net.minecraft.world.item.ItemStack stack)
      Returns the max cooldown of the current spell to display on the spell HUD for the given ItemStack.
    • showSpellHUD

      boolean showSpellHUD(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack stack)
      Returns whether the spell HUD should be shown when a player is holding this item. Only called client-side.
    • showSpellsInWorkbench

      default boolean showSpellsInWorkbench(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack stack)
      Returns whether this item's spells should be displayed in the arcane workbench tooltip. Only called client-side. Ignore this method if you don't want to use it on the Arcane Workbench.