类 PercentageAttribute

所有已实现的接口:
IAttributeExtension

public class PercentageAttribute extends RangedAttribute
A Percentage Attribute is one which always displays modifiers as percentages, including for AttributeModifier.Operation.ADD_VALUE.

This is used for attributes that would not make sense being displayed as flat additions (ex: +0.05 Swim Speed).

  • 字段详细资料

    • scaleFactor

      protected final double scaleFactor
  • 构造器详细资料

    • PercentageAttribute

      public PercentageAttribute(String pDescriptionId, double pDefaultValue, double pMin, double pMax, double scaleFactor)
      Creates a new PercentageAttribute with the given description, value information, and scale factor.

      If your attribute's "real" value correlates 1 == 100%, you would use a scale factor of 100 to convert to 1 to 100%.

      参数:
      pDescriptionId - The description id used for generating the attribute's lang key.
      pDefaultValue - The default value of the attribute
      pMin - The minimum value
      pMax - The maximum value
      scaleFactor - The scale factor, used to convert the literal value to a percentage value.
    • PercentageAttribute

      public PercentageAttribute(String pDescriptionId, double pDefaultValue, double pMin, double pMax)
      Creates a new PercentageAttribute with the default scale factor of 100.
      另请参阅:
  • 方法详细资料

    • toValueComponent

      public MutableComponent toValueComponent(AttributeModifier.Operation op, double value, TooltipFlag flag)
      从接口复制的说明: IAttributeExtension
      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.

      参数:
      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.
      返回:
      The component form of the formatted value.