Class ScrollItem

java.lang.Object
net.minecraft.world.item.Item
com.binaris.wizardry.content.item.ScrollItem
All Implemented Interfaces:
ISpellCastingItem, IWorkbenchItem, net.minecraft.world.flag.FeatureElement, net.minecraft.world.level.ItemLike, net.minecraftforge.common.extensions.IForgeItem

public class ScrollItem extends net.minecraft.world.item.Item implements ISpellCastingItem, IWorkbenchItem
Scroll Item!! Fast and easy way to use spells

Compared to wands, scrolls are single use items that allow the player to cast a single spell without any mana/charge cost. They are consumed upon use. You can think of them as disposable spellcasting items.

  • Nested Class Summary

    Nested classes/interfaces inherited from class net.minecraft.world.item.Item

    net.minecraft.world.item.Item.Properties
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The limit time for a continuous spell cast from a scroll.
    static final int
    Cooldown applied when a spell cast is canceled by forfeit (or any listener from SpellPreCast/SpellTickCast)

    Fields inherited from class net.minecraft.world.item.Item

    BASE_ATTACK_DAMAGE_UUID, BASE_ATTACK_SPEED_UUID, BY_BLOCK, canRepair, EAT_DURATION, MAX_BAR_WIDTH, MAX_STACK_SIZE

    Fields inherited from interface net.minecraft.world.flag.FeatureElement

    FILTERED_REGISTRIES
  • Constructor Summary

    Constructors
    Constructor
    Description
    ScrollItem(net.minecraft.world.item.Item.Properties properties)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    appendHoverText(@NotNull net.minecraft.world.item.ItemStack stack, @Nullable net.minecraft.world.level.Level level, @NotNull List<net.minecraft.network.chat.Component> list, @NotNull net.minecraft.world.item.TooltipFlag tooltipFlag)
     
    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
    canPlace(net.minecraft.world.item.ItemStack stack)
     
    boolean
    cast(net.minecraft.world.item.ItemStack stack, Spell spell, PlayerCastContext ctx)
    The items implementing this interface are responsible about how to use this.
    @NotNull net.minecraft.world.item.ItemStack
    finishUsingItem(@NotNull net.minecraft.world.item.ItemStack stack, @NotNull net.minecraft.world.level.Level level, @NotNull net.minecraft.world.entity.LivingEntity livingEntity)
     
    @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.
    @NotNull net.minecraft.network.chat.Component
    getName(@NotNull net.minecraft.world.item.ItemStack stack)
     
    int
    getSpellSlotCount(net.minecraft.world.item.ItemStack stack)
     
    int
    getUseDuration(@NotNull net.minecraft.world.item.ItemStack stack)
     
    boolean
    isFoil(@NotNull net.minecraft.world.item.ItemStack stack)
     
    boolean
    onApplyButtonPressed(net.minecraft.world.entity.player.Player player, net.minecraft.world.inventory.Slot centre, net.minecraft.world.inventory.Slot crystals, net.minecraft.world.inventory.Slot upgrade, net.minecraft.world.inventory.Slot[] spellBooks)
     
    void
    onUseTick(@NotNull net.minecraft.world.level.Level level, @NotNull net.minecraft.world.entity.LivingEntity livingEntity, @NotNull net.minecraft.world.item.ItemStack stack, int timeLeft)
     
    void
    releaseUsing(@NotNull net.minecraft.world.item.ItemStack stack, @NotNull net.minecraft.world.level.Level level, @NotNull net.minecraft.world.entity.LivingEntity livingEntity, int timeCharged)
     
    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.
    boolean
    showTooltip(net.minecraft.world.item.ItemStack stack)
     
    @NotNull net.minecraft.world.InteractionResultHolder<net.minecraft.world.item.ItemStack>
    use(@NotNull net.minecraft.world.level.Level level, net.minecraft.world.entity.player.Player player, @NotNull net.minecraft.world.InteractionHand hand)
     

    Methods inherited from class net.minecraft.world.item.Item

    asItem, builtInRegistryHolder, byBlock, byId, canAttackBlock, canBeDepleted, canBeHurtBy, canFitInsideContainerItems, getBarColor, getBarWidth, getCraftingRemainingItem, getDefaultAttributeModifiers, getDefaultInstance, getDescription, getDescriptionId, getDescriptionId, getDestroySpeed, getDrinkingSound, getEatingSound, getEnchantmentValue, getFoodProperties, getId, getMaxDamage, getMaxStackSize, getOrCreateDescriptionId, getPlayerPOVHitResult, getRarity, getRenderPropertiesInternal, getTooltipImage, getUseAnimation, hasCraftingRemainingItem, hurtEnemy, initializeClient, interactLivingEntity, inventoryTick, isBarVisible, isComplex, isCorrectToolForDrops, isEdible, isEnchantable, isFireResistant, isRepairable, isValidRepairItem, mineBlock, onCraftedBy, onDestroyed, overrideOtherStackedOnMe, overrideStackedOnOther, requiredFeatures, shouldOverrideMultiplayerNbt, toString, useOn, useOnRelease, verifyTagAfterLoad

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface net.minecraft.world.flag.FeatureElement

    isEnabled

    Methods inherited from interface net.minecraftforge.common.extensions.IForgeItem

    canApplyAtEnchantingTable, canContinueUsing, canDisableShield, canElytraFly, canEquip, canGrindstoneRepair, canPerformAction, canWalkOnPowderedSnow, createEntity, damageItem, doesSneakBypassUse, elytraFlightTick, getAllEnchantments, getArmorTexture, getAttributeModifiers, getBurnTime, getCraftingRemainingItem, getCreatorModId, getDamage, getDefaultTooltipHideFlags, getEnchantmentLevel, getEnchantmentValue, getEntityLifespan, getEquipmentSlot, getFoodProperties, getHighlightTip, getMaxDamage, getMaxStackSize, getShareTag, getSweepHitBox, getXpRepairRatio, hasCraftingRemainingItem, hasCustomEntity, initCapabilities, isBookEnchantable, isCorrectToolForDrops, isDamageable, isDamaged, isEnderMask, isNotReplaceableByPickAction, isPiglinCurrency, makesPiglinsNeutral, onArmorTick, onBlockStartBreak, onDestroyed, onDroppedByPlayer, onEntityItemUpdate, onEntitySwing, onHorseArmorTick, onInventoryTick, onItemUseFirst, onLeftClickEntity, onStopUsing, readShareTag, setDamage, shouldCauseBlockBreakReset, shouldCauseReequipAnimation

    Methods inherited from interface com.binaris.wizardry.api.content.item.IWorkbenchItem

    applyUpgrade, isClearable, onClearButtonPressed
  • Field Details

    • CASTING_TIME

      public static final int CASTING_TIME
      The limit time for a continuous spell cast from a scroll.
      See Also:
    • COOLDOWN_FORFEIT_TICKS

      public static final int COOLDOWN_FORFEIT_TICKS
      Cooldown applied when a spell cast is canceled by forfeit (or any listener from SpellPreCast/SpellTickCast)
      See Also:
  • Constructor Details

    • ScrollItem

      public ScrollItem(net.minecraft.world.item.Item.Properties properties)
  • Method Details

    • use

      @NotNull public @NotNull net.minecraft.world.InteractionResultHolder<net.minecraft.world.item.ItemStack> use(@NotNull @NotNull net.minecraft.world.level.Level level, net.minecraft.world.entity.player.Player player, @NotNull @NotNull net.minecraft.world.InteractionHand hand)
      Overrides:
      use in class net.minecraft.world.item.Item
    • onUseTick

      public void onUseTick(@NotNull @NotNull net.minecraft.world.level.Level level, @NotNull @NotNull net.minecraft.world.entity.LivingEntity livingEntity, @NotNull @NotNull net.minecraft.world.item.ItemStack stack, int timeLeft)
      Overrides:
      onUseTick in class net.minecraft.world.item.Item
    • canCast

      public boolean canCast(net.minecraft.world.item.ItemStack stack, Spell spell, PlayerCastContext ctx)
      Description copied from interface: ISpellCastingItem
      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.

      Specified by:
      canCast in interface ISpellCastingItem
    • cast

      public boolean cast(net.minecraft.world.item.ItemStack stack, Spell spell, PlayerCastContext ctx)
      Description copied from interface: ISpellCastingItem
      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)
      Specified by:
      cast in interface ISpellCastingItem
    • appendHoverText

      public void appendHoverText(@NotNull @NotNull net.minecraft.world.item.ItemStack stack, @Nullable @Nullable net.minecraft.world.level.Level level, @NotNull @NotNull List<net.minecraft.network.chat.Component> list, @NotNull @NotNull net.minecraft.world.item.TooltipFlag tooltipFlag)
      Overrides:
      appendHoverText in class net.minecraft.world.item.Item
    • finishUsingItem

      @NotNull public @NotNull net.minecraft.world.item.ItemStack finishUsingItem(@NotNull @NotNull net.minecraft.world.item.ItemStack stack, @NotNull @NotNull net.minecraft.world.level.Level level, @NotNull @NotNull net.minecraft.world.entity.LivingEntity livingEntity)
      Overrides:
      finishUsingItem in class net.minecraft.world.item.Item
    • releaseUsing

      public void releaseUsing(@NotNull @NotNull net.minecraft.world.item.ItemStack stack, @NotNull @NotNull net.minecraft.world.level.Level level, @NotNull @NotNull net.minecraft.world.entity.LivingEntity livingEntity, int timeCharged)
      Overrides:
      releaseUsing in class net.minecraft.world.item.Item
    • getCurrentSpell

      @NotNull public @NotNull Spell getCurrentSpell(net.minecraft.world.item.ItemStack stack)
      Description copied from interface: ISpellCastingItem
      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
      Specified by:
      getCurrentSpell in interface ISpellCastingItem
    • showSpellHUD

      public boolean showSpellHUD(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack stack)
      Description copied from interface: ISpellCastingItem
      Returns whether the spell HUD should be shown when a player is holding this item. Only called client-side.
      Specified by:
      showSpellHUD in interface ISpellCastingItem
    • isFoil

      public boolean isFoil(@NotNull @NotNull net.minecraft.world.item.ItemStack stack)
      Overrides:
      isFoil in class net.minecraft.world.item.Item
    • getName

      @NotNull public @NotNull net.minecraft.network.chat.Component getName(@NotNull @NotNull net.minecraft.world.item.ItemStack stack)
      Overrides:
      getName in class net.minecraft.world.item.Item
    • getUseDuration

      public int getUseDuration(@NotNull @NotNull net.minecraft.world.item.ItemStack stack)
      Overrides:
      getUseDuration in class net.minecraft.world.item.Item
    • showTooltip

      public boolean showTooltip(net.minecraft.world.item.ItemStack stack)
      Specified by:
      showTooltip in interface IWorkbenchItem
    • onApplyButtonPressed

      public boolean onApplyButtonPressed(net.minecraft.world.entity.player.Player player, net.minecraft.world.inventory.Slot centre, net.minecraft.world.inventory.Slot crystals, net.minecraft.world.inventory.Slot upgrade, net.minecraft.world.inventory.Slot[] spellBooks)
      Specified by:
      onApplyButtonPressed in interface IWorkbenchItem
    • getSpellSlotCount

      public int getSpellSlotCount(net.minecraft.world.item.ItemStack stack)
      Specified by:
      getSpellSlotCount in interface IWorkbenchItem
    • canPlace

      public boolean canPlace(net.minecraft.world.item.ItemStack stack)
      Specified by:
      canPlace in interface IWorkbenchItem