## Run by prisoners
## Run from animation.ender_prisoner.barrier_sensor
## @s = ldz:ender_charger, ldz:ender_chef, ldz:ender_gardener, ldz:ender_hydro

scoreboard objectives add temp dummy
execute at @s[type=ldz:ender_charger] unless entity @p[x=-529,y=167,z=-162,dx=6,dy=0,dz=6] run scoreboard objectives remove temp
execute at @s[type=ldz:ender_chef] unless entity @p[x=79,y=153,z=-480,dx=6,dy=0,dz=6] run scoreboard objectives remove temp
execute at @s[type=ldz:ender_gardener] unless entity @p[x=23,y=165,z=443,dx=6,dy=0,dz=6] run scoreboard objectives remove temp
execute at @s[type=ldz:ender_hydro] unless entity @p[x=586,y=165,z=47,dx=6,dy=1,dz=6] run scoreboard objectives remove temp

execute as @s[type=ldz:ender_charger] unless entity @e[type=ldz:magic_barrier,family=mystic_dungeon_barrier] run scoreboard players set @s temp 1
execute as @s[type=ldz:ender_chef] unless entity @e[type=ldz:magic_barrier,family=beast_dungeon_barrier] run scoreboard players set @s temp 1
execute as @s[type=ldz:ender_gardener] unless entity @e[type=ldz:magic_barrier,family=scourge_dungeon_barrier] run scoreboard players set @s temp 1
execute as @s[type=ldz:ender_hydro] unless entity @e[type=ldz:magic_barrier,family=wraith_dungeon_barrier] run scoreboard players set @s temp 1

execute as @s[scores={temp=1}] run function endermen/prisoners/prison_2_button_pressed
execute at @s[scores={temp=1}] as @a[r=8] run function dialogue/player_press_prison_2_button

scoreboard objectives remove temp