Package net.neoforged.neoforge.common
Class BooleanAttribute
java.lang.Object
net.minecraft.world.entity.ai.attributes.Attribute
net.neoforged.neoforge.common.BooleanAttribute
- All Implemented Interfaces:
IAttributeExtension
public class BooleanAttribute
extends net.minecraft.world.entity.ai.attributes.Attribute
A boolean attribute only has two states, on or off, represented by a value of 0 (false) or 1 (true).
For boolean attributes, only use the following modifier values:
- A value of 1 with
AttributeModifier.Operation.ADD_VALUE
to enable the effect. - A value of -1 with
AttributeModifier.Operation.ADD_MULTIPLIED_TOTAL
to forcibly disable the effect.
Additionally, it permits forcibly disabling the effect through multiply total.
-
Nested Class Summary
Nested classes/interfaces inherited from class net.minecraft.world.entity.ai.attributes.Attribute
net.minecraft.world.entity.ai.attributes.Attribute.Sentiment
-
Field Summary
Fields inherited from class net.minecraft.world.entity.ai.attributes.Attribute
CODEC, MERGED_BLUE, MERGED_GRAY, MERGED_RED, STREAM_CODEC
Fields inherited from interface net.neoforged.neoforge.common.extensions.IAttributeExtension
FORMAT
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble
sanitizeValue
(double value) 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.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.Methods inherited from class net.minecraft.world.entity.ai.attributes.Attribute
getDefaultValue, getDescriptionId, getMergedStyle, getStyle, isClientSyncable, setSentiment, setSyncable
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
-
Constructor Details
-
BooleanAttribute
-
-
Method Details
-
sanitizeValue
public double sanitizeValue(double value) - Overrides:
sanitizeValue
in classnet.minecraft.world.entity.ai.attributes.Attribute
-
toValueComponent
public 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) Description copied from interface: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.
- 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
public net.minecraft.network.chat.MutableComponent toComponent(net.minecraft.world.entity.ai.attributes.AttributeModifier modif, net.minecraft.world.item.TooltipFlag flag) Description copied from interface:IAttributeExtension
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.
-