Entity attribute modifiers

Attribute

An Attribute represents a Minecraft entity attribute (max health, movement speed, attack damage, etc.) and its current value. Use it to modify player or entity stats.


Class Methods

apply

await Attribute.apply(player, attribute_type, base_value)

Set an attribute's base value for a player.

# Set max health to 40 (20 hearts)
await Attribute.apply(player, "GENERIC_MAX_HEALTH", 40.0)

# Double movement speed
await Attribute.apply(player, AttributeType.GENERIC_MOVEMENT_SPEED, 0.2)

Attributes

attribute_type

The type of this attribute.

value

The current effective value (base + modifiers).

base_value

The base value before modifiers.


Methods

set_base_value

await attribute.set_base_value(value)

Change the base value of this attribute.


Common Attribute Types

AttributeType Default Description
GENERIC_MAX_HEALTH 20.0 Maximum health (1.0 = half heart)
GENERIC_MOVEMENT_SPEED 0.1 Walk speed
GENERIC_ATTACK_DAMAGE 1.0 Base melee damage
GENERIC_ATTACK_SPEED 4.0 Attack cooldown speed
GENERIC_ARMOR 0.0 Armor points
GENERIC_ARMOR_TOUGHNESS 0.0 Armor toughness
GENERIC_KNOCKBACK_RESISTANCE 0.0 Knockback resistance (0–1)
GENERIC_LUCK 0.0 Luck for loot tables
GENERIC_FLYING_SPEED 0.4 Creative fly speed
# Tank build
await Attribute.apply(player, "GENERIC_MAX_HEALTH", 40.0)
await Attribute.apply(player, "GENERIC_ARMOR", 20.0)
await Attribute.apply(player, "GENERIC_KNOCKBACK_RESISTANCE", 0.5)

# Speed runner build
await Attribute.apply(player, "GENERIC_MOVEMENT_SPEED", 0.2)
await Attribute.apply(player, "GENERIC_ATTACK_SPEED", 8.0)