## Back click
execute as @s[nbt={EnderItems:[{Slot:10b,id:"minecraft:arrow"}]}] run execute unless entity @s[nbt={EnderItems:[{Slot:18b,id:"minecraft:ender_pearl"}]}] run scoreboard players set @s men_cos 1
execute as @s[nbt={EnderItems:[{Slot:10b,id:"minecraft:arrow"}]}] run execute unless entity @s[nbt={EnderItems:[{Slot:18b,id:"minecraft:ender_pearl"}]}] at @s run playsound minecraft:ui.button.click master @s ~ ~ ~ 1 1.5

## No trail click
execute as @s[nbt={EnderItems:[{Slot:11b,id:"minecraft:totem_of_undying"}]}] run execute unless entity @s[nbt={EnderItems:[{Slot:10b,id:"minecraft:arrow"}]}] run scoreboard players set @s arrow_type 1
execute as @s[nbt={EnderItems:[{Slot:11b,id:"minecraft:totem_of_undying"}]}] run execute unless entity @s[nbt={EnderItems:[{Slot:10b,id:"minecraft:arrow"}]}] at @s run playsound minecraft:ui.button.click master @s ~ ~ ~ 1 1.5

## Totem click
execute as @s[nbt={EnderItems:[{Slot:10b,id:"minecraft:arrow"}]},scores={statsWins=1..}] run execute unless entity @s[nbt={EnderItems:[{Slot:11b,id:"minecraft:totem_of_undying"}]}] run scoreboard players set @s arrow_type 2
execute as @s[nbt={EnderItems:[{Slot:10b,id:"minecraft:arrow"}]},scores={statsWins=1..}] run execute unless entity @s[nbt={EnderItems:[{Slot:11b,id:"minecraft:totem_of_undying"}]}] at @s run playsound minecraft:ui.button.click master @s ~ ~ ~ 1 1.5
execute as @s[nbt={EnderItems:[{Slot:10b,id:"minecraft:arrow"}]},scores={statsWins=..0}] run execute unless entity @s[nbt={EnderItems:[{Slot:11b,id:"minecraft:totem_of_undying"}]}] run tellraw @s {"translate":"subchronos.lobby.cosmetics.generic.wins","fallback":"You need %s win to use these trail!","with":["1"],"color":"red"}
execute as @s[nbt={EnderItems:[{Slot:10b,id:"minecraft:arrow"}]},scores={statsWins=..0}] run execute unless entity @s[nbt={EnderItems:[{Slot:11b,id:"minecraft:totem_of_undying"}]}] at @s run playsound minecraft:entity.villager.no master @s ~ ~ ~ 1

## Magic click
execute as @s[nbt={EnderItems:[{Slot:10b,id:"minecraft:arrow"}]},scores={statsKills=5..}] run execute unless entity @s[nbt={EnderItems:[{Slot:15b,id:"minecraft:potion"}]}] run scoreboard players set @s arrow_type 3
execute as @s[nbt={EnderItems:[{Slot:10b,id:"minecraft:arrow"}]},scores={statsKills=5..}] run execute unless entity @s[nbt={EnderItems:[{Slot:15b,id:"minecraft:potion"}]}] at @s run playsound minecraft:ui.button.click master @s ~ ~ ~ 1 1.5
execute as @s[nbt={EnderItems:[{Slot:10b,id:"minecraft:arrow"}]},scores={statsKills=..4}] run execute unless entity @s[nbt={EnderItems:[{Slot:15b,id:"minecraft:potion"}]}] run tellraw @s {"translate":"subchronos.lobby.cosmetics.generic.kills","fallback":"You need %s kills to use these trail!","with":["5"],"color":"red"}
execute as @s[nbt={EnderItems:[{Slot:10b,id:"minecraft:arrow"}]},scores={statsKills=..4}] run execute unless entity @s[nbt={EnderItems:[{Slot:15b,id:"minecraft:potion"}]}] at @s run playsound minecraft:entity.villager.no master @s ~ ~ ~ 1

## Dirt click
execute as @s[nbt={EnderItems:[{Slot:10b,id:"minecraft:arrow"}]},scores={statsKills=1..}] run execute unless entity @s[nbt={EnderItems:[{Slot:14b,id:"minecraft:coarse_dirt"}]}] run scoreboard players set @s arrow_type 4
execute as @s[nbt={EnderItems:[{Slot:10b,id:"minecraft:arrow"}]},scores={statsKills=1..}] run execute unless entity @s[nbt={EnderItems:[{Slot:14b,id:"minecraft:coarse_dirt"}]}] at @s run playsound minecraft:ui.button.click master @s ~ ~ ~ 1 1.5
execute as @s[nbt={EnderItems:[{Slot:10b,id:"minecraft:arrow"}]},scores={statsKills=..0}] run execute unless entity @s[nbt={EnderItems:[{Slot:14b,id:"minecraft:coarse_dirt"}]}] run tellraw @s {"translate":"subchronos.lobby.cosmetics.generic.kills","fallback":"You need %s kill to use these trail!","with":["1"],"color":"red"}
execute as @s[nbt={EnderItems:[{Slot:10b,id:"minecraft:arrow"}]},scores={statsKills=..0}] run execute unless entity @s[nbt={EnderItems:[{Slot:14b,id:"minecraft:coarse_dirt"}]}] at @s run playsound minecraft:entity.villager.no master @s ~ ~ ~ 1

## Gold click
execute as @s[nbt={EnderItems:[{Slot:10b,id:"minecraft:arrow"}]},scores={statsWins=2..}] run execute unless entity @s[nbt={EnderItems:[{Slot:12b,id:"minecraft:raw_gold"}]}] run scoreboard players set @s arrow_type 5
execute as @s[nbt={EnderItems:[{Slot:10b,id:"minecraft:arrow"}]},scores={statsWins=2..}] run execute unless entity @s[nbt={EnderItems:[{Slot:12b,id:"minecraft:raw_gold"}]}] at @s run playsound minecraft:ui.button.click master @s ~ ~ ~ 1 1.5
execute as @s[nbt={EnderItems:[{Slot:10b,id:"minecraft:arrow"}]},scores={statsWins=..1}] run execute unless entity @s[nbt={EnderItems:[{Slot:12b,id:"minecraft:raw_gold"}]}] run tellraw @s {"translate":"subchronos.lobby.cosmetics.generic.wins","fallback":"You need %s wins to use these trail!","with":["2"],"color":"red"}
execute as @s[nbt={EnderItems:[{Slot:10b,id:"minecraft:arrow"}]},scores={statsWins=..1}] run execute unless entity @s[nbt={EnderItems:[{Slot:12b,id:"minecraft:raw_gold"}]}] at @s run playsound minecraft:entity.villager.no master @s ~ ~ ~ 1

## Obs click
execute as @s[nbt={EnderItems:[{Slot:10b,id:"minecraft:arrow"}]},scores={statsWins=5..}] run execute unless entity @s[nbt={EnderItems:[{Slot:13b,id:"minecraft:crying_obsidian"}]}] run scoreboard players set @s arrow_type 7
execute as @s[nbt={EnderItems:[{Slot:10b,id:"minecraft:arrow"}]},scores={statsWins=5..}] run execute unless entity @s[nbt={EnderItems:[{Slot:13b,id:"minecraft:crying_obsidian"}]}] at @s run playsound minecraft:ui.button.click master @s ~ ~ ~ 1 1.5
execute as @s[nbt={EnderItems:[{Slot:10b,id:"minecraft:arrow"}]},scores={statsWins=..4}] run execute unless entity @s[nbt={EnderItems:[{Slot:13b,id:"minecraft:crying_obsidian"}]}] run tellraw @s {"translate":"subchronos.lobby.cosmetics.generic.wins","fallback":"You need %s wins to use these trail!","with":["5"],"color":"red"}
execute as @s[nbt={EnderItems:[{Slot:10b,id:"minecraft:arrow"}]},scores={statsWins=..4}] run execute unless entity @s[nbt={EnderItems:[{Slot:13b,id:"minecraft:crying_obsidian"}]}] at @s run playsound minecraft:entity.villager.no master @s ~ ~ ~ 1

## Glow click
execute as @s[nbt={EnderItems:[{Slot:10b,id:"minecraft:arrow"}]},scores={statsKills=10..}] run execute unless entity @s[nbt={EnderItems:[{Slot:16b,id:"minecraft:glow_ink_sac"}]}] run scoreboard players set @s arrow_type 6
execute as @s[nbt={EnderItems:[{Slot:10b,id:"minecraft:arrow"}]},scores={statsKills=10..}] run execute unless entity @s[nbt={EnderItems:[{Slot:16b,id:"minecraft:glow_ink_sac"}]}] at @s run playsound minecraft:ui.button.click master @s ~ ~ ~ 1 1.5
execute as @s[nbt={EnderItems:[{Slot:10b,id:"minecraft:arrow"}]},scores={statsKills=..9}] run execute unless entity @s[nbt={EnderItems:[{Slot:16b,id:"minecraft:glow_ink_sac"}]}] run tellraw @s {"translate":"subchronos.lobby.cosmetics.generic.kills","fallback":"You need %s kills to use these trail!","with":["10"],"color":"red"}
execute as @s[nbt={EnderItems:[{Slot:10b,id:"minecraft:arrow"}]},scores={statsKills=..9}] run execute unless entity @s[nbt={EnderItems:[{Slot:16b,id:"minecraft:glow_ink_sac"}]}] at @s run playsound minecraft:entity.villager.no master @s ~ ~ ~ 1

## Redstone click
execute if entity @s[scores={easter_cueva=1}] as @s[nbt={EnderItems:[{Slot:10b,id:"minecraft:arrow"}]}] run execute unless entity @s[nbt={EnderItems:[{Slot:22b,id:"minecraft:redstone"}]}] run scoreboard players set @s arrow_type 8
execute if entity @s[scores={easter_cueva=1}] as @s[nbt={EnderItems:[{Slot:10b,id:"minecraft:arrow"}]}] run execute unless entity @s[nbt={EnderItems:[{Slot:22b,id:"minecraft:redstone"}]}] at @s run playsound minecraft:ui.button.click master @s ~ ~ ~ 1 1.5

# Placing GUI

execute if entity @s[scores={easter_cueva=1}] run item replace entity @s enderchest.0 with minecraft:purple_stained_glass_pane[minecraft:custom_data={trash:1b},minecraft:custom_name={"text":" "}]
execute unless entity @s[scores={easter_cueva=1}] run item replace entity @s enderchest.0 with minecraft:purple_stained_glass_pane[minecraft:custom_data={trash:1b},minecraft:custom_name={"text":" "}]

item replace entity @s enderchest.1 with minecraft:magenta_stained_glass_pane[minecraft:custom_data={trash:1b},minecraft:custom_name={"text":" "}]
item replace entity @s enderchest.2 with minecraft:purple_stained_glass_pane[minecraft:custom_data={trash:1b},minecraft:custom_name={"text":" "}]
item replace entity @s enderchest.3 with minecraft:magenta_stained_glass_pane[minecraft:custom_data={trash:1b},minecraft:custom_name={"text":" "}]
item replace entity @s enderchest.4 with minecraft:purple_stained_glass_pane[minecraft:custom_data={trash:1b},minecraft:custom_name={"text":" "}]
item replace entity @s enderchest.5 with minecraft:magenta_stained_glass_pane[minecraft:custom_data={trash:1b},minecraft:custom_name={"text":" "}]
item replace entity @s enderchest.6 with minecraft:purple_stained_glass_pane[minecraft:custom_data={trash:1b},minecraft:custom_name={"text":" "}]
item replace entity @s enderchest.7 with minecraft:magenta_stained_glass_pane[minecraft:custom_data={trash:1b},minecraft:custom_name={"text":" "}]
item replace entity @s enderchest.8 with minecraft:purple_stained_glass_pane[minecraft:custom_data={trash:1b},minecraft:custom_name={"text":" "}]
item replace entity @s enderchest.9 with minecraft:magenta_stained_glass_pane[minecraft:custom_data={trash:1b},minecraft:custom_name={"text":" "}]

# NO TRAIL (slot 10)
execute unless score @s arrow_type matches 1 run item replace entity @s enderchest.10 with arrow[minecraft:custom_data={trash:1b},minecraft:custom_name={"translate":"subchronos.lobby.cosmetics.p4.no_trail","fallback":"No Trail","italic":false,"color":"green"},potion_contents={custom_color:65280},tooltip_display={hidden_components:["potion_contents"]},lore=[{"translate":"subchronos.lobby.cosmetics.generic.unlocked","fallback":"Unlocked","color":"green"}]]
execute if score @s arrow_type matches 1 run item replace entity @s enderchest.10 with arrow[minecraft:custom_data={trash:1b},minecraft:custom_name={"translate":"subchronos.lobby.cosmetics.p4.no_trail","fallback":"No Trail","italic":true,"color":"aqua"},potion_contents={custom_color:65535},tooltip_display={hidden_components:["potion_contents"]},lore=[{"translate":"subchronos.lobby.cosmetics.generic.selected","fallback":"Selected","color":"gray"}]]

# TOTEM TRAIL (slot 11)
execute unless score @s arrow_type matches 2 if score @s statsWins matches ..0 run item replace entity @s enderchest.11 with totem_of_undying[minecraft:custom_data={trash:1b},minecraft:custom_name={"translate":"subchronos.lobby.cosmetics.p4.totem","fallback":"Totem Trail","italic":false,"color":"red"},lore=[{"translate":"subchronos.lobby.cosmetics.generic.wins","fallback":"You need %s wins to unlock.","with":["1"],"color":"red"}]]
execute unless score @s arrow_type matches 2 if score @s statsWins matches 1.. run item replace entity @s enderchest.11 with totem_of_undying[minecraft:custom_data={trash:1b},minecraft:custom_name={"translate":"subchronos.lobby.cosmetics.p4.totem","fallback":"Totem Trail","italic":false,"color":"green"},lore=[{"translate":"subchronos.lobby.cosmetics.generic.unlocked","fallback":"Unlocked","color":"green"}]]
execute if score @s arrow_type matches 2 run item replace entity @s enderchest.11 with totem_of_undying[minecraft:custom_data={trash:1b},minecraft:custom_name={"translate":"subchronos.lobby.cosmetics.p4.totem","fallback":"Totem Trail","italic":true,"color":"aqua"},lore=[{"translate":"subchronos.lobby.cosmetics.generic.selected","fallback":"Selected","color":"gray"}]]

# MAGIC TRAIL (slot 15)
execute unless score @s arrow_type matches 3 if score @s statsKills matches ..4 run item replace entity @s enderchest.15 with potion[minecraft:custom_data={trash:1b},minecraft:custom_name={"translate":"subchronos.lobby.cosmetics.p4.magic","fallback":"Magic Trail","italic":false,"color":"red"},potion_contents={custom_color:11010205},tooltip_display={hidden_components:["potion_contents"]},lore=[{"translate":"subchronos.lobby.cosmetics.generic.kills","fallback":"You need %s kills to unlock.","with":["5"],"color":"red"}]]
execute unless score @s arrow_type matches 3 if score @s statsKills matches 5.. run item replace entity @s enderchest.15 with potion[minecraft:custom_data={trash:1b},minecraft:custom_name={"translate":"subchronos.lobby.cosmetics.p4.magic","fallback":"Magic Trail","italic":false,"color":"green"},potion_contents={custom_color:11010205},tooltip_display={hidden_components:["potion_contents"]},lore=[{"translate":"subchronos.lobby.cosmetics.generic.unlocked","fallback":"Unlocked","color":"green"}]]
execute if score @s arrow_type matches 3 run item replace entity @s enderchest.15 with potion[minecraft:custom_data={trash:1b},minecraft:custom_name={"translate":"subchronos.lobby.cosmetics.p4.magic","fallback":"Magic Trail","italic":true,"color":"aqua"},potion_contents={custom_color:11010205},tooltip_display={hidden_components:["potion_contents"]},lore=[{"translate":"subchronos.lobby.cosmetics.generic.selected","fallback":"Selected","color":"gray"}]]

# DUST TRAIL (slot 14)
execute unless score @s arrow_type matches 4 if score @s statsKills matches ..0 run item replace entity @s enderchest.14 with coarse_dirt[minecraft:custom_data={trash:1b},minecraft:custom_name={"translate":"subchronos.lobby.cosmetics.p4.dust","fallback":"Dust Trail","italic":false,"color":"red"},lore=[{"translate":"subchronos.lobby.cosmetics.generic.kills","fallback":"You need %s kills to unlock.","with":["1"],"color":"red"}]]
execute unless score @s arrow_type matches 4 if score @s statsKills matches 1.. run item replace entity @s enderchest.14 with coarse_dirt[minecraft:custom_data={trash:1b},minecraft:custom_name={"translate":"subchronos.lobby.cosmetics.p4.dust","fallback":"Dust Trail","italic":false,"color":"green"},lore=[{"translate":"subchronos.lobby.cosmetics.generic.unlocked","fallback":"Unlocked","color":"green"}]]
execute if score @s arrow_type matches 4 run item replace entity @s enderchest.14 with coarse_dirt[minecraft:custom_data={trash:1b},minecraft:custom_name={"translate":"subchronos.lobby.cosmetics.p4.dust","fallback":"Dust Trail","italic":true,"color":"aqua"},lore=[{"translate":"subchronos.lobby.cosmetics.generic.selected","fallback":"Selected","color":"gray"}]]

# GOLDEN TRAIL (slot 12)
execute unless score @s arrow_type matches 5 if score @s statsWins matches ..1 run item replace entity @s enderchest.12 with minecraft:raw_gold[minecraft:custom_data={trash:1b},minecraft:custom_name={"translate":"subchronos.lobby.cosmetics.p4.gold","fallback":"Golden Trail","italic":false,"color":"red"},lore=[{"translate":"subchronos.lobby.cosmetics.generic.wins","fallback":"You need %s wins to unlock.","with":["2"],"color":"red"}]]
execute unless score @s arrow_type matches 5 if score @s statsWins matches 2.. run item replace entity @s enderchest.12 with minecraft:raw_gold[minecraft:custom_data={trash:1b},minecraft:custom_name={"translate":"subchronos.lobby.cosmetics.p4.gold","fallback":"Golden Trail","italic":false,"color":"green"},lore=[{"translate":"subchronos.lobby.cosmetics.generic.unlocked","fallback":"Unlocked","color":"green"}]]
execute if score @s arrow_type matches 5 run item replace entity @s enderchest.12 with minecraft:raw_gold[minecraft:custom_data={trash:1b},minecraft:custom_name={"translate":"subchronos.lobby.cosmetics.p4.gold","fallback":"Golden Trail","italic":true,"color":"aqua"},lore=[{"translate":"subchronos.lobby.cosmetics.generic.selected","fallback":"Selected","color":"gray"}]]

# OBSIDIAN TRAIL (slot 13)
execute unless score @s arrow_type matches 7 if score @s statsWins matches ..4 run item replace entity @s enderchest.13 with minecraft:crying_obsidian[minecraft:custom_data={trash:1b},minecraft:custom_name={"translate":"subchronos.lobby.cosmetics.p4.obsidian","fallback":"Obsidian Trail","italic":false,"color":"red"},lore=[{"translate":"subchronos.lobby.cosmetics.generic.wins","fallback":"You need %s wins to unlock.","with":["5"],"color":"red"}]]
execute unless score @s arrow_type matches 7 if score @s statsWins matches 5.. run item replace entity @s enderchest.13 with minecraft:crying_obsidian[minecraft:custom_data={trash:1b},minecraft:custom_name={"translate":"subchronos.lobby.cosmetics.p4.obsidian","fallback":"Obsidian Trail","italic":false,"color":"green"},lore=[{"translate":"subchronos.lobby.cosmetics.generic.unlocked","fallback":"Unlocked","color":"green"}]]
execute if score @s arrow_type matches 7 run item replace entity @s enderchest.13 with minecraft:crying_obsidian[minecraft:custom_data={trash:1b},minecraft:custom_name={"translate":"subchronos.lobby.cosmetics.p4.obsidian","fallback":"Obsidian Trail","italic":true,"color":"aqua"},lore=[{"translate":"subchronos.lobby.cosmetics.generic.selected","fallback":"Selected","color":"gray"}]]

# GLOW TRAIL (slot 16)
execute unless score @s arrow_type matches 6 if score @s statsKills matches ..9 run item replace entity @s enderchest.16 with glow_ink_sac[minecraft:custom_data={trash:1b},minecraft:custom_name={"translate":"subchronos.lobby.cosmetics.p4.glow","fallback":"Glow Trail","italic":false,"color":"red"},lore=[{"translate":"subchronos.lobby.cosmetics.generic.kills","fallback":"You need %s kills to unlock.","with":["10"],"color":"red"}]]
execute unless score @s arrow_type matches 6 if score @s statsKills matches 10.. run item replace entity @s enderchest.16 with glow_ink_sac[minecraft:custom_data={trash:1b},minecraft:custom_name={"translate":"subchronos.lobby.cosmetics.p4.glow","fallback":"Glow Trail","italic":false,"color":"green"},lore=[{"translate":"subchronos.lobby.cosmetics.generic.unlocked","fallback":"Unlocked","color":"green"}]]
execute if score @s arrow_type matches 6 run item replace entity @s enderchest.16 with glow_ink_sac[minecraft:custom_data={trash:1b},minecraft:custom_name={"translate":"subchronos.lobby.cosmetics.p4.glow","fallback":"Glow Trail","italic":true,"color":"aqua"},lore=[{"translate":"subchronos.lobby.cosmetics.generic.selected","fallback":"Selected","color":"gray"}]]

# REDSTONE TRAIL (slot 22)
execute if entity @s[scores={easter_cueva=1}] unless score @s arrow_type matches 8 run item replace entity @s enderchest.22 with redstone[minecraft:custom_data={trash:1b},minecraft:custom_name={"translate":"subchronos.lobby.cosmetics.p4.redstone","fallback":"Redstone Trail","italic":false,"color":"green"},lore=[{"translate":"subchronos.lobby.cosmetics.generic.unlocked","fallback":"Unlocked by finding the easter egg","color":"green"}]]
execute if entity @s[scores={easter_cueva=1}] if score @s arrow_type matches 8 run item replace entity @s enderchest.22 with redstone[minecraft:custom_data={trash:1b},minecraft:custom_name={"translate":"subchronos.lobby.cosmetics.p4.redstone","fallback":"Redstone Trail","italic":false,"color":"aqua"},lore=[{"translate":"subchronos.lobby.cosmetics.generic.selected","fallback":"Selected","color":"gray"}]]
execute unless entity @s[scores={easter_cueva=1}] run item replace entity @s enderchest.22 with minecraft:purple_stained_glass_pane[minecraft:custom_data={trash:1b},minecraft:custom_name={"text":" "}]


# Border and back buttons
item replace entity @s enderchest.17 with minecraft:magenta_stained_glass_pane[minecraft:custom_data={trash:1b},minecraft:custom_name={"text":" "}]
item replace entity @s enderchest.18 with minecraft:ender_pearl[minecraft:custom_data={trash:1b},minecraft:custom_name={"translate":"subchronos.lobby.cosmetics.generic.back","fallback":"Back","italic":false,"color":"#A1A1A1"}]
item replace entity @s enderchest.19 with minecraft:magenta_stained_glass_pane[minecraft:custom_data={trash:1b},minecraft:custom_name={"text":" "}]
item replace entity @s enderchest.20 with minecraft:purple_stained_glass_pane[minecraft:custom_data={trash:1b},minecraft:custom_name={"text":" "}]
item replace entity @s enderchest.21 with minecraft:magenta_stained_glass_pane[minecraft:custom_data={trash:1b},minecraft:custom_name={"text":" "}]


item replace entity @s enderchest.23 with minecraft:magenta_stained_glass_pane[minecraft:custom_data={trash:1b},minecraft:custom_name={"text":" "}]
item replace entity @s enderchest.24 with minecraft:purple_stained_glass_pane[minecraft:custom_data={trash:1b},minecraft:custom_name={"text":" "}]
item replace entity @s enderchest.25 with minecraft:magenta_stained_glass_pane[minecraft:custom_data={trash:1b},minecraft:custom_name={"text":" "}]
item replace entity @s enderchest.26 with minecraft:purple_stained_glass_pane[minecraft:custom_data={trash:1b},minecraft:custom_name={"text":" "}]