execute if entity @s[tag=!freeze] run scoreboard players add @s n_effects 1

execute if entity @s[tag=!freeze] run scoreboard players operation @s freeze = duration n_effects
execute if entity @s[tag=freeze] if score @s freeze < duration n_effects run scoreboard players operation @s freeze = duration n_effects

tag @s add freeze

execute as @e[type=#effects:hard_freeze] run data merge entity @s {NoAI:1b}
execute at @s run playsound custom.effect.freeze ambient @a ~ ~ ~

execute unless predicate effects:is_baby at @s run particle item ice ~ ~.7 ~ .2 .7 .2 0 40 force
execute unless predicate effects:is_baby at @s run particle falling_dust ice ~ ~.7 ~ .2 .7 .2 0 40 force
execute if predicate effects:is_baby at @s run particle item ice ~ ~.2 ~ .1 .2 .1 0 30 force
execute if predicate effects:is_baby at @s run particle falling_dust ice ~ ~.2 ~ .1 .2 .1 0 30 force
