scoreboard players set @s spell_cost_current 800
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 entity @s[predicate=kiwi2:on_ground] run tag @s add magus_flashfreeze_not_on_ground

execute unless score @s[tag=!magus_flashfreeze_not_on_ground] magus_mana_bar < @s spell_cost_current run particle snowflake ~ ~1 ~ 0.5 0.5 0.5 0.1 50
execute unless score @s[tag=!magus_flashfreeze_not_on_ground] magus_mana_bar < @s spell_cost_current run scoreboard players add @s magus_flashfreeze_timer 200
execute unless score @s[tag=!magus_flashfreeze_not_on_ground] magus_mana_bar < @s spell_cost_current run tag @s add magus_flashfreeze_ongoing
execute unless score @s[tag=!magus_flashfreeze_not_on_ground] magus_mana_bar < @s spell_cost_current run playsound minecraft:block.respawn_anchor.set_spawn master @a ~ ~ ~ 10000 2
execute unless score @s[tag=!magus_flashfreeze_not_on_ground] magus_mana_bar < @s spell_cost_current run schedule function kiwi2:upgrades/classes/magus/spells/tier_4/flashfreeze/flashfreeze_ground_user 1t

execute unless score @s[tag=!magus_flashfreeze_not_on_ground] magus_mana_bar < @s spell_cost_current run playsound minecraft:block.trial_spawner.spawn_item master @a[distance=..12] ~ ~ ~ 1 1
execute unless score @s[tag=!magus_flashfreeze_not_on_ground] magus_mana_bar < @s spell_cost_current run scoreboard players operation @s magus_mana_bar -= @s spell_cost_current

# Not On Ground
execute if entity @s[tag=magus_flashfreeze_not_on_ground] run title @s actionbar {"text": "CANNOT CAST AIRBORNE", "color": "red","bold": true}
execute if entity @s[tag=magus_flashfreeze_not_on_ground] run playsound entity.arrow.hit_player master @s ~ ~ ~ 1 0
execute if entity @s[tag=magus_flashfreeze_not_on_ground] run tag @s remove magus_flashfreeze_not_on_ground