Class ScrollItem

java.lang.Object
net.minecraft.world.item.Item
com.binaris.wizardry.content.item.ScrollItem
All Implemented Interfaces:
ICastItem, IWorkbenchItem, net.fabricmc.fabric.api.item.v1.FabricItem, net.minecraft.world.flag.FeatureElement, net.minecraft.world.level.ItemLike

public class ScrollItem extends net.minecraft.world.item.Item implements ICastItem, 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, 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)
    Normally you would call the events SpellCastEvent.Pre and SpellCastEvent.Tick in order to know when to allow the spell to run, but here you also handle any other conditions to allow casting.
    boolean
    canPlace(net.minecraft.world.item.ItemStack stack)
     
    boolean
    cast(net.minecraft.world.item.ItemStack stack, Spell spell, PlayerCastContext ctx)
    This is where you make all the spell cast handling (normally just instant spells).
    @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)
    Gets the current spell selected in the ItemStack.
    @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, getTooltipImage, getUseAnimation, hasCraftingRemainingItem, hurtEnemy, interactLivingEntity, inventoryTick, isBarVisible, isComplex, isCorrectToolForDrops, isEdible, isEnchantable, isFireResistant, 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.fabricmc.fabric.api.item.v1.FabricItem

    allowContinuingBlockBreaking, allowNbtUpdateAnimation, getAttributeModifiers, getRecipeRemainder, isSuitableFor

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

    isEnabled

    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: ICastItem
      Normally you would call the events SpellCastEvent.Pre and SpellCastEvent.Tick in order to know when to allow the spell to run, but here you also handle any other conditions to allow casting.
      Specified by:
      canCast in interface ICastItem
      Parameters:
      stack - The ItemStack to cast the spell from
      spell - The spell to cast
      ctx - The context of the cast
      Returns:
      Whether the spell can be cast or not
    • cast

      public boolean cast(net.minecraft.world.item.ItemStack stack, Spell spell, PlayerCastContext ctx)
      Description copied from interface: ICastItem
      This is where you make all the spell cast handling (normally just instant spells). For doing the continuous spells you could use Item.onUseTick(Level, LivingEntity, ItemStack, int)
      Specified by:
      cast in interface ICastItem
      Parameters:
      stack - The ItemStack to cast the spell from
      spell - The spell to cast
      ctx - The context of the cast
      Returns:
      Whether the spell was cast successfully or not
    • 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: ICastItem
      Gets the current spell selected in the ItemStack. This is used for client-side rendering or spell selection utils.
      Specified by:
      getCurrentSpell in interface ICastItem
      Parameters:
      stack - The ItemStack to get the current spell from
      Returns:
      The current spell selected in the ItemStack
    • showSpellHUD

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