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

public class RangedAttribute extends Attribute
Defines an entity attribute that is limited to a range of values.
  • Field Details

    • minValue

      private final double minValue
      The lowest possible value for the attribute.
    • maxValue

      private final double maxValue
      The highest possible value for the attribute.
  • Constructor Details

    • RangedAttribute

      public RangedAttribute(String pDescriptionId, double pDefaultValue, double pMin, double pMax)
  • 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 between minValue and maxValue.
      Overrides:
      sanitizeValue in class Attribute
      Parameters:
      pValue - The value of the attribute to sanitize.
      Returns:
      The clamped attribute value.