Class ExpandItemAttributeModifierEvent

java.lang.Object
com.blamejared.crafttweaker.natives.event.item.ExpandItemAttributeModifierEvent

@ZenRegister public class ExpandItemAttributeModifierEvent extends Object
This event is fired when the attributes for an ItemStack are being calculated. Attributes are calculated on the server when equipping and un-equipping an item to add and remove attributes respectively, both must be consistent. Attributes are calculated on the client when rendering an item's tooltip to show relevant attributes.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final IEventBus<net.minecraftforge.event.ItemAttributeModifierEvent>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    addModifier(net.minecraftforge.event.ItemAttributeModifierEvent internal, net.minecraft.world.entity.ai.attributes.Attribute attribute, String name, double value, net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation operation)
    Adds a new AttributeModifier to the ItemStack.
    static boolean
    addModifier(net.minecraftforge.event.ItemAttributeModifierEvent internal, net.minecraft.world.entity.ai.attributes.Attribute attribute, String uuid, String name, double value, net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation operation)
    Adds a new AttributeModifier to the ItemStack.
    static void
    clearModifiers(net.minecraftforge.event.ItemAttributeModifierEvent internal)
    Clears all AttributeModifiers from the ItemStack.
    static IItemStack
    getItemStack(net.minecraftforge.event.ItemAttributeModifierEvent internal)
    Gets the ItemStack that this event is being ran for.
    static Map<net.minecraft.world.entity.ai.attributes.Attribute,List<net.minecraft.world.entity.ai.attributes.AttributeModifier>>
    getModifiers(net.minecraftforge.event.ItemAttributeModifierEvent internal)
    Gets the modifiers on the ItemStack
    static Map<net.minecraft.world.entity.ai.attributes.Attribute,List<net.minecraft.world.entity.ai.attributes.AttributeModifier>>
    getOriginalModifiers(net.minecraftforge.event.ItemAttributeModifierEvent internal)
    Gets the original modifiers on the ItemStack before being changed by any other event listener.
    static net.minecraft.world.entity.EquipmentSlot
    getSlotType(net.minecraftforge.event.ItemAttributeModifierEvent internal)
    Gets the EquipmentSlotType that this event is being ran for.
    static List<net.minecraft.world.entity.ai.attributes.AttributeModifier>
    removeAttribute(net.minecraftforge.event.ItemAttributeModifierEvent internal, net.minecraft.world.entity.ai.attributes.Attribute attribute)
    Removes an Attribute from the ItemStack.
    static boolean
    removeModifier(net.minecraftforge.event.ItemAttributeModifierEvent internal, net.minecraft.world.entity.ai.attributes.Attribute attribute, String uuid)
    Removes an AttributeModifier from the ItemStack based on the modifier's UUID.
    static boolean
    removeModifier(net.minecraftforge.event.ItemAttributeModifierEvent internal, net.minecraft.world.entity.ai.attributes.Attribute attribute, net.minecraft.world.entity.ai.attributes.AttributeModifier modifier)
    Removes an AttributeModifier from the ItemStack.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • BUS

      public static final IEventBus<net.minecraftforge.event.ItemAttributeModifierEvent> BUS
  • Constructor Details

    • ExpandItemAttributeModifierEvent

      public ExpandItemAttributeModifierEvent()
  • Method Details

    • getModifiers

      public static Map<net.minecraft.world.entity.ai.attributes.Attribute,List<net.minecraft.world.entity.ai.attributes.AttributeModifier>> getModifiers(net.minecraftforge.event.ItemAttributeModifierEvent internal)
      Gets the modifiers on the ItemStack
      Returns:
      A Map of Attribute to a List of AttributeModifier.
    • getOriginalModifiers

      public static Map<net.minecraft.world.entity.ai.attributes.Attribute,List<net.minecraft.world.entity.ai.attributes.AttributeModifier>> getOriginalModifiers(net.minecraftforge.event.ItemAttributeModifierEvent internal)
      Gets the original modifiers on the ItemStack before being changed by any other event listener.
      Returns:
      A Map of Attribute to a List of AttributeModifier.
    • addModifier

      public static boolean addModifier(net.minecraftforge.event.ItemAttributeModifierEvent internal, net.minecraft.world.entity.ai.attributes.Attribute attribute, String name, double value, net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation operation)
      Adds a new AttributeModifier to the ItemStack.
      Parameters:
      attribute - The Attribute to add.
      name - The name of the modifier to add
      value - The value of the modifier.
      operation - The operation of the modifier.
      Returns:
      True if the modifier was added. False otherwise.
      DocParam:
      attribute <attribute:minecraft:generic.attack_damage>, name "Extra Power", value 10, operation AttributeOperation.ADDITION
    • addModifier

      public static boolean addModifier(net.minecraftforge.event.ItemAttributeModifierEvent internal, net.minecraft.world.entity.ai.attributes.Attribute attribute, String uuid, String name, double value, net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation operation)
      Adds a new AttributeModifier to the ItemStack.
      Parameters:
      attribute - The Attribute to add.
      uuid - The UUID of the modifier.
      name - The name of the modifier.
      value - The value of the modifier.
      operation - The operation of the modifier.
      Returns:
      True if the modifier was added. False otherwise.
      DocParam:
      attribute <attribute:minecraft:generic.attack_damage>, uuid "8c1b5535-9f79-448b-87ae-52d81480aaa3", name "Extra Power", value 10, operation AttributeOperation.ADDITION
    • removeModifier

      public static boolean removeModifier(net.minecraftforge.event.ItemAttributeModifierEvent internal, net.minecraft.world.entity.ai.attributes.Attribute attribute, String uuid)
      Removes an AttributeModifier from the ItemStack based on the modifier's UUID.
      Parameters:
      attribute - The Attribute to remove.
      uuid - The UUID of the modifier.
      Returns:
      True if the modifier was remove. False otherwise.
      DocParam:
      attribute <attribute:minecraft:generic.attack_damage>, uuid "8c1b5535-9f79-448b-87ae-52d81480aaa3"
    • removeModifier

      public static boolean removeModifier(net.minecraftforge.event.ItemAttributeModifierEvent internal, net.minecraft.world.entity.ai.attributes.Attribute attribute, net.minecraft.world.entity.ai.attributes.AttributeModifier modifier)
      Removes an AttributeModifier from the ItemStack.
      Parameters:
      attribute - The Attribute to remove.
      modifier - The modifier to remove.
      Returns:
      True if the modifier was remove. False otherwise.
      DocParam:
      attribute <attribute:minecraft:generic.attack_damage>, modifier modifier
    • removeAttribute

      public static List<net.minecraft.world.entity.ai.attributes.AttributeModifier> removeAttribute(net.minecraftforge.event.ItemAttributeModifierEvent internal, net.minecraft.world.entity.ai.attributes.Attribute attribute)
      Removes an Attribute from the ItemStack.
      Parameters:
      attribute - The Attribute to remove.
      Returns:
      A List of the AttributeModifiers for the removed Attribute.
      DocParam:
      attribute <attribute:minecraft:generic.attack_damage>
    • clearModifiers

      public static void clearModifiers(net.minecraftforge.event.ItemAttributeModifierEvent internal)
      Clears all AttributeModifiers from the ItemStack.
    • getSlotType

      public static net.minecraft.world.entity.EquipmentSlot getSlotType(net.minecraftforge.event.ItemAttributeModifierEvent internal)
      Gets the EquipmentSlotType that this event is being ran for. If you only want to add / remove a modifier from a specific slot, you can use this to filter based on the slot.
      Returns:
      The EquipmentSlotType of this event.
    • getItemStack

      public static IItemStack getItemStack(net.minecraftforge.event.ItemAttributeModifierEvent internal)
      Gets the ItemStack that this event is being ran for.
      Returns:
      The ItemStack this event is being ran for.