Interface IAttributeExtension

All Known Implementing Classes:
Attribute, BooleanAttribute, PercentageAttribute, RangedAttribute

public interface IAttributeExtension
  • Field Details

  • Method Details

    • toValueComponent

      default MutableComponent toValueComponent(@Nullable @Nullable AttributeModifier.Operation op, double value, TooltipFlag flag)
      Converts the value of an attribute modifier to the value that will be displayed.

      For multiplicative modifiers, this method is responsible for converting the value to percentage form.

      Parameters:
      op - The operation of the modifier. Null if we are just displaying the raw value and not a modifier.
      value - The value to convert. Either the current attribute value (if null operation) or the attribute modifier's amount.
      flag - The tooltip flag.
      Returns:
      The component form of the formatted value.
    • toComponent

      default MutableComponent toComponent(AttributeModifier modif, TooltipFlag flag)
      Converts an attribute modifier into its tooltip representation.

      This method does not handle formatting of "base" modifiers, such as Attack Damage or Attack Speed.

      The returned component may append additional debug information based on the tooltip flag.

      Parameters:
      modif - The attribute modifier being converted to a component.
      flag - The tooltip flag.
      Returns:
      The component representation of the passed attribute modifier, with debug info appended if enabled.
    • getDebugInfo

      default Component getDebugInfo(AttributeModifier modif, TooltipFlag flag)
      Computes the additional debug information for a given attribute modifier, if the flag is advanced.
      Parameters:
      modif - The attribute modifier being converted to a component.
      flag - The tooltip flag.
      Returns:
      The debug component, or CommonComponents.EMPTY if disabled.
    • getBaseId

      @Nullable default @Nullable ResourceLocation getBaseId()
      Gets the specific ID that represents a "base" (green) modifier for this attribute.
      Returns:
      The ID of the "base" modifier, or null, if no such modifier may exist.
    • toBaseComponent

      default MutableComponent toBaseComponent(double value, double entityBase, boolean merged, TooltipFlag flag)
      Converts a "base" attribute modifier (as dictated by getBaseId()) into a text component.

      Similar to toComponent(net.minecraft.world.entity.ai.attributes.AttributeModifier, net.minecraft.world.item.TooltipFlag), this method is responsible for adding debug information when the tooltip flag is advanced.

      Parameters:
      value - The value to be shown (after having been added to the entity's base value)
      entityBase - The entity's base value for this attribute from LivingEntity.getAttributeBaseValue(Holder).
      merged - If we are displaying a merged base component (which will have a non-merged base component as a child).
      flag - The tooltip flag.
      Returns:
      The component representation of the passed attribute modifier.
    • getMergedStyle

      TextColor getMergedStyle(boolean isPositive)
      Returns the color used by merged attribute modifiers. Only used when NeoForgeMod.enableMergedAttributeTooltips() is active.

      Similarly to Attribute.getStyle(boolean), this method should return a color based on the attribute's Attribute.Sentiment. The returned color should be distinguishable from the color used by Attribute.getStyle(boolean).

      Parameters:
      positive - If the attribute modifier value is positive or not.
    • isNullOrAddition

      static boolean isNullOrAddition(@Nullable @Nullable AttributeModifier.Operation op)
    • self

      private Attribute self()