Name | Attribute Modifiers |
Description | In minecraft, the "attributes" system defined certain core numerical values on entities, such as max health or attack damage.
The value of an "attribute" is determined by its "base value" modified mathematically by each of its "attribute modififers". "Attribute modifiers" can be added either directly to the entity, or onto items - when on an item, an entity can equip it into the correct slot to automatically apply the modifier. These can be read via such tags as EntityTag.attribute_modifiers, ItemTag.attribute_modifiers, EntityTag.has_attribute, EntityTag.attribute_value, EntityTag.attribute_base_value, EntityTag.attribute_default_value, ... These can be modified by such mechanisms as EntityTag.attribute_base_values, EntityTag.attribute_modifiers, EntityTag.add_attribute_modifiers, EntityTag.remove_attribute_modifiers, ItemTag.attribute_modifiers, ItemTag.add_attribute_modifiers, ItemTag.remove_attribute_modifiers, ... The input format of each of the 'add' and set mechanisms is slightly complicated: a MapTag where the keys are attribute names, and values are a ListTag of modifiers, where each modifier is itself a MapTag with required keys 'operation' and 'amount', and additionally: Before MC 1.21: optional 'name', 'slot', and 'id' keys. The default ID will be randomly generated, the default name will be the attribute name. After MC 1.21: required 'key' key, and optional 'slot'. The 'key' is the attribute's name/identifier in a "namespace:key" format (defaulting to the "minecraft" namespace), which has to be distinct to other modifiers of the same type on the object. Valid operations: ADD_NUMBER, ADD_SCALAR, and MULTIPLY_SCALAR_1 Valid slots (used up to MC 1.20.6): HAND, OFF_HAND, FEET, LEGS, CHEST, HEAD, ANY Valid slot groups (used on MC 1.20.6+): https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/EquipmentSlotGroup.html Valid attribute names are listed at https://hub.spigotmc.org/javadocs/spigot/org/bukkit/attribute/Attribute.html The default slot/slot group is "any". Operation names are based on the Bukkit enum. ADD_NUMBER corresponds to Mojang "ADDITION" - adds on top of the base value. ADD_SCALAR corresponds to Mojang "MULTIPLY_BASE" - adds to the total, multiplied by the base value. MULTIPLY_SCALAR_1 corresponds to Mojang "MULTIPLY_TOTAL", multiplies the final value (after both "add_number" and "add_scaler") by the amount given plus one. They are combined like (pseudo-code):
See also https://minecraft.wiki/w/Attribute#Modifiers For a quick and dirty in-line input, you can do for example: [generic_max_health=<list[<map[key=my_project:add_health;operation=ADD_NUMBER;amount=20;slot=HEAD]>]>] For more clean/proper input, instead do something like:
When pre-defining a custom item, instead of this, simply use an item script: item script containers. That page shows an example of valid attribute modifiers on an item script. |
Group | Properties |
Source | https://github.com/DenizenScript/Denizen/blob/dev/plugin/src/main/java/com/denizenscript/denizen/objects/properties/entity/EntityAttributeModifiers.java#L208 |