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.

@Experimental @FunctionalInterface public interface ModifyItemAttributeModifiersCallback
Stack-aware event for modifying the default attribute modifier component of an item. This should only be used for items external to your mod, such as vanilla items or items from other mods.

This does not modify the actual attribute modifiers component, instead it adjusts the attributes that are used when applied to an entity or displaying the tooltip.

This is an experimental event, it may not work fully as expected or impact performance. Proceed with caution.

Example: This listener adds max health to all helmets

 
  ModifyItemAttributeModifiersCallback.EVENT.register((stack, builder) -> {
  	if (stack.isIn(ItemTags.HEAD_ARMOR)) {
          builder.add(EntityAttributes.MAX_HEALTH, MODIFIER, AttributeModifierSlot.HEAD);
      }
  });
 
 
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final net.fabricmc.fabric.api.event.Event<ModifyItemAttributeModifiersCallback>
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    modifyAttributeModifiers(net.minecraft.world.item.ItemStack stack, net.minecraft.world.item.component.ItemAttributeModifiers.Builder builder)
     
  • Field Details

  • Method Details

    • modifyAttributeModifiers

      void modifyAttributeModifiers(net.minecraft.world.item.ItemStack stack, net.minecraft.world.item.component.ItemAttributeModifiers.Builder builder)