Entity Types - CleverNucleus/DataAttributes Wiki

Every entity registered to the game has an entity type, which has a registry key associated with it (such as the player, which has the registry key minecraft:player). Every entity that is an instance of LivingEntity has an attribute container, which holds all the attributes attached to that entity. An attribute attached to an entity also has a default value (this is different from the default value of the attribute itself, as it can be different for different entities). Data Attributes allows you to add attributes to an entity's attribute container and/or change the default value of attributes already added.

Example 1

Say we want to adjust the maximum health of the player to be 10 instead of the default 20. We create the directory data/namespace/attributes/ where namespace is your modid, or some other unique string of characters if you are making a datapack. Inside of the directory, we add the json file entity_types.json. This json file acts similarly to tags, which means that it doesn't override other datapack entity_types.json files, rather it forms a collection of entries. Inside the file, we add the following:

{
    "values": {
        "minecraft:player": {
            "minecraft:generic.max_health": 10.0
        }
    }
}

Note the presence of the full registry key for the max health attribute, and the full registry key for the entity type for the player. With that, the player will now have a max health of 10.

Example 2

Say we have our mod, examplemod, and we have just created (and registered) the attribute Max Mana. We want to add it to the witch mob and for it to have a default value of 30. Firstly, we know the attribute's registry key: examplemod:max_mana and the witch entity type's registry key: minecraft:witch. We go to the directory data/examplemod/attributes/ and add the json file entity_types.json. Inside the file we add the following:

{
    "values": {
        "minecraft:witch": {
            "examplemod:max_mana": 30.0
        }
    }
}

And that's it. Now the witch has the attribute Max Mana with a default value of 30.