Interface IAttributeExtension
- All Known Implementing Classes:
net.minecraft.world.entity.ai.attributes.Attribute
,BooleanAttribute
,PercentageAttribute
,net.minecraft.world.entity.ai.attributes.RangedAttribute
public interface IAttributeExtension
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault @Nullable net.minecraft.resources.ResourceLocation
Gets the specific ID that represents a "base" (green) modifier for this attribute.default net.minecraft.network.chat.Component
getDebugInfo
(net.minecraft.world.entity.ai.attributes.AttributeModifier modif, net.minecraft.world.item.TooltipFlag flag) Computes the additional debug information for a given attribute modifier, if the flag is advanced.net.minecraft.network.chat.TextColor
getMergedStyle
(boolean isPositive) Returns the color used by merged attribute modifiers.static boolean
isNullOrAddition
(@Nullable net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation op) private net.minecraft.world.entity.ai.attributes.Attribute
self()
default net.minecraft.network.chat.MutableComponent
toBaseComponent
(double value, double entityBase, boolean merged, net.minecraft.world.item.TooltipFlag flag) Converts a "base" attribute modifier (as dictated bygetBaseId()
) into a text component.default net.minecraft.network.chat.MutableComponent
toComponent
(net.minecraft.world.entity.ai.attributes.AttributeModifier modif, net.minecraft.world.item.TooltipFlag flag) Converts an attribute modifier into its tooltip representation.default net.minecraft.network.chat.MutableComponent
toValueComponent
(@Nullable net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation op, double value, net.minecraft.world.item.TooltipFlag flag) Converts the value of an attribute modifier to the value that will be displayed.
-
Field Details
-
FORMAT
-
-
Method Details
-
toValueComponent
default net.minecraft.network.chat.MutableComponent toValueComponent(@Nullable @Nullable net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation op, double value, net.minecraft.world.item.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 net.minecraft.network.chat.MutableComponent toComponent(net.minecraft.world.entity.ai.attributes.AttributeModifier modif, net.minecraft.world.item.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 net.minecraft.network.chat.Component getDebugInfo(net.minecraft.world.entity.ai.attributes.AttributeModifier modif, net.minecraft.world.item.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 net.minecraft.resources.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 net.minecraft.network.chat.MutableComponent toBaseComponent(double value, double entityBase, boolean merged, net.minecraft.world.item.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
net.minecraft.network.chat.TextColor getMergedStyle(boolean isPositive) 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
static boolean isNullOrAddition(@Nullable @Nullable net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation op) -
self
private net.minecraft.world.entity.ai.attributes.Attribute self()
-