Class WizardArmorItem

java.lang.Object
net.minecraft.world.item.Item
net.minecraft.world.item.ArmorItem
com.binaris.wizardry.content.item.armor.WizardArmorItem
All Implemented Interfaces:
ICustomAttributesItem, ICustomDamageItem, IElementValue, IManaItem, IWorkbenchItem, net.fabricmc.fabric.api.item.v1.FabricItem, net.minecraft.world.flag.FeatureElement, net.minecraft.world.item.Equipable, net.minecraft.world.item.Vanishable, net.minecraft.world.level.ItemLike
Direct Known Subclasses:
BattleMageArmorItem, SageArmorItem, WarlockArmorItem

public class WizardArmorItem extends net.minecraft.world.item.ArmorItem implements IManaItem, ICustomDamageItem, IWorkbenchItem, IElementValue, ICustomAttributesItem
Base class for all wizard armor items in Electroblob's Wizardry Redux.

This provides the mana storage, full armor checking and helper methods to apply new SpellModifiers and set bonuses depending on your armor type. Subclasses of this class will have the deletion of the entity attributes (Protection), spell modifiers and full set bonus if mana is 0 in any of the armor pieces.

To create a new armor via addon, extend this class and override the relevant hooks:

By default, this already handles the cost reduction when cast a spell with the same element as the armor, increment potency, check cooldown reduction based on the armor type and include the tooltip lines for these bonuses. But you can override these methods to customize/delete any of these behaviors.
  • Nested Class Summary

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

    net.minecraft.world.item.ArmorItem.Type

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

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

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

    DISPENSE_ITEM_BEHAVIOR, knockbackResistance, material, type

    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
    WizardArmorItem(WizardArmorType material, net.minecraft.world.item.ArmorItem.Type type, Element element)
     
    WizardArmorItem(net.minecraft.world.item.ArmorItem.Type type, Element element)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    appendHoverText(@NotNull net.minecraft.world.item.ItemStack stack, net.minecraft.world.level.Level world, @NotNull List<net.minecraft.network.chat.Component> tooltip, @NotNull net.minecraft.world.item.TooltipFlag advanced)
     
    void
    applyModifiers(net.minecraft.world.entity.LivingEntity entity, SpellModifiers modifiers, WizardArmorItem armor, Spell spell)
    Hook for applying additional SpellModifiers when the caster is wearing the full armor set with mana.
    net.minecraft.world.item.ItemStack
    applyUpgrade(@Nullable net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack stack, net.minecraft.world.item.ItemStack upgrade)
     
    boolean
    canBreak(net.minecraft.world.item.ItemStack stack)
    used to control whether the item can be broken or if it should stay at 0 durability
    static void
    collectArmorModifiers(net.minecraft.world.entity.player.Player caster, Spell spell, SpellModifiers out)
     
    void
    effectTick(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.level.Level level)
    Called every inventoryTick when the entity is wearing the full armor set and all pieces have mana.
    int
    getBarColor(@NotNull net.minecraft.world.item.ItemStack stack)
     
    com.google.common.collect.Multimap<net.minecraft.world.entity.ai.attributes.Attribute,net.minecraft.world.entity.ai.attributes.AttributeModifier>
    getCustomAttributes(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.EquipmentSlot slot)
     
    Gets the element associated with this item.
    int
    getMana(net.minecraft.world.item.ItemStack stack)
     
    int
    getManaCapacity(net.minecraft.world.item.ItemStack stack)
     
    @NotNull net.minecraft.network.chat.Component
    getName(@NotNull net.minecraft.world.item.ItemStack stack)
     
    int
    getSpellSlotCount(net.minecraft.world.item.ItemStack stack)
     
     
    void
    inventoryTick(@NotNull net.minecraft.world.item.ItemStack stack, @NotNull net.minecraft.world.level.Level level, @NotNull net.minecraft.world.entity.Entity entity, int slotId, boolean isSelected)
     
    boolean
    isValidRepairItem(@NotNull net.minecraft.world.item.ItemStack toRepair, @NotNull net.minecraft.world.item.ItemStack repair)
     
    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)
     
    static void
     
    void
    setCustomDamage(net.minecraft.world.item.ItemStack stack, int damage)
    exposing a new way to control when and how damage is set
    void
    setMana(net.minecraft.world.item.ItemStack stack, int mana)
     
    boolean
    showTooltip(net.minecraft.world.item.ItemStack stack)
     
    boolean
    Determines if this item is valid for use in a receptacle.

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

    dispenseArmor, getDefaultAttributeModifiers, getDefense, getEnchantmentValue, getEquipmentSlot, getEquipSound, getMaterial, getToughness, getType, use

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

    asItem, builtInRegistryHolder, byBlock, byId, canAttackBlock, canBeDepleted, canBeHurtBy, canFitInsideContainerItems, finishUsingItem, getBarWidth, getCraftingRemainingItem, getDefaultInstance, getDescription, getDescriptionId, getDescriptionId, getDestroySpeed, getDrinkingSound, getEatingSound, getFoodProperties, getId, getMaxDamage, getMaxStackSize, getOrCreateDescriptionId, getPlayerPOVHitResult, getRarity, getTooltipImage, getUseAnimation, getUseDuration, hasCraftingRemainingItem, hurtEnemy, interactLivingEntity, isBarVisible, isComplex, isCorrectToolForDrops, isEdible, isEnchantable, isFireResistant, isFoil, mineBlock, onCraftedBy, onDestroyed, onUseTick, overrideOtherStackedOnMe, overrideStackedOnOther, releaseUsing, 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.item.Equipable

    swapWithEquipmentSlot

    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.ICustomDamageItem

    getCustomMaxDamage

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

    consumeMana, getFullness, isManaEmpty, isManaFull, rechargeMana, showManaInWorkbench

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

    canPlace, isClearable, onClearButtonPressed
  • Constructor Details

    • WizardArmorItem

      public WizardArmorItem(WizardArmorType material, net.minecraft.world.item.ArmorItem.Type type, Element element)
    • WizardArmorItem

      public WizardArmorItem(net.minecraft.world.item.ArmorItem.Type type, Element element)
  • Method Details

    • effectTick

      public void effectTick(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.level.Level level)
      Called every inventoryTick when the entity is wearing the full armor set and all pieces have mana. In case you want to apply a specific effect without the full set check override inventoryTick instead.
      Parameters:
      stack - the armor item stack
      entity - the entity wearing the armor
      level - the current level (world)
    • applyModifiers

      public void applyModifiers(net.minecraft.world.entity.LivingEntity entity, SpellModifiers modifiers, WizardArmorItem armor, Spell spell)
      Hook for applying additional SpellModifiers when the caster is wearing the full armor set with mana. Called from applySpellModifiers(net.minecraft.world.entity.LivingEntity, com.binaris.wizardry.content.item.armor.WizardArmorItem, com.binaris.wizardry.api.content.spell.Spell, com.binaris.wizardry.api.content.spell.internal.SpellModifiers) after base modifiers (elemental cost reduction, cooldown reduction) have already been applied.
      Parameters:
      entity - the entity casting the spell
      modifiers - the modifiers being built, modify this in place
      armor - the specific armor piece triggering this call
      spell - the spell being cast
    • appendHoverText

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

      public void inventoryTick(@NotNull @NotNull net.minecraft.world.item.ItemStack stack, @NotNull @NotNull net.minecraft.world.level.Level level, @NotNull @NotNull net.minecraft.world.entity.Entity entity, int slotId, boolean isSelected)
      Overrides:
      inventoryTick in class net.minecraft.world.item.Item
    • onSpellPreCast

      public static void onSpellPreCast(SpellCastEvent.Pre event)
    • collectArmorModifiers

      public static void collectArmorModifiers(net.minecraft.world.entity.player.Player caster, Spell spell, SpellModifiers out)
    • applyUpgrade

      public net.minecraft.world.item.ItemStack applyUpgrade(@Nullable @Nullable net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack stack, net.minecraft.world.item.ItemStack upgrade)
      Specified by:
      applyUpgrade 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
    • setCustomDamage

      public void setCustomDamage(net.minecraft.world.item.ItemStack stack, int damage)
      Description copied from interface: ICustomDamageItem
      exposing a new way to control when and how damage is set
      Specified by:
      setCustomDamage in interface ICustomDamageItem
    • canBreak

      public boolean canBreak(net.minecraft.world.item.ItemStack stack)
      Description copied from interface: ICustomDamageItem
      used to control whether the item can be broken or if it should stay at 0 durability
      Specified by:
      canBreak in interface ICustomDamageItem
    • 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
    • getWizardArmorType

      public WizardArmorType getWizardArmorType()
    • getElement

      public Element getElement()
      Description copied from interface: IElementValue
      Gets the element associated with this item.
      Specified by:
      getElement in interface IElementValue
      Returns:
      The element of the item.
    • validForReceptacle

      public boolean validForReceptacle()
      Description copied from interface: IElementValue
      Determines if this item is valid for use in a receptacle.
      Specified by:
      validForReceptacle in interface IElementValue
      Returns:
      true if the item can be used in a receptacle, false otherwise.
    • getBarColor

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

      public int getMana(net.minecraft.world.item.ItemStack stack)
      Specified by:
      getMana in interface IManaItem
    • setMana

      public void setMana(net.minecraft.world.item.ItemStack stack, int mana)
      Specified by:
      setMana in interface IManaItem
    • getManaCapacity

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

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

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

      public boolean isValidRepairItem(@NotNull @NotNull net.minecraft.world.item.ItemStack toRepair, @NotNull @NotNull net.minecraft.world.item.ItemStack repair)
      Overrides:
      isValidRepairItem in class net.minecraft.world.item.ArmorItem
    • getCustomAttributes

      public com.google.common.collect.Multimap<net.minecraft.world.entity.ai.attributes.Attribute,net.minecraft.world.entity.ai.attributes.AttributeModifier> getCustomAttributes(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.EquipmentSlot slot)
      Specified by:
      getCustomAttributes in interface ICustomAttributesItem