scoreboard players operation @s mana_count -= @s mana_speed

execute if score @s mana_count matches ..0 run scoreboard players add @s mana 1
execute if score @s mana_count matches ..0 run scoreboard players set @s mana_count 10

execute if entity @s[tag=infinite_mana] if score @s mana < @s mana_capacity run scoreboard players operation @s mana = @s mana_capacity
