scoreboard players set @s spell_cost_current 300
scoreboard players operation @s spell_cost_current /= @s mana_efficiency
execute if score @s magus_mana_bar < @s spell_cost_current run function kiwi2:upgrades/classes/magus/spells/not_enough_mana_warning

execute unless score @s magus_mana_bar < @s spell_cost_current run title @s actionbar [{"text": "[ICE WALL]","color": "#22c7d6","bold": true},{"text": " -","bold": false,"color": "red"},{"score": {"name": "@s","objective": "spell_cost_current"},"bold": false,"color": "red"},{"text": " Mana","bold": false,"color": "red"}]

execute unless score @s magus_mana_bar < @s spell_cost_current run function kiwi2:upgrades/classes/magus/spells/wand_stability

execute unless score @s magus_mana_bar < @s spell_cost_current unless entity @s[tag=unstable_spell] run function kiwi2:upgrades/classes/magus/spells/tier_2/ice_wall_create
execute unless score @s magus_mana_bar < @s spell_cost_current if entity @s[tag=unstable_spell] run function kiwi2:upgrades/classes/magus/spells/tier_2/ice_wall_create_unstable

tag @s remove unstable_spell
execute unless score @s magus_mana_bar < @s spell_cost_current run scoreboard players operation @s magus_mana_bar -= @s spell_cost_current