Description
# Stamina Attributes
This API adds a stamina system controlled by entity attributes.
## Default implementation
LivingEntities can have up to **_generic.max_stamina_** amounts of stamina. Stamina is regenerated by **_generic.stamina_regeneration_** every **_generic.stamina_tick_threshold_** ticks.
When stamina is reduced, regeneration is stopped for **_generic.stamina_regeneration_delay_threshold_** ticks.
When stamina is <= 0, regeneration is stopped for **_generic.depleted_stamina_regeneration_delay_threshold_** ticks.
**_generic.reserved_stamina_** describes the percentage amount of maximum stamina, that is currently not available.
**_generic.item_use_stamina_cost_** is the amount of stamina that is reduced when using an item with a stamina cost.
There are two ways to give an item a stamina cost:
1. Items in the "staminaattributes:using_costs_stamina" item tag reduce stamina by **_generic.item_use_stamina_cost_** when they are used once. When stamina is < 0 the use action is not performed. In that case the item gets a cooldown, configured in the server config.
2. Items in the "staminaattributes:continuous_using_costs_stamina" item tag reduce stamina by **_generic.item_use_stamina_cost_** every tick while they are used. When stamina is < 0, the usage is cancelled. In that case the item gets a cooldown, configured in the server config.
### Default attribute values
- **_generic.max_stamina_**: 10
- **_generic.stamina_regeneration_**: 0
- **_generic.stamina_tick_threshold_**: 20
- **_generic.stamina_regeneration_delay_threshold_**: 20
- **_generic.depleted_stamina_regeneration_delay_threshold_**: 60
- **_generic.reserved_stamina_**: 0
- **_generic.item_use_stamina_cost_**: 0
### Default item tags
"staminaattributes:using_costs_stamina":
```json
{
"values": [
"minecraft:snowball"
]
}
```
"staminaattributes:continuous_using_costs_stamina":
```json
{
"values": [
"minecraft:bow",
"minecraft:crossbow",
"minecraft:shield"
]
}
```
## Customization
When the gamerule "naturalStaminaRegeneration" is true, players have a stamina regeneration of at least 1.
The client config allows customizing the HUD element. The details are explained
in [this wiki article](https://github.com/TheRedBrain/overhauled-damage/wiki/Resource-Bar-Customization).
The server config controls the integration with game mechanics, like stamina costs for various actions like jumping.
## API
Casting a "LivingEntity" to the "StaminaUsingEntity" interface gives access to all relevant methods.