Interface IAttributeExtension
- All Known Implementing Classes:
Attribute
,BooleanAttribute
,PercentageAttribute
,RangedAttribute
public interface IAttributeExtension
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault @Nullable ResourceLocation
Gets the specific ID that represents a "base" (green) modifier for this attribute.default Component
getDebugInfo
(AttributeModifier modif, TooltipFlag flag) Computes the additional debug information for a given attribute modifier, if the flag is advanced.getMergedStyle
(boolean isPositive) Returns the color used by merged attribute modifiers.static boolean
isNullOrAddition
(@Nullable AttributeModifier.Operation op) private Attribute
self()
default MutableComponent
toBaseComponent
(double value, double entityBase, boolean merged, TooltipFlag flag) Converts a "base" attribute modifier (as dictated bygetBaseId()
) into a text component.default MutableComponent
toComponent
(AttributeModifier modif, TooltipFlag flag) Converts an attribute modifier into its tooltip representation.default MutableComponent
toValueComponent
(@Nullable AttributeModifier.Operation op, double value, TooltipFlag flag) Converts the value of an attribute modifier to the value that will be displayed.
-
Field Details
-
FORMAT
-
-
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
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
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
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 bygetBaseId()
) 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 fromLivingEntity.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
Returns the color used by merged attribute modifiers. Only used whenNeoForgeMod.enableMergedAttributeTooltips()
is active.Similarly to
Attribute.getStyle(boolean)
, this method should return a color based on the attribute'sAttribute.Sentiment
. The returned color should be distinguishable from the color used byAttribute.getStyle(boolean)
.- Parameters:
positive
- If the attribute modifier value is positive or not.
-
isNullOrAddition
-
self
-