Class Attribute
java.lang.Object
net.minecraft.world.entity.ai.attributes.Attribute
- All Implemented Interfaces:
IAttributeExtension
- Direct Known Subclasses:
BooleanAttribute
,RangedAttribute
Defines an entity attribute. These are properties of entities that can be dynamically modified.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final double
The default value of the attribute.private final String
A description Id for the attribute.protected static final TextColor
protected static final TextColor
protected static final TextColor
private Attribute.Sentiment
static final StreamCodec
<RegistryFriendlyByteBuf, Holder<Attribute>> private boolean
Whether the value of this attribute should be kept in sync on the client.Fields inherited from interface net.neoforged.neoforge.common.extensions.IAttributeExtension
FORMAT
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble
getMergedStyle
(boolean isPositive) Returns the color used by merged attribute modifiers.getStyle
(boolean pIsPositive) boolean
double
sanitizeValue
(double pValue) Sanitizes the value of the attribute to fit within the expected parameter range of the attribute.setSentiment
(Attribute.Sentiment pSentiment) setSyncable
(boolean pWatch) Sets whether the attribute value should be synced to the client.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.neoforged.neoforge.common.extensions.IAttributeExtension
getBaseId, getDebugInfo, toBaseComponent, toComponent, toValueComponent
-
Field Details
-
CODEC
-
STREAM_CODEC
-
defaultValue
private final double defaultValueThe default value of the attribute. -
syncable
private boolean syncableWhether the value of this attribute should be kept in sync on the client. -
descriptionId
A description Id for the attribute. This is most commonly used as the localization key. -
sentiment
-
MERGED_RED
-
MERGED_BLUE
-
MERGED_GRAY
-
-
Constructor Details
-
Attribute
-
-
Method Details
-
getDefaultValue
public double getDefaultValue() -
isClientSyncable
public boolean isClientSyncable() -
setSyncable
Sets whether the attribute value should be synced to the client.- Parameters:
pWatch
- Whether the attribute value should be kept in sync.- Returns:
- The same attribute instance being modified.
-
setSentiment
-
sanitizeValue
public double sanitizeValue(double pValue) Sanitizes the value of the attribute to fit within the expected parameter range of the attribute.- Parameters:
pValue
- The value of the attribute to sanitize.- Returns:
- The sanitized attribute value.
-
getDescriptionId
-
getStyle
-
getMergedStyle
Description copied from interface:IAttributeExtension
Returns the color used by merged attribute modifiers. Only used whenNeoForgeMod.enableMergedAttributeTooltips()
is active.Similarly to
getStyle(boolean)
, this method should return a color based on the attribute'sAttribute.Sentiment
. The returned color should be distinguishable from the color used bygetStyle(boolean)
.- Specified by:
getMergedStyle
in interfaceIAttributeExtension
-