Interface ModifyItemAttributeModifiersCallback

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ModifyItemAttributeModifiersCallback
Stack-aware attribute modifier callback for foreign items. Instead of using Mixin to change attribute modifiers in items not in your mod, you can use this event instead, either checking the Item itself or using a tag. This event provides you with a guaranteed mutable map you can put attribute modifiers in. Do not use for your own Item classes; see FabricItem.getAttributeModifiers(net.minecraft.item.ItemStack, net.minecraft.entity.EquipmentSlot) instead. For example, the following code modifies a Diamond Helmet to give you five extra hearts when wearing.
 
 ModifyItemAttributeModifiersCallback.EVENT.register((stack, slot, attributeModifiers) -> {
 	if (stack.isOf(Items.DIAMOND_HELMET) && slot.getEntitySlotId() == HEAD_SLOT_ID) {
 		attributeModifiers.put(EntityAttributes.GENERIC_MAX_HEALTH, MODIFIER);
 	}
 });
 
 
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    modifyAttributeModifiers(net.minecraft.item.ItemStack stack, net.minecraft.entity.EquipmentSlot slot, Multimap<net.minecraft.entity.attribute.EntityAttribute,net.minecraft.entity.attribute.EntityAttributeModifier> attributeModifiers)
     
  • Field Details

  • Method Details

    • modifyAttributeModifiers

      void modifyAttributeModifiers(net.minecraft.item.ItemStack stack, net.minecraft.entity.EquipmentSlot slot, Multimap<net.minecraft.entity.attribute.EntityAttribute,net.minecraft.entity.attribute.EntityAttributeModifier> attributeModifiers)