function zzzzdonotuse:misc/revive/reset
tag @a remove KyuRevivingT1
tag @a remove KyuRevivingT2
tag @a remove KyuRevivingT3
tag @a remove KyuReviver
tag @a remove KyuReviverT1
tag @a remove KyuReviverT2
tag @a remove KyuReviverT3
tag @a remove KyuDoRevive

data merge block 999995 125 999979 {auto:0b}
data merge block 999995 126 999979 {auto:0b}
data merge block 999995 127 999979 {auto:0b}
scoreboard players set @e[name=DayQ] ReviveTimer 0
scoreboard players set @a KyuRevive 0
execute as @s[tag=!KyuDied,scores={KyuSpells=16..18}] run tag @s add KyuReviver

execute at @s run execute if entity @a[distance=..15,gamemode=spectator] run execute as @s[tag=!KyuDied,scores={KyuSpells=16},nbt={Inventory:[{id:"minecraft:golden_apple"}]}] run tag @s add KyuDoRevive
execute as @s[tag=!KyuDied,scores={KyuSpells=16},tag=KyuDoRevive] run execute at @s run tag @p[distance=..15,gamemode=spectator] add KyuRevivingT1
execute as @s[tag=!KyuDied,scores={KyuSpells=16},tag=KyuDoRevive] run tag @s add KyuReviverT1
execute as @s[tag=!KyuDied,scores={KyuSpells=16},tag=!KyuDoRevive] run tellraw @s ["",{"text":"You do not have the required materials to do this, or there is no eligible player nearby to revive.","color":"gold"}]
execute as @s[tag=!KyuDied,scores={KyuSpells=16},tag=KyuDoRevive] run scoreboard players enable @s KyuRevive
execute as @s[tag=!KyuDied,scores={KyuSpells=16},tag=KyuDoRevive] run execute at @s run tellraw @s ["",{"text":"You are about to revive ","color":"blue"},{"selector":"@p[tag=KyuRevivingT1]","color":"red"},{"text":" with low health and no inventory, excluding their tome which will be spared. This will cost you 1 golden apple. ","color":"blue"},{"text":"Click here to confirm you wish to proceed. ","bold":true,"color":"yellow","clickEvent":{"action":"run_command","value":"/trigger KyuRevive set 1"}},{"text":"This will expire after 1 minute.","color":"red","bold":false,"italic":true}]

execute at @s run execute if entity @a[distance=..15,gamemode=spectator] run execute as @s[tag=!KyuDied,scores={KyuSpells=17},nbt={Inventory:[{id:"minecraft:blaze_powder"}]},nbt=!{Inventory:[{id:"minecraft:blaze_powder",Count:1b}]},nbt={Inventory:[{id:"minecraft:golden_apple"}]},nbt={Inventory:[{id:"minecraft:ghast_tear"}]}] run tag @s add KyuDoRevive
execute as @s[tag=!KyuDied,scores={KyuSpells=17},tag=KyuDoRevive] run execute at @s run tag @p[distance=..15,gamemode=spectator] add KyuRevivingT2
execute as @s[tag=!KyuDied,scores={KyuSpells=17},tag=KyuDoRevive] run tag @s add KyuReviverT2
execute as @s[tag=!KyuDied,scores={KyuSpells=17},tag=!KyuDoRevive] run tellraw @s ["",{"text":"You do not have the required materials to do this, or there is no eligible player nearby to revive.","color":"gold"}]
execute as @s[tag=!KyuDied,scores={KyuSpells=17},tag=KyuDoRevive] run scoreboard players enable @s KyuRevive
execute as @s[tag=!KyuDied,scores={KyuSpells=17},tag=KyuDoRevive] run execute at @s run tellraw @s ["",{"text":"You are about to revive ","color":"blue"},{"selector":"@p[tag=KyuRevivingT2]","color":"red"},{"text":" with low health and only their hotbar, tome, and equipped armor items. This will cost you 2 blaze powder, 1 ghast tear, and 1 golden apple. ","color":"blue"},{"text":"Click here to confirm you wish to proceed. ","bold":true,"color":"yellow","clickEvent":{"action":"run_command","value":"/trigger KyuRevive set 3"}},{"text":"This will expire after 1 minute.","color":"red","bold":false,"italic":true}]

execute at @s run execute if entity @a[distance=..15,gamemode=spectator] run execute as @s[tag=!KyuDied,scores={KyuSpells=18},nbt={Inventory:[{id:"minecraft:blaze_powder"}]},nbt=!{Inventory:[{id:"minecraft:blaze_powder",Count:1b}]},nbt=!{Inventory:[{id:"minecraft:blaze_powder",Count:2b}]},nbt={Inventory:[{id:"minecraft:ghast_tear"}]},nbt=!{Inventory:[{id:"minecraft:ghast_tear",Count:1b}]},nbt={Inventory:[{id:"minecraft:wither_skeleton_skull"}]}] run tag @s add KyuDoRevive
execute as @s[tag=!KyuDied,scores={KyuSpells=18},tag=KyuDoRevive] run execute at @s run tag @p[distance=..15,gamemode=spectator] add KyuRevivingT3
execute as @s[tag=!KyuDied,scores={KyuSpells=18},tag=KyuDoRevive] run tag @s add KyuReviverT3
execute as @s[tag=!KyuDied,scores={KyuSpells=18},tag=!KyuDoRevive] run tellraw @s ["",{"text":"You do not have the required materials to do this, or there is no eligible player nearby to revive.","color":"gold"}]
execute as @s[tag=!KyuDied,scores={KyuSpells=18},tag=KyuDoRevive] run scoreboard players enable @s KyuRevive
execute as @s[tag=!KyuDied,scores={KyuSpells=18},tag=KyuDoRevive] run execute at @s run tellraw @s ["",{"text":"You are about to revive ","color":"blue"},{"selector":"@p[tag=KyuRevivingT3]","color":"red"},{"text":" with full health and all of their inventory. This will cost you 3 blaze powder, 2 ghast tears, and 1 wither skull.","color":"blue"},{"text":"Click here to confirm you wish to proceed. ","bold":true,"color":"yellow","clickEvent":{"action":"run_command","value":"/trigger KyuRevive set 5"}},{"text":"This will expire after 1 minute.","color":"red","bold":false,"italic":true}]



execute if entity @a[tag=KyuDoRevive] run data merge block ~ ~4 ~ {auto:1b}

scoreboard players set @s KyuSpells 0