Overrides 1.17.1 - CleverNucleus/DataAttributes Wiki

Entity attributes have four data points that can be overridden using json files; see the following.

Json overrides can be used to either override pre-existing attributes, either vanilla or modded, or if non exist a new attribute is created. Therefore, new entity attributes can be created using just json files. The json files follow a particular format; example 1 shows how armor would be formatted:

Example 1

Minecraft's armor attribute has the following:

default value = 0.0
minimum value = 0.0
maximum value = 30.0
translation key = "attribute.name.generic.armor"

Say we want to change the maximum armor value to 100.0: we need to know the attribute's registry key, which is comprised of a namespace and a path. In this case, the registry key is minecraft:generic.armor. In the directory data/minecraft/attributes/overrides/ we create a json file generic.armor.json. Note how the registry key's namespace matches our directory's namespace, and the registry key's path matches our file name.

We add the following to generic.armor.json:

{
    "defaultValue": 0.0,
    "minValue": 0.0,
    "maxValue": 100.0,
    "translationKey": "attribute.name.generic.armor"
}

That's it. Now the maximum value for armor is 100. Similarly, we can use this same methodology to create a new attribute - for example:

Example 2

Say we have a mod with a modid examplemod, and we want to add the attribute max_mana. We create the directory data/examplemod/attributes/overrides/ and create the json file max_mana.json. Inside the json file add the following:

{
    "defaultValue": 0.0,
    "minValue": 0.0,
    "maxValue": 10000.0,
    "translationKey": "examplemod.attribute.name.max_mana"
}

We now have an attribute registered to the game. In our language file we can add the translation key entry like so:

"examplemod.attribute.name.max_mana": "Max Mana"

Although our attribute is registered to the game, it won't be present on any living entity yet. The next step is to attach it to an entity's attribute container - see Entity Types.