Record Class ItemAttributeModifier

java.lang.Object
java.lang.Record
com.github.thedeathlycow.thermoo.api.attribute.ItemAttributeModifier
Record Components:
attribute - The attribute this modifier affects
modifier - The modifier that this applies to the attribute
itemPredicate - A type predicate for items this should apply to
slot - The slot this should apply to

@Experimental public record ItemAttributeModifier(net.minecraft.entity.attribute.EntityAttribute attribute, net.minecraft.entity.attribute.EntityAttributeModifier modifier, ItemAttributeModifier.ItemTypePredicate itemPredicate, net.minecraft.entity.EquipmentSlot slot) extends Record
Applies changes to the default attributes of an item. Item attribute modifiers are provided in datapack JSON files at data/<entry namespace>/thermoo/item_attribute_modifier/<entry path>. They are synchronized to clients so that they will properly show up in the item tooltip.

Example JSON file:

     {
          "attribute": "thermoo:generic.heat_resistance",
          "modifier": {
              "uuid": "413a10a0-bf0b-47db-a9a9-2eb3dda3bbaf",
              "name": "Test",
              "value": -1.0,
              "operation": "ADDITION"
          },
          "item": {
              "items": [
                  "minecraft:diamond_helmet",
                  "minecraft:iron_helmet",
                  "minecraft:leather_helmet"
              ]
          },
          "slot": "HEAD"
     }
 

You can also use tags:

     {
          "attribute": "thermoo:generic.heat_resistance",
          "modifier": {
              "uuid": "413a10a0-bf0b-47db-a9a9-2eb3dda3bbaf",
              "name": "Test",
              "value": 2.0,
              "operation": "ADDITION"
          },
          "item": {
              "tag": "scorchful:turtle_armor"
          },
          "slot": "HEAD"
     }
 

This class is experimental and subject to change. Please use the datapack JSON instead of referencing this class directly.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.Codec<ItemAttributeModifier>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    ItemAttributeModifier(net.minecraft.entity.attribute.EntityAttribute attribute, net.minecraft.entity.attribute.EntityAttributeModifier modifier, ItemAttributeModifier.ItemTypePredicate itemPredicate, net.minecraft.entity.EquipmentSlot slot)
    Creates an instance of a ItemAttributeModifier record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    apply(net.minecraft.item.ItemStack stack, net.minecraft.entity.EquipmentSlot slot, com.google.common.collect.Multimap<net.minecraft.entity.attribute.EntityAttribute,net.minecraft.entity.attribute.EntityAttributeModifier> attributeModifiers)
     
    net.minecraft.entity.attribute.EntityAttribute
    Returns the value of the attribute record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    Returns the value of the itemPredicate record component.
    net.minecraft.entity.attribute.EntityAttributeModifier
    Returns the value of the modifier record component.
    net.minecraft.entity.EquipmentSlot
    Returns the value of the slot record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • ItemAttributeModifier

      public ItemAttributeModifier(net.minecraft.entity.attribute.EntityAttribute attribute, net.minecraft.entity.attribute.EntityAttributeModifier modifier, ItemAttributeModifier.ItemTypePredicate itemPredicate, net.minecraft.entity.EquipmentSlot slot)
      Creates an instance of a ItemAttributeModifier record class.
      Parameters:
      attribute - the value for the attribute record component
      modifier - the value for the modifier record component
      itemPredicate - the value for the itemPredicate record component
      slot - the value for the slot record component
  • Method Details

    • apply

      public void apply(net.minecraft.item.ItemStack stack, net.minecraft.entity.EquipmentSlot slot, com.google.common.collect.Multimap<net.minecraft.entity.attribute.EntityAttribute,net.minecraft.entity.attribute.EntityAttributeModifier> attributeModifiers)
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • attribute

      public net.minecraft.entity.attribute.EntityAttribute attribute()
      Returns the value of the attribute record component.
      Returns:
      the value of the attribute record component
    • modifier

      public net.minecraft.entity.attribute.EntityAttributeModifier modifier()
      Returns the value of the modifier record component.
      Returns:
      the value of the modifier record component
    • itemPredicate

      Returns the value of the itemPredicate record component.
      Returns:
      the value of the itemPredicate record component
    • slot

      public net.minecraft.entity.EquipmentSlot slot()
      Returns the value of the slot record component.
      Returns:
      the value of the slot record component