## Run from "controller.animation.dungeon_lever.powered_state"
## @s = ldz:dungeon_lever

scoreboard objectives add BeastBarrier dummy
scoreboard objectives add MysticBarrier dummy
scoreboard objectives add ScourgeBarrier dummy
scoreboard objectives add WraithBarrier dummy

playsound entity.dungeon_lever.deactivate @a ~ ~ ~

## PORTAL ROOM LEVER MOVING UP
execute as @s[family=portal_room_lever] run tellraw @a[tag=dev] { "rawtext": [ { "text": "§9Portal Room Lever Deactivated" } ] }
execute as @s[family=portal_room_lever] run event entity @e[type=ldz:magic_barrier,family=portal_room_barrier] despawn
execute as @s[family=portal_room_lever] run summon ldz:magic_barrier 104 167 53 0 0 portal_room_barrier_levered
execute as @s[family=portal_room_lever] at @e[type=ldz:magic_barrier,family=portal_room_barrier] run fill ~-1 ~ ~ ~1 ~2 ~ ldz:tinted_barrier_z


## BEAST HUB LEVER MOVING UP
execute as @s[family=beast_lever_hub] run tellraw @a[tag=dev] { "rawtext": [ { "text": "§9Beast Hub Lever Deactivated" } ] }
execute as @s[family=beast_lever_hub] run event entity @e[type=ldz:magic_barrier,family=beast_hub_barrier] despawn
execute as @s[family=beast_lever_hub] run summon ldz:magic_barrier 104 149 15 0 0 beast_hub_barrier_levered
execute as @s[family=beast_lever_hub] at @e[type=ldz:magic_barrier,family=beast_hub_barrier] run fill ~-1 ~ ~ ~1 ~2 ~ ldz:tinted_barrier_neg_z

## BEAST DUNGEON
execute as @s[family=beast_lever_dungeon] run tellraw @a[tag=dev] { "rawtext": [ { "text": "§9Beast Dungeon Lever Deactivated" } ] }
execute as @s[family=beast_lever_dungeon] run event entity @e[type=ldz:magic_barrier,family=beast_dungeon_barrier] despawn
execute as @s[family=beast_lever_dungeon] run scoreboard players set .var BeastBarrier 1
execute as @s[family=beast_lever_dungeon] run scoreboard objectives remove MagicBarrierDB
execute as @s[family=beast_lever_dungeon] run scoreboard objectives add MagicBarrierDB dummy
execute as @s[family=beast_lever_dungeon] run summon ldz:magic_barrier ~ ~-10 ~ 0 0 beast_dungeon_barrier_levered
execute as @s[family=beast_lever_dungeon] run scoreboard players set @e[type=ldz:magic_barrier,family=beast_dungeon_barrier,c=1] MagicBarrierDB 1
execute as @s[family=beast_lever_dungeon] at @s if entity @e[type=ldz:ender_chef,r=5] run summon ldz:help_bubble 81.85 155.25 -482 0 0 beast_bubble
execute as @s[family=beast_lever_dungeon] at @s if entity @e[type=ldz:ender_chef,r=5] run scoreboard players set @e[family=beast_bubble] BeastBubble 1
execute as @s[family=beast_lever_dungeon] run playsound entity.magic_barrier.spawn @a ~ ~ ~ 0.3
execute as @s[family=beast_lever_dungeon] run setblock ~ ~-1 ~ ldz:ender_copper
teleport @e[type=ldz:magic_barrier,family=beast_dungeon_barrier] 82 153 -480

## MYSTIC HUB LEVER MOVING UP
execute as @s[family=mystic_lever_hub] run tellraw @a[tag=dev] { "rawtext": [ { "text": "§9Mystic Hub Lever Deactivated" } ] }
execute as @s[family=mystic_lever_hub] run event entity @e[type=ldz:magic_barrier,family=mystic_hub_barrier] despawn
execute as @s[family=mystic_lever_hub] run summon ldz:magic_barrier 78 157 31 0 0 mystic_hub_barrier_levered
execute as @s[family=mystic_lever_hub] at @e[type=ldz:magic_barrier,family=mystic_hub_barrier] run fill ~ ~ ~-1 ~ ~2 ~1 ldz:tinted_barrier_neg_x

## MYSTIC DUNGEON
execute as @s[family=mystic_lever_dungeon] run tellraw @a[tag=dev] { "rawtext": [ { "text": "§9Mystic Dungeon Lever Deactivated" } ] }
execute as @s[family=mystic_lever_dungeon] run event entity @e[type=ldz:magic_barrier,family=mystic_dungeon_barrier] despawn
execute as @s[family=mystic_lever_dungeon] run scoreboard players set .var MysticBarrier 1
execute as @s[family=mystic_lever_dungeon] run scoreboard objectives remove MagicBarrierDM
execute as @s[family=mystic_lever_dungeon] run scoreboard objectives add MagicBarrierDM dummy
execute as @s[family=mystic_lever_dungeon] run summon ldz:magic_barrier ~ ~-10 ~ 0 0 mystic_dungeon_barrier_levered
execute as @s[family=mystic_lever_dungeon] run scoreboard players set @e[type=ldz:magic_barrier,family=mystic_dungeon_barrier,c=1] MagicBarrierDM 1
execute as @s[family=mystic_lever_dungeon] at @s if entity @e[type=ldz:ender_charger,r=5] run summon ldz:help_bubble -531 169 -158.25 -90 0 mystic_bubble
execute as @s[family=mystic_lever_dungeon] at @s if entity @e[type=ldz:ender_charger,r=5] run scoreboard players set @e[family=mystic_bubble] MysticBubble 1
execute as @s[family=mystic_lever_dungeon] run playsound entity.magic_barrier.spawn @a ~ ~ ~ 0.3
execute as @s[family=mystic_lever_dungeon] run setblock ~ ~-1 ~ ldz:ender_copper
teleport @e[type=ldz:magic_barrier,family=mystic_dungeon_barrier] -529 167 -159

## SCOURGE HUB LEVER MOVING UP
execute as @s[family=scourge_lever_hub] run tellraw @a[tag=dev] { "rawtext": [ { "text": "§9Scourge Hub Lever Deactivated" } ] }
execute as @s[family=scourge_lever_hub] run event entity @e[type=ldz:magic_barrier,family=scourge_hub_barrier] despawn
execute as @s[family=scourge_lever_hub] run summon ldz:magic_barrier 104 149 47 0 0 scourge_hub_barrier_levered
execute as @s[family=scourge_lever_hub] at @e[type=ldz:magic_barrier,family=scourge_hub_barrier] run fill ~-1 ~ ~ ~1 ~2 ~ ldz:tinted_barrier_pos_z

## SCOURGE DUNGEON
execute as @s[family=scourge_lever_dungeon] run tellraw @a[tag=dev] { "rawtext": [ { "text": "§9Scourge Dungeon Lever Deactivated" } ] }
execute as @s[family=scourge_lever_dungeon] run event entity @e[type=ldz:magic_barrier,family=scourge_dungeon_barrier] despawn
execute as @s[family=scourge_lever_dungeon] run scoreboard players set .var ScourgeBarrier 1
execute as @s[family=scourge_lever_dungeon] run scoreboard objectives remove MagicBarrierDS
execute as @s[family=scourge_lever_dungeon] run scoreboard objectives add MagicBarrierDS dummy
execute as @s[family=scourge_lever_dungeon] run summon ldz:magic_barrier ~ ~-10 ~ 0 0 scourge_dungeon_barrier_levered
execute as @s[family=scourge_lever_dungeon] run scoreboard players set @e[type=ldz:magic_barrier,family=scourge_dungeon_barrier,c=1] MagicBarrierDS 1
execute as @s[family=scourge_lever_dungeon] at @s if entity @e[type=ldz:ender_gardener,r=5] run summon ldz:help_bubble 30.9 167.5 445.95 90 0 scourge_bubble
execute as @s[family=scourge_lever_dungeon] at @s if entity @e[type=ldz:ender_gardener,r=5] run scoreboard players set @e[family=scourge_bubble] ScourgeBubble 1
execute as @s[family=scourge_lever_dungeon] run playsound entity.magic_barrier.spawn @a ~ ~ ~ 0.3
execute as @s[family=scourge_lever_dungeon] run setblock ~ ~-1 ~ ldz:ender_copper
teleport @e[type=ldz:magic_barrier,family=scourge_dungeon_barrier] 29 165 446


## WRAITH HUB LEVER MOVING UP
execute as @s[family=wraith_lever_hub] run tellraw @a[tag=dev] { "rawtext": [ { "text": "§9Wraith Hub Lever Deactivated" } ] }
execute as @s[family=wraith_lever_hub] run event entity @e[type=ldz:magic_barrier,family=wraith_hub_barrier] despawn
execute as @s[family=wraith_lever_hub] run summon ldz:magic_barrier 130 157 31 0 0 wraith_hub_barrier_levered
execute as @s[family=wraith_lever_hub] at @e[type=ldz:magic_barrier,family=wraith_hub_barrier] run fill ~ ~ ~-1 ~ ~2 ~1 ldz:tinted_barrier_pos_x

## WRAITH DUNGEON
execute as @s[family=wraith_lever_dungeon] run tellraw @a[tag=dev] { "rawtext": [ { "text": "§9Wraith Dungeon Lever Deactivated" } ] }
execute as @s[family=wraith_lever_dungeon] run event entity @e[type=ldz:magic_barrier,family=wraith_dungeon_barrier] despawn
execute as @s[family=wraith_lever_dungeon] run scoreboard players set .var WraithBarrier 1
execute as @s[family=wraith_lever_dungeon] run scoreboard objectives remove MagicBarrierDW
execute as @s[family=wraith_lever_dungeon] run scoreboard objectives add MagicBarrierDW dummy
execute as @s[family=wraith_lever_dungeon] run summon ldz:magic_barrier ~ ~-10 ~ 0 0 wraith_dungeon_barrier_levered
execute as @s[family=wraith_lever_dungeon] run scoreboard players set @e[type=ldz:magic_barrier,family=wraith_dungeon_barrier,c=1] MagicBarrierDW 1
execute as @s[family=wraith_lever_dungeon] at @s if entity @e[type=ldz:ender_hydro,r=5] run summon ldz:help_bubble 593.9 168.85 49.85 90 0 wraith_bubble
execute as @s[family=wraith_lever_dungeon] at @s if entity @e[type=ldz:ender_hydro,r=5] run scoreboard players set @e[family=wraith_bubble] WraithBubble 1
execute as @s[family=wraith_lever_dungeon] run playsound entity.magic_barrier.spawn @a ~ ~ ~ 0.3
execute as @s[family=wraith_lever_dungeon] run setblock ~ ~-1 ~ ldz:ender_copper
teleport @e[type=ldz:magic_barrier,family=wraith_dungeon_barrier] 591 166 50

event entity @e[type=ldz:bob_arrow] despawn