#hotbar stuff

#makes sure the player has all the proper icons in their hotbar during gameplay
#right-clicks on the icons are also handled here

tag @s[tag=hasSlot0] remove hasSlot0
tag @s[nbt={Inventory:[{Slot:0b,tag:{Tags:["slot0"]}}]}] add hasSlot0
clear @s[gamemode=!creative,tag=!hasSlot0] ghast_tear
execute if entity @s[tag=!hasSlot0,tag=!noInventory] run item replace entity @s hotbar.0 with ghast_tear{Tags:["slot0"],CustomModelData:1234567,display:{Name:"{\"text\":\"Reset Puzzle\",\"color\":\"dark_aqua\",\"bold\":\"true\",\"italic\":\"false\"}"}} 1
execute if entity @s[nbt={SelectedItem:{tag:{Tags:["slot0"]}}},scores={inputCooldown=..0,carrotInput=1..}] run function bd:game/reset_puzzle

tag @s[tag=hasSlot1] remove hasSlot1
execute unless score global dontRecordUndo matches 1 run tag @s[nbt={Inventory:[{Slot:1b,tag:{Tags:["slot1"]}}]}] add hasSlot1
clear @s[gamemode=!creative,tag=!hasSlot1] emerald
execute unless score global dontRecordUndo matches 1 if entity @s[tag=!hasSlot1,tag=!noInventory] run item replace entity @s hotbar.1 with emerald{Tags:["slot1"],CustomModelData:1234567,display:{Name:"{\"text\":\"Undo\",\"color\":\"light_purple\",\"bold\":\"true\",\"italic\":\"false\"}"}} 1
execute if entity @s[nbt={SelectedItem:{tag:{Tags:["slot1"]}}},scores={inputCooldown=..0,carrotInput=1..}] run function bd:game/undo

tag @s[tag=hasSlot7] remove hasSlot7
execute unless score global exitEnabled matches 0 run tag @s[nbt={Inventory:[{Slot:7b,tag:{Tags:["slot7"]}}]}] add hasSlot7
clear @s[gamemode=!creative,tag=!hasSlot7] gold_nugget
execute unless score global exitEnabled matches 0 if entity @s[tag=!hasSlot7,tag=!noInventory] run item replace entity @s hotbar.7 with gold_nugget{Tags:["slot7"],CustomModelData:1234567,display:{Name:"{\"text\":\"Exit Puzzle\",\"color\":\"gold\",\"bold\":\"true\",\"italic\":\"false\"}"}} 1
execute if entity @s[nbt={SelectedItem:{tag:{Tags:["slot7"]}}},scores={inputCooldown=..0,carrotInput=1..}] run function bd:game/exit_puzzle

tag @s[tag=hasSlot8] remove hasSlot8
tag @s[nbt={Inventory:[{Slot:8b,tag:{Tags:["slot8"]}}]}] add hasSlot8
clear @s[gamemode=!creative,tag=!hasSlot8] gold_ingot
execute if entity @s[tag=!hasSlot8,tag=!noInventory] run item replace entity @s hotbar.8 with gold_ingot{Tags:["slot8"],CustomModelData:1234567,display:{Name:"{\"text\":\"Exit Bulldozer\",\"color\":\"red\",\"bold\":\"true\",\"italic\":\"false\"}"}} 1
execute if entity @s[nbt={SelectedItem:{tag:{Tags:["slot8"]}}},scores={inputCooldown=..0,carrotInput=1..}] run function bd:game/exit_bulldozer