## Run by ldz:magic_barrier
## Runs from animation.magic_barrier.state_check

#scoreboard objectives setdisplay sidebar BarrierState

scoreboard objectives add BeastBarrier dummy
scoreboard objectives add MysticBarrier dummy
scoreboard objectives add ScourgeBarrier dummy
scoreboard objectives add WratihBarrier dummy
scoreboard players add .var BeastBarrier 0
scoreboard players add .var MysticBarrier 0
scoreboard players add .var ScourgeBarrier 0
scoreboard players add .var WratihBarrier 0

execute as @s[family=beast_dungeon_barrier] if score .var BeastBarrier matches -1 at @s run fill ~-1 ~ ~ ~1 ~2 ~ air
execute as @s[family=beast_dungeon_barrier] if score .var BeastBarrier matches -1 at @s unless block ~ ~ ~ air run event entity @s set_barrier_to_disappear

execute as @s[family=mystic_dungeon_barrier] if score .var MysticBarrier matches -1 at @s run fill ~ ~ ~-1 ~ ~2 ~1 air
execute as @s[family=mystic_dungeon_barrier] if score .var MysticBarrier matches -1 at @s unless block ~ ~ ~ air run event entity @s set_barrier_to_disappear

execute as @s[family=scourge_dungeon_barrier] if score .var ScourgeBarrier matches -1 at @s run fill ~ ~ ~-1 ~ ~2 ~1 air
execute as @s[family=scourge_dungeon_barrier] if score .var ScourgeBarrier matches -1 at @s unless block ~ ~ ~ air run event entity @s set_barrier_to_disappear

execute as @s[family=wraith_dungeon_barrier] if score .var WraithBarrier matches -1 at @s run fill ~ ~ ~-1 ~ ~2 ~1 air
execute as @s[family=wraith_dungeon_barrier] if score .var WraithBarrier matches -1 at @s unless block ~ ~ ~ air run event entity @s set_barrier_to_disappear