Mana Attributes
This API adds a mana system controlled by entity attributes.
Default implementation
LivingEntities can have up to _manaattributes:maxmana amounts of mana. Mana is regenerated by _manaattributes:manaregeneration every _manaattributes:mana_tickthreshold ticks.
When mana is reduced, regeneration is stopped for _manaattributes:mana_regeneration_delaythreshold ticks.
When mana is <= 0, regeneration is stopped for _manaattributes:depleted_mana_regeneration_delaythreshold ticks.
_manaattributes:reservedmana describes the percentage amount of maximum mana that is currently not available.
Default attribute values
- _manaattributes:maxmana: 0
- _manaattributes:manaregeneration: 0
- _manaattributes:mana_tickthreshold: 20
- _manaattributes:mana_regeneration_delaythreshold: 20
- _manaattributes:depleted_mana_regeneration_delaythreshold: 60
- _manaattributes:reservedmana: 0
All default values for players can be set in the server config.
Customization
The client config allows customizing the HUD element.
Using the mana system
Java
Casting a "LivingEntity" to the "ManaUsingEntity" interface gives access to all relevant methods.
Data packs
Mana Attributes implements several data driven methods to interact with the current mana value of an entity.
- the "manaattributes:add_mana" enchantment effect allows adding a defined amount to the current mana
- the "manaattributes:mana_using_entity" entity sub predicate passes when the current mana of an entity matches the defined range
Example
This enchantment reduces mana of the attacker by 2, as long as the attacker has at least 5 mana:
{
"anvil_cost": 1,
"description": {
"translate": "enchantment.manaattributes.test"
},
"effects": {
"minecraft:post_attack": [
{
"affected": "attacker",
"effect": {
"type": "manaattributes:add_mana",
"amount": {
"type": "minecraft:linear",
"base": -2.0,
"per_level_above_first": -2.0
}
},
"enchanted": "attacker",
"requirements": {
"condition": "minecraft:entity_properties",
"entity": "direct_attacker",
"predicate": {
"type_specific": {
"type": "manaattributes:mana_using_entity",
"mana_amount": {
"min": 5.0
}
}
}
}
}
]
},
"max_cost": {
"base": 25,
"per_level_above_first": 8
},
"max_level": 1,
"min_cost": {
"base": 5,
"per_level_above_first": 8
},
"slots": [
"hand"
],
"supported_items": "#minecraft:swords",
"weight": 5
} How to Install Mana Attributes (Mod)
Mana Attributes by TheRedBrain is verified for Fabric across Minecraft versions 1.20.1, 1.21, 1.21.1, 1.21.10, 1.21.11, 26.1, 26.1.1, 26.1.2 (latest release: 4.0.0, file size: 107 KB). Follow the steps below to install it safely from ModCraft.tv:
- Click the Download button above and select your Minecraft version (1.20.1, 1.21, 1.21.1, 1.21.10, 1.21.11, 26.1, 26.1.1, 26.1.2) and platform (Fabric).
- Make sure you have the compatible loader or environment installed for Fabric.
- Move the downloaded Mana Attributes file into your Minecraft
.minecraft/modsfolder and launch the game.
All Versions
+ Add Version| Name | Game version | Platforms | Published | Downloads | Actions |
|---|---|---|---|---|---|
|
R
4.0.0
|
7mo ago | 1 | |||
|
R
3.2.1
|
7mo ago | 1 | |||
|
R
3.2.0
|
9mo ago | 1 | |||
|
R
3.1.0
|
9mo ago | 1 | |||
|
R
3.0.0
|
last yr. | 1 | |||
|
R
2.9.1
|
last yr. | 1 | |||
|
R
2.9.0
|
last yr. | 1 | |||
|
R
2.8.1
|
last yr. | 1 | |||
|
R
2.8.0
|
last yr. | 1 | |||
|
R
2.7.0
|
last yr. | 1 | |||
|
R
1.6.1
|
last yr. | 1 | |||
|
R
1.6.0
|
last yr. | 1 | |||
|
R
2.6.0
|
last yr. | 1 | |||
|
R
1.5.1
|
last yr. | 1 | |||
|
R
2.5.1
|
last yr. | 1 | |||
|
R
2.4.0
|
last yr. | 1 | |||
|
R
1.4.0
|
last yr. | 1 | |||
|
R
2.3.0
|
last yr. | 1 | |||
|
R
2.2.0
|
last yr. | 1 | |||
|
R
2.1.0
|
last yr. | 1 | |||
|
R
1.3.0
|
last yr. | 1 | |||
|
R
2.0.0
|
last yr. | 1 | |||
|
R
1.2.0
|
last yr. | 1 | |||
|
R
1.1.0
|
last yr. | 1 | |||
|
R
1.0.1
|
last yr. | 1 | |||
|
R
1.0.0
|
last yr. | 1 |
- updated to 26.1.x
## Fixes
- fixed an issue where respawning would no longer reset mana after re-joining a world
## Additions
- readded API methods to set and get current mana
- added "manaattributes:add_mana" enchantment effect
- added "manaattributes:mana_using_entity" entity sub predicate
- the mana icon bar now blinks when mana changes, similar to the vanilla health bar. This can be disabled in the client config.
- the mana icon bar now displays reserved mana
## Fixes
- fixed mana for players on respawn/joining a world
- fixed regeneration delay
- updated to 1.21.11
## Changes
- regeneration delay timers no longer apply when joining a world
## Technical
- migrated to Mojang Mappings
- replace synced data with a data attachment, following the best practice for custom entity data
- updated to 1.21.10
## Additions
## Changes
- removed "generic." prefix from all entity attributes, following vanillas example
## Fixes
- fixed wrong server config name. Sorry for the inconvenience this might have caused!
- fixed mana bar being empty when joining a world for the first time
- bumped various dependency versions
- replaced game rules with server config options
- tweaked default client config settings
- fixed mana bar being empty when joining a world / respawning
- fixed game rules
- added "naturalMaximumMana" game rule
- changed default value of "generic.max_mana" to 0
- reworked the "naturalManaRegeneration" game rule (now is a double value, instead of a boolean)
- added alternative mana bar consisting of icons, similar to vanillas resource bars (this first iteration does not yet support multiple icon types per bar, e.g. reserved mana)
- reworked the "naturalManaRegeneration" game rule (now works with mods that display attribute values)
- fixed an issue where the mana bar was empty when joining a world for the first time/respawning
- fixed an issue where the mana bar was visible in creative mode
- fixed an issue where the mana bar was visible even when the HUD was hidden (pressing F1)
- removed debug log spam
HUD rendering overhaul
The initial idea of splitting a bar into three textures per "layer" to allow for easy change of the bar length, came with the cost of massive FPS drops.
With this rewrite the bar size is no longer changeable with a simple config option. Each 'layer' consists of only 1 texture (which can have configurable dimensions).
In addition, the texture can be dynamically replaced by another texture (with configurable dimensions) depending on the max value.
- removed 'is_centered' option, as it was redundant and unnecessarily complicated
- 'fill_direction' no longer chooses between a horizontal and a vertical 'texture set', it only determines the direction from which the bar is filled. This means that changing between horizontal and vertical resource bars also requires a texture change.
- added the option to display an icon (with configurable texture id and dimensions). This can be toggled independently of the bar and the number.
- changed default value of "generic.max_mana" to 10
HUD rendering overhaul
The initial idea of splitting a bar into three textures per "layer" to allow for easy change of the bar length, came with the cost of massive FPS drops.
With this rewrite the bar size is no longer changeable with a simple config option. Each 'layer' consists of only 1 texture (which can have configurable dimensions).
In addition, the texture can be dynamically replaced by another texture (with configurable dimensions) depending on the max value.
- removed 'is_centered' option, as it was redundant and unnecessarily complicated
- 'fill_direction' no longer chooses between a horizontal and a vertical 'texture set', it only determines the direction from which the bar is filled. This means that changing between horizontal and vertical resource bars also requires a texture change.
- added the option to display an icon (with configurable texture id and dimensions). This can be toggled independently of the bar and the number.
- changed default value of "generic.max_mana" to 10
- fixed "offset_from_origin" config values not working correctly
- mana number display is now independent of the mana bar
- fixed "offset_from_origin" config values not working correctly
- mana number display is now independent of the mana bar