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:
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 TypeMethodDescriptionbooleancanCast(net.minecraft.world.item.ItemStack stack, Spell spell, PlayerCastContext ctx) The items implementing this interface are responsible about how to use this.booleancast(net.minecraft.world.item.ItemStack stack, Spell spell, PlayerCastContext ctx) The items implementing this interface are responsible about how to use this.default intgetCurrentCooldown(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 intgetCurrentMaxCooldown(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 SpellgetCurrentSpell(net.minecraft.world.item.ItemStack stack) This gets the actual item that's on the ItemStack, normally you won't use this.default @NotNull SpellgetNextSpell(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 SpellgetPreviousSpell(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 voidselectNextSpell(net.minecraft.world.item.ItemStack stack) Selects the next spell bound to the given ItemStack.default voidselectPreviousSpell(net.minecraft.world.item.ItemStack stack) Selects the previous spell bound to the given itemstack.default booleanselectSpell(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.booleanshowSpellHUD(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 booleanshowSpellsInWorkbench(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
The items implementing this interface are responsible about how to use this. Normally you would call the eventsSpellCastEvent.PreandSpellCastEvent.Tickin 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
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 useItem.onUseTick(Level, LivingEntity, ItemStack, int) -
getCurrentSpell
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
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
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
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.
-