Record Class ItemAttributeModifier
java.lang.Object
java.lang.Record
com.github.thedeathlycow.thermoo.api.attribute.ItemAttributeModifier
- Record Components:
attribute- The attribute this modifier affectsmodifier- The modifier that this applies to the attributeitemPredicate- A type predicate for items this should apply toslot- 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 -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<ItemAttributeModifier> -
Constructor Summary
ConstructorsConstructorDescriptionItemAttributeModifier(net.minecraft.entity.attribute.EntityAttribute attribute, net.minecraft.entity.attribute.EntityAttributeModifier modifier, ItemAttributeModifier.ItemTypePredicate itemPredicate, net.minecraft.entity.EquipmentSlot slot) Creates an instance of aItemAttributeModifierrecord class. -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(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.EntityAttributeReturns the value of theattributerecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of theitemPredicaterecord component.net.minecraft.entity.attribute.EntityAttributeModifiermodifier()Returns the value of themodifierrecord component.net.minecraft.entity.EquipmentSlotslot()Returns the value of theslotrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
CODEC
-
-
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 aItemAttributeModifierrecord class.- Parameters:
attribute- the value for theattributerecord componentmodifier- the value for themodifierrecord componentitemPredicate- the value for theitemPredicaterecord componentslot- the value for theslotrecord 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
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
attribute
public net.minecraft.entity.attribute.EntityAttribute attribute()Returns the value of theattributerecord component.- Returns:
- the value of the
attributerecord component
-
modifier
public net.minecraft.entity.attribute.EntityAttributeModifier modifier()Returns the value of themodifierrecord component.- Returns:
- the value of the
modifierrecord component
-
itemPredicate
Returns the value of theitemPredicaterecord component.- Returns:
- the value of the
itemPredicaterecord component
-
slot
public net.minecraft.entity.EquipmentSlot slot()Returns the value of theslotrecord component.- Returns:
- the value of the
slotrecord component
-