###Checks for eastern button press; adds tier to nitPillars 1 and 4###
execute if block ~2 ~3 ~ minecraft:stone_button[powered=true] run scoreboard players add @e[tag=nitPillar1,distance=..10] nitPillarTier 1
execute if block ~2 ~3 ~ minecraft:stone_button[powered=true] run scoreboard players add @e[tag=nitPillar4,distance=..10] nitPillarTier 1
execute if block ~2 ~3 ~ minecraft:stone_button[powered=true] run setblock ~2 ~3 ~ minecraft:stone_button[powered=false,face=floor,facing=east]

###Checks for southern button press; subtracts tier from nitPillars 1 and 3###
execute if block ~ ~3 ~2 minecraft:stone_button[powered=true] run scoreboard players remove @e[tag=nitPillar1,distance=..10] nitPillarTier 1
execute if block ~ ~3 ~2 minecraft:stone_button[powered=true] run scoreboard players remove @e[tag=nitPillar3,distance=..10] nitPillarTier 1
execute if block ~ ~3 ~2 minecraft:stone_button[powered=true] run setblock ~ ~3 ~2 minecraft:stone_button[powered=false,face=floor,facing=south]

###Checks for western button press; adds tier to nitPillar 2 and subtracts from nitPillar 4###
execute if block ~-2 ~3 ~ minecraft:stone_button[powered=true] run scoreboard players add @e[tag=nitPillar2,distance=..10] nitPillarTier 1
execute if block ~-2 ~3 ~ minecraft:stone_button[powered=true] run scoreboard players remove @e[tag=nitPillar4,distance=..10] nitPillarTier 1
execute if block ~-2 ~3 ~ minecraft:stone_button[powered=true] run setblock ~-2 ~3 ~ minecraft:stone_button[powered=false,face=floor,facing=west]

###Checks for northern button press; adds tier to nitPillar 3 and subtracts from nitPillar 2###
execute if block ~ ~3 ~-2 minecraft:stone_button[powered=true] run scoreboard players add @e[tag=nitPillar3,distance=..10] nitPillarTier 1
execute if block ~ ~3 ~-2 minecraft:stone_button[powered=true] run scoreboard players remove @e[tag=nitPillar2,distance=..10] nitPillarTier 1
execute if block ~ ~3 ~-2 minecraft:stone_button[powered=true] run setblock ~ ~3 ~-2 minecraft:stone_button[powered=false,face=floor,facing=north]

###Performs physical tier adjustments###
execute as @e[tag=nitPillar,distance=..10] at @s run function nitk:special/puzzle_pillars

execute unless entity @e[tag=nitPillar,tag=!nitClearCondition,distance=..10] run tag @s add nitClearCondition
execute if entity @s[tag=nitClearCondition] run loot spawn ~ ~3 ~ loot nitk:items/inscribed_sundisc
execute if entity @s[tag=nitClearCondition] run playsound minecraft:block.end_portal.spawn record @p ~ ~3 ~ 5
execute if entity @s[tag=nitClearCondition] run kill @s