Skip to content

Attribute

endstone.attribute

Classes relevant to attributes.

Classes:

Name Description
Attribute

All attribute types.

AttributeInstance

Represents a mutable instance of an attribute and its associated modifiers and values.

AttributeModifier

Represents an attribute modifier.

Attribute

All attribute types.

Attributes:

Name Type Description
ABSORPTION Identifier[Attribute]
ATTACK_DAMAGE Identifier[Attribute]
FOLLOW_RANGE Identifier[Attribute]
HEALTH Identifier[Attribute]
JUMP_STRENGTH Identifier[Attribute]
KNOCKBACK_RESISTANCE Identifier[Attribute]
LAVA_MOVEMENT_SPEED Identifier[Attribute]
LUCK Identifier[Attribute]
MOVEMENT_SPEED Identifier[Attribute]
PLAYER_EXHAUSTION Identifier[Attribute]
PLAYER_EXPERIENCE Identifier[Attribute]
PLAYER_HUNGER Identifier[Attribute]
PLAYER_LEVEL Identifier[Attribute]
PLAYER_SATURATION Identifier[Attribute]
UNDERWATER_MOVEMENT_SPEED Identifier[Attribute]
ZOMBIE_SPAWN_REINFORCEMENTS Identifier[Attribute]

ABSORPTION class-attribute instance-attribute

ABSORPTION: Identifier[Attribute] = 'minecraft:absorption'

ATTACK_DAMAGE class-attribute instance-attribute

ATTACK_DAMAGE: Identifier[Attribute] = (
    "minecraft:attack_damage"
)

FOLLOW_RANGE class-attribute instance-attribute

FOLLOW_RANGE: Identifier[Attribute] = (
    "minecraft:follow_range"
)

HEALTH class-attribute instance-attribute

HEALTH: Identifier[Attribute] = 'minecraft:health'

JUMP_STRENGTH class-attribute instance-attribute

JUMP_STRENGTH: Identifier[Attribute] = (
    "minecraft:jump_strength"
)

KNOCKBACK_RESISTANCE class-attribute instance-attribute

KNOCKBACK_RESISTANCE: Identifier[Attribute] = (
    "minecraft:knockback_resistance"
)

LAVA_MOVEMENT_SPEED class-attribute instance-attribute

LAVA_MOVEMENT_SPEED: Identifier[Attribute] = (
    "minecraft:lava_movement"
)

LUCK class-attribute instance-attribute

LUCK: Identifier[Attribute] = 'minecraft:luck'

MOVEMENT_SPEED class-attribute instance-attribute

MOVEMENT_SPEED: Identifier[Attribute] = "minecraft:movement"

PLAYER_EXHAUSTION class-attribute instance-attribute

PLAYER_EXHAUSTION: Identifier[Attribute] = (
    "minecraft:player.exhaustion"
)

PLAYER_EXPERIENCE class-attribute instance-attribute

PLAYER_EXPERIENCE: Identifier[Attribute] = (
    "minecraft:player.experience"
)

PLAYER_HUNGER class-attribute instance-attribute

PLAYER_HUNGER: Identifier[Attribute] = (
    "minecraft:player.hunger"
)

PLAYER_LEVEL class-attribute instance-attribute

PLAYER_LEVEL: Identifier[Attribute] = (
    "minecraft:player.level"
)

PLAYER_SATURATION class-attribute instance-attribute

PLAYER_SATURATION: Identifier[Attribute] = (
    "minecraft:player.saturation"
)

UNDERWATER_MOVEMENT_SPEED class-attribute instance-attribute

UNDERWATER_MOVEMENT_SPEED: Identifier[Attribute] = (
    "minecraft:underwater_movement"
)

ZOMBIE_SPAWN_REINFORCEMENTS class-attribute instance-attribute

ZOMBIE_SPAWN_REINFORCEMENTS: Identifier[Attribute] = (
    "minecraft:zombie.spawn_reinforcements"
)

AttributeInstance

Represents a mutable instance of an attribute and its associated modifiers and values.

Methods:

Name Description
add_modifier

Add a modifier to this instance.

add_transient_modifier

Add a transient modifier to this instance. Transient modifiers are not persisted (saved with the NBT data).

get_modifier

Gets the modifier with the corresponding id.

remove_modifier

Attributes:

Name Type Description
base_value float

Base value of this instance before modifiers are applied.

max_value float

The maximum value this instance is allowed to take. Bedrock-specific.

min_value float

The minimum value this instance is allowed to take. Bedrock-specific.

modifiers list[AttributeModifier]

All modifiers present on this instance.

type Identifier[Attribute]

The attribute type pertaining to this instance.

value float

The value of this instance after all associated modifiers have been applied.

base_value property writable

base_value: float

Base value of this instance before modifiers are applied.

max_value property writable

max_value: float

The maximum value this instance is allowed to take. Bedrock-specific.

min_value property writable

min_value: float

The minimum value this instance is allowed to take. Bedrock-specific.

modifiers property

modifiers: list[AttributeModifier]

All modifiers present on this instance.

type property

type: Identifier[Attribute]

The attribute type pertaining to this instance.

value property

value: float

The value of this instance after all associated modifiers have been applied.

add_modifier

add_modifier(modifier: AttributeModifier) -> None

Add a modifier to this instance.

Parameters:

Name Type Description Default
modifier AttributeModifier

Modifier to add.

required

add_transient_modifier

add_transient_modifier(modifier: AttributeModifier) -> None

Add a transient modifier to this instance. Transient modifiers are not persisted (saved with the NBT data).

Parameters:

Name Type Description Default
modifier AttributeModifier

Modifier to add.

required

get_modifier

get_modifier(
    id: Identifier[AttributeModifier] | str,
) -> AttributeModifier | None

Gets the modifier with the corresponding id.

Parameters:

Name Type Description Default
id Identifier[AttributeModifier] | str

The id of the modifier.

required

Returns:

Type Description
AttributeModifier | None

The modifier, or None if no modifier with the given id is present.

remove_modifier

remove_modifier(modifier: AttributeModifier) -> None
remove_modifier(
    id: Identifier[AttributeModifier] | str,
) -> None

AttributeModifier

AttributeModifier(
    id: Identifier[AttributeModifier] | str,
    amount: float,
    operation: Operation,
)

Represents an attribute modifier.

Classes:

Name Description
Operation

Operation to be applied.

Attributes:

Name Type Description
ADD
CAP
MULTIPLY
MULTIPLY_BASE
amount float

The amount by which this modifier will apply its operation.

id Identifier[AttributeModifier]

The id of this modifier.

operation Operation

The operation this modifier will apply.

ADD class-attribute instance-attribute

ADD = ADD

CAP class-attribute instance-attribute

CAP = CAP

MULTIPLY class-attribute instance-attribute

MULTIPLY = MULTIPLY

MULTIPLY_BASE class-attribute instance-attribute

MULTIPLY_BASE = MULTIPLY_BASE

amount property

amount: float

The amount by which this modifier will apply its operation.

id property

id: Identifier[AttributeModifier]

The id of this modifier.

operation property

operation: Operation

The operation this modifier will apply.

Operation

Bases: Enum

Operation to be applied.

Attributes:

Name Type Description
ADD

Adds (or subtracts) the specified amount to the base value.

CAP

Caps the value of the attribute at the modifier's amount. Bedrock-specific operation with no Bukkit equivalent.

MULTIPLY

For every modifier, multiplies the current value of the attribute by (1 + x), where x is the amount of the particular modifier.

MULTIPLY_BASE

Multiplies the current value of the attribute by (1 + x), where x is the sum of the modifiers' amounts.

ADD class-attribute instance-attribute
ADD = 0

Adds (or subtracts) the specified amount to the base value.

CAP class-attribute instance-attribute
CAP = 3

Caps the value of the attribute at the modifier's amount. Bedrock-specific operation with no Bukkit equivalent.

MULTIPLY class-attribute instance-attribute
MULTIPLY = 2

For every modifier, multiplies the current value of the attribute by (1 + x), where x is the amount of the particular modifier.

MULTIPLY_BASE class-attribute instance-attribute
MULTIPLY_BASE = 1

Multiplies the current value of the attribute by (1 + x), where x is the sum of the modifiers' amounts.