Class RangedAttribute
java.lang.Object
net.minecraft.world.entity.ai.attributes.Attribute
net.minecraft.world.entity.ai.attributes.RangedAttribute
- All Implemented Interfaces:
IAttributeExtension
- Direct Known Subclasses:
PercentageAttribute
Defines an entity attribute that is limited to a range of values.
-
Nested Class Summary
Nested classes/interfaces inherited from class net.minecraft.world.entity.ai.attributes.Attribute
Attribute.Sentiment -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final doubleThe highest possible value for the attribute.private final doubleThe lowest possible value for the attribute.Fields inherited from class net.minecraft.world.entity.ai.attributes.Attribute
CODEC, MERGED_BLUE, MERGED_GRAY, MERGED_RED, STREAM_CODECFields inherited from interface net.neoforged.neoforge.common.extensions.IAttributeExtension
FORMAT -
Constructor Summary
ConstructorsConstructorDescriptionRangedAttribute(String pDescriptionId, double pDefaultValue, double pMin, double pMax) -
Method Summary
Modifier and TypeMethodDescriptiondoubledoubledoublesanitizeValue(double pValue) Sanitizes the value of the attribute to fit within the expected parameter range of the attribute.Methods inherited from class net.minecraft.world.entity.ai.attributes.Attribute
getDefaultValue, getDescriptionId, getMergedStyle, getStyle, isClientSyncable, setSentiment, setSyncableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.neoforged.neoforge.common.extensions.IAttributeExtension
getBaseId, getDebugInfo, toBaseComponent, toComponent, toValueComponent
-
Field Details
-
minValue
private final double minValueThe lowest possible value for the attribute. -
maxValue
private final double maxValueThe highest possible value for the attribute.
-
-
Constructor Details
-
RangedAttribute
-
-
Method Details
-
getMinValue
public double getMinValue() -
getMaxValue
public double getMaxValue() -
sanitizeValue
public double sanitizeValue(double pValue) Sanitizes the value of the attribute to fit within the expected parameter range of the attribute. In this case it will clamp the value betweenminValueandmaxValue.- Overrides:
sanitizeValuein classAttribute- Parameters:
pValue- The value of the attribute to sanitize.- Returns:
- The clamped attribute value.
-