Interface ICastItem
- All Known Implementing Classes:
ScrollItem,WandItem
public interface ICastItem
Offers a template for spell casting items to handle the base spell casting logic, cooldown, spell selection, cast
verification and spell casting. Implementing this interface allows you to have a better integration with EBWR Ecosystem
and order how the spell casting works in your item.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleancanCast(net.minecraft.world.item.ItemStack stack, Spell spell, PlayerCastContext ctx) Normally you would call the eventsSpellCastEvent.PreandSpellCastEvent.Tickin order to know when to allow the spell to run, but here you also handle any other conditions to allow casting.booleancast(net.minecraft.world.item.ItemStack stack, Spell spell, PlayerCastContext ctx) This is where you make all the spell cast handling (normally just instant spells).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) Gets the current spell selected in the ItemStack.default @NotNull SpellgetNextSpell(net.minecraft.world.item.ItemStack stack) Gets the next spell in the list of spells.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
Normally you would call the eventsSpellCastEvent.PreandSpellCastEvent.Tickin order to know when to allow the spell to run, but here you also handle any other conditions to allow casting.- Parameters:
stack- The ItemStack to cast the spell fromspell- The spell to castctx- The context of the cast- Returns:
- Whether the spell can be cast or not
-
cast
This is where you make all the spell cast handling (normally just instant spells). For doing the continuous spells you could useItem.onUseTick(Level, LivingEntity, ItemStack, int)- Parameters:
stack- The ItemStack to cast the spell fromspell- The spell to castctx- The context of the cast- Returns:
- Whether the spell was cast successfully or not
-
getCurrentSpell
Gets the current spell selected in the ItemStack. This is used for client-side rendering or spell selection utils.- Parameters:
stack- The ItemStack to get the current spell from- Returns:
- The current spell selected in the ItemStack
-
getNextSpell
Gets the next spell in the list of spells. By default, it just returns the current spell.- Parameters:
stack- The ItemStack to get the next spell from- Returns:
- The next spell in the list of spells or the current spell if there is only one spell allowed
-
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.
-