scoreboard players set @s spell_cost_current 100
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 effect give @e[distance=..4] levitation 10 0 true
execute unless score @s magus_mana_bar < @s spell_cost_current at @e[distance=..4] run particle falling_dust{block_state:white_concrete} ~ ~1 ~ 0.7 0.7 0.7 0.1 20
execute unless score @s magus_mana_bar < @s spell_cost_current at @e[distance=..4] run particle end_rod ~ ~ ~ 0 0 0 0 1
execute unless score @s magus_mana_bar < @s spell_cost_current at @e[distance=..4] run particle end_rod ~ ~1 ~ 0 0 0 0 1
execute unless score @s magus_mana_bar < @s spell_cost_current at @e[distance=..4] run particle end_rod ~ ~2 ~ 0 0 0 0 1
execute unless score @s magus_mana_bar < @s spell_cost_current at @e[distance=..4] run particle end_rod ~ ~3 ~ 0 0 0 0 1
execute unless score @s magus_mana_bar < @s spell_cost_current at @e[distance=..4] run particle end_rod ~ ~4 ~ 0 0 0 0 1
execute unless score @s magus_mana_bar < @s spell_cost_current at @e[distance=..4] run particle end_rod ~ ~5 ~ 0 0 0 0 1
execute unless score @s magus_mana_bar < @s spell_cost_current at @e[distance=..4] run particle end_rod ~ ~6 ~ 0 0 0 0 1
execute unless score @s magus_mana_bar < @s spell_cost_current at @e[distance=..4] run particle end_rod ~ ~7 ~ 0 0 0 0 1
execute unless score @s magus_mana_bar < @s spell_cost_current run playsound minecraft:entity.shulker.shoot master @a[distance=..15] ~ ~ ~ 1 1

execute unless score @s magus_mana_bar < @s spell_cost_current run title @s actionbar [{"text": "[LEVITATE]","color": "white","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 run scoreboard players operation @s magus_mana_bar -= @s spell_cost_current