# place items
item replace block 235 -49 -223 container.10 with bat_spawn_egg[custom_model_data={strings:["1"]},can_place_on=[{blocks:"#game:bolt_place"}],custom_name={"text":"Walls","color":"gray","italic":false},lore=[{"text":"Four blocks of breakable gravel","color":"white","italic":false},{"text":"Pushes players and enitites up.","color":"white","italic":false}],entity_data={id:"minecraft:silverfish",Silent:1b,NoAI:1},tooltip_display={hidden_components:["attribute_modifiers","can_break","custom_model_data","unbreakable","tooltip_display","weapon","max_damage","can_place_on","trim","dyed_color","damage","enchantments","food","tool","tooltip_display","potion_contents","item_model","item_name"]}] 8
item replace block 235 -49 -223 container.11 with creeper_spawn_egg[custom_model_data={strings:["0"]},can_place_on=[{blocks:"#game:bolt_place"}],custom_name={"text":"Trap","italic":false,"color":"gray"},lore=[{"text":"Explodes when enemies get near","color":"white","italic":false},{"text":"Outer ring - explosion radius","color":"white","italic":false},{"text":"Inner ring - trigger radius","color":"white","italic":false},{"text":"Can be shot","color":"white","italic":false},{"text":"Max active: 12","color":"white","italic":false}],entity_data={id:"minecraft:creeper",PersistenceRequired:1b,Silent:1b},tooltip_display={hidden_components:["attribute_modifiers","can_break","custom_model_data","unbreakable","tooltip_display","weapon","max_damage","can_place_on","trim","dyed_color","damage","enchantments","food","tool","tooltip_display","potion_contents","item_model","item_name"]}] 4
item replace block 235 -49 -223 container.12 with snowball[custom_model_data={strings:["0"]},custom_name={"text":"Mini TNT","italic":false,"color":"gray"},lore=[{"text":"Explodes, killing players","color":"white","italic":false},{"text":"Kills traps and respawns","color":"white","italic":false},{"text":"Explodes slower if thrown close","color":"white","italic":false}],tooltip_display={hidden_components:["attribute_modifiers","can_break","custom_model_data","unbreakable","tooltip_display","weapon","max_damage","can_place_on","trim","dyed_color","damage","enchantments","food","tool","tooltip_display","potion_contents","item_model","item_name"]}] 4
item replace block 235 -49 -223 container.13 with slime_spawn_egg[custom_model_data={strings:["3"]},can_place_on=[{blocks:"#game:bolt_place"}],custom_name={"text":"Spawn Point","italic":false,"color":"gray"},lore=[{"text":"Place a location to respawn at","color":"white","italic":false},{"text":"Respawn 1.5 seconds faster","color":"white","italic":false},{"text":"Can be shot","color":"white","italic":false},{"text":"Max active: 1","color":"white","italic":false},{"text":"Returned on flag capture","color":"white","italic":false}],entity_data={id:"minecraft:slime",PersistenceRequired:1b,Silent:1b,Size:0},tooltip_display={hidden_components:["attribute_modifiers","can_break","custom_model_data","unbreakable","tooltip_display","weapon","max_damage","can_place_on","trim","dyed_color","damage","enchantments","food","tool","tooltip_display","potion_contents","item_model","item_name"]}] 2
item replace block 235 -49 -223 container.20 with map[custom_name={"text":"Reveal","italic":false,"color":"gray"},lore=[{"text":"See enemy players and placables","color":"white","italic":false},{"text":"through walls for 6 seconds","color":"white","italic":false}],tooltip_display={hidden_components:["attribute_modifiers","can_break","custom_model_data","unbreakable","tooltip_display","weapon","max_damage","can_place_on","trim","dyed_color","damage","enchantments","food","tool","tooltip_display","potion_contents","item_model","item_name"]}] 1
item replace block 235 -49 -223 container.23 with crossbow[custom_name={"text":"Crossbow (12 seconds)","italic":false,"color":"gray"},lore=[{"text":"Automatic rapid fire crossbow","color":"white","italic":false},{"text":"Keep out of range of small children","color":"white","italic":false}],enchantments={"minecraft:quick_charge":1},custom_data={trigger:1b},tooltip_display={hidden_components:["attribute_modifiers","can_break","custom_model_data","unbreakable","tooltip_display","weapon","max_damage","can_place_on","trim","dyed_color","damage","enchantments","food","tool","tooltip_display","potion_contents","item_model","item_name"]}] 1
item replace block 235 -49 -223 container.15 with iron_ingot[custom_name={"text":"Armor","color":"gray","italic":false},lore=[{"text":"Survive one arrow hit","color":"white","italic":false},{"text":"Doesn\'t block explosions","color":"white","italic":false},{"text":"Drops the flag","color":"white","italic":false}],tooltip_display={hidden_components:["attribute_modifiers","can_break","custom_model_data","unbreakable","tooltip_display","weapon","max_damage","can_place_on","trim","dyed_color","damage","enchantments","food","tool","tooltip_display","potion_contents","item_model","item_name"]}] 2
item replace block 235 -49 -223 container.21 with egg[custom_name={"text":"Boost","italic":false,"color":"gray"},lore=[{"text":"Explode forward","color":"white","italic":false}],tooltip_display={hidden_components:["attribute_modifiers","can_break","custom_model_data","unbreakable","tooltip_display","weapon","max_damage","can_place_on","trim","dyed_color","damage","enchantments","food","tool","tooltip_display","potion_contents","item_model","item_name"]}] 1
item replace block 235 -49 -223 container.22 with ender_pearl[custom_name={"text":"Zoomies (8 Seconds)","italic":false,"color":"gray"},lore=[{"text":"Speed and jump boost for 8 seconds","color":"white","italic":false}],tooltip_display={hidden_components:["attribute_modifiers","can_break","custom_model_data","unbreakable","tooltip_display","weapon","max_damage","can_place_on","trim","dyed_color","damage","enchantments","food","tool","tooltip_display","potion_contents","item_model","item_name"]}] 1
item replace block 235 -49 -223 container.24 with minecraft:netherite_sword[custom_name={"text":"Claws","italic":false,"color":"gray"},minecraft:max_damage=1,lore=[{"text":"Claw players, placables, and walls","color":"white","italic":false}],damage=0,can_break=[{blocks:"gravel"}],enchantments={"minecraft:knockback":3},attribute_modifiers=[{id:"attack_damage",type:"attack_damage",amount:100,operation:"add_value",slot:"any"}],tooltip_display={hidden_components:["attribute_modifiers","can_break","custom_model_data","unbreakable","tooltip_display","weapon","max_damage","can_place_on","trim","dyed_color","damage","enchantments","food","tool","tooltip_display","potion_contents","item_model","item_name"]}] 1
item replace block 235 -49 -223 container.19 with pig_spawn_egg[custom_model_data={strings:["4"]},can_place_on=[{blocks:"#game:bolt_place"}],custom_name={"text":"Turret","italic":false,"color":"gray"},lore=[{"text":"Turret that shoots players and minions","color":"white","italic":false},{"text":"Range: 20 blocks","color":"white","italic":false},{"text":"Charge time: 1s","color":"white","italic":false},{"text":"Max active: 5","color":"white","italic":false}],entity_data={id:"minecraft:pig",PersistenceRequired:0b,Silent:1b,NoAI:1,IsBaby:0b,Health:10f},tooltip_display={hidden_components:["attribute_modifiers","can_break","custom_model_data","unbreakable","tooltip_display","weapon","max_damage","can_place_on","trim","dyed_color","damage","enchantments","food","tool","tooltip_display","potion_contents","item_model","item_name"]}] 1
item replace block 235 -49 -223 container.14 with minecraft:zombie_villager_spawn_egg[can_place_on=[{blocks:"#game:bolt_place"}],custom_name={"text":"Minion","italic":false,"color":"gray"},lore=[{"text":"Summon zombie that attacks enemies","color":"white","italic":false},{"text":"Max active: 12","color":"white","italic":false}],entity_data={id:"minecraft:zombie_villager",PersistenceRequired:1b,CanPickUpLoot:0b,Health:10f,IsBaby:0b,equipment:{head:{id:"minecraft:zombie_head",count:1}},Attributes:[{Name:max_health,Base:1},{Name:movement_speed,Base:0.33}]},tooltip_display={hidden_components:["attribute_modifiers","can_break","custom_model_data","unbreakable","tooltip_display","weapon","max_damage","can_place_on","trim","dyed_color","damage","enchantments","food","tool","tooltip_display","potion_contents","item_model","item_name"]}] 2

# change preset
execute unless items block 235 -49 -223 container.0 paper run function game:tmi/click_paper

item replace block 235 -49 -223 container.1 with black_stained_glass_pane[custom_name={"text":""},tooltip_display={hide_tooltip:true}]
item replace block 235 -49 -223 container.2 with black_stained_glass_pane[custom_name={"text":""},tooltip_display={hide_tooltip:true}]
item replace block 235 -49 -223 container.3 with black_stained_glass_pane[custom_name={"text":""},tooltip_display={hide_tooltip:true}]
item replace block 235 -49 -223 container.4 with black_stained_glass_pane[custom_name={"text":""},tooltip_display={hide_tooltip:true}]
item replace block 235 -49 -223 container.5 with black_stained_glass_pane[custom_name={"text":""},tooltip_display={hide_tooltip:true}]
item replace block 235 -49 -223 container.6 with black_stained_glass_pane[custom_name={"text":""},tooltip_display={hide_tooltip:true}]
item replace block 235 -49 -223 container.7 with black_stained_glass_pane[custom_name={"text":""},tooltip_display={hide_tooltip:true}]

execute if score .tmi_objective .data matches 0 unless data block 235 -49 -223 {Items:[{Slot:8b,id:"minecraft:red_dye"}]} run scoreboard players set .tmi_objective .data 11
execute if score .tmi_objective .data matches 1 unless data block 235 -49 -223 {Items:[{Slot:8b,id:"minecraft:beacon"}]} run scoreboard players set .tmi_objective .data 12
execute if score .tmi_objective .data matches 2 unless data block 235 -49 -223 {Items:[{Slot:8b,id:"minecraft:skeleton_skull"}]} run scoreboard players set .tmi_objective .data 10

execute if score .tmi_objective .data matches 10 run scoreboard players set .tmi_objective .data 0
execute if score .tmi_objective .data matches 11 run scoreboard players set .tmi_objective .data 1
execute if score .tmi_objective .data matches 12 run scoreboard players set .tmi_objective .data 2

execute if score .tmi_objective .data matches 0 run item replace block 235 -49 -223 container.8 with red_dye[custom_name={"text":"Capture the Flag","italic":false},lore=[{"text":"Normal capture the flag","color":"white","italic":false},{"text":"First to three","color":"white","italic":false}]]
execute if score .tmi_objective .data matches 1 run item replace block 235 -49 -223 container.8 with beacon[custom_name={"text":"Capture the Point","italic":false},lore=[{"text":"Stand on flag one second to capture","color":"white","italic":false},{"text":"First to five","color":"white","italic":false}]]
execute if score .tmi_objective .data matches 2 run item replace block 235 -49 -223 container.8 with minecraft:skeleton_skull[custom_name={"text":"Team Deathmatch","italic":false},lore=[{"text":"Kills give points","color":"white","italic":false},{"text":"First to nine","color":"white","italic":false}]]

item replace block 235 -49 -223 container.9 with black_stained_glass_pane[custom_name={"text":""},tooltip_display={hide_tooltip:true}]

item replace block 235 -49 -223 container.16 with black_stained_glass_pane[custom_name={"text":""},tooltip_display={hide_tooltip:true}]

execute if score .tmi_arrow .data matches 0 unless data block 235 -49 -223 {Items:[{Slot:17b,id:"minecraft:arrow"}]} run scoreboard players set .tmi_arrow .data 11
execute if score .tmi_arrow .data matches 1 unless data block 235 -49 -223 {Items:[{Slot:17b,id:"minecraft:wind_charge"}]} run scoreboard players set .tmi_arrow .data 12
execute if score .tmi_arrow .data matches 2 unless data block 235 -49 -223 {Items:[{Slot:17b,id:"minecraft:arrow"}]} run scoreboard players set .tmi_arrow .data 10

execute if score .tmi_arrow .data matches 10 run scoreboard players set .tmi_arrow .data 0
execute if score .tmi_arrow .data matches 11 run scoreboard players set .tmi_arrow .data 1
execute if score .tmi_arrow .data matches 12 run scoreboard players set .tmi_arrow .data 2

execute if score .tmi_arrow .data matches 0 run item replace block 235 -49 -223 container.17 with arrow[custom_name={"text":"Normal Arrow","italic":false},custom_data={chest:1},lore=[{"text":"Normal reloading arrows","color":"white","italic":false}]]
execute if score .tmi_arrow .data matches 1 run item replace block 235 -49 -223 container.17 with wind_charge[custom_name={"text":"Wind Arrow","italic":false},custom_data={chest:1},lore=[{"text":"Arrows explode if they hit a wall","color":"white","italic":false}]]
execute if score .tmi_arrow .data matches 2 run item replace block 235 -49 -223 container.17 with arrow[custom_model_data={strings:["3"]},custom_name={"text":"Three in the quiver","italic":false,"color":white},custom_data={chest:1},lore=[{"text":"Start with three arrows. Kills reloads one arrow.","color":"white","italic":false},{"text":"Trap, spawn, and turret kills count","color":"white","italic":false},{"text":"Wall hits reload arrow","color":"white","italic":false},{"text":"If no arrow, reload one in 8s","color":"white","italic":false}]]

item replace block 235 -49 -223 container.18 with black_stained_glass_pane[custom_name={"text":""},tooltip_display={hide_tooltip:true}]

item replace block 235 -49 -223 container.25 with black_stained_glass_pane[custom_name={"text":""},tooltip_display={hide_tooltip:true}]

execute if score .tmi_fog .data matches 0 unless data block 235 -49 -223 {Items:[{Slot:26b,id:"minecraft:pink_dye"}]} run scoreboard players set .tmi_fog .data 11
execute if score .tmi_fog .data matches 1 unless data block 235 -49 -223 {Items:[{Slot:26b,id:"minecraft:purple_dye"}]} run scoreboard players set .tmi_fog .data 12
execute if score .tmi_fog .data matches 2 unless data block 235 -49 -223 {Items:[{Slot:26b,id:"minecraft:black_dye"}]} run scoreboard players set .tmi_fog .data 10

execute if score .tmi_fog .data matches 10 run scoreboard players set .tmi_fog .data 0
execute if score .tmi_fog .data matches 11 run scoreboard players set .tmi_fog .data 1
execute if score .tmi_fog .data matches 12 run scoreboard players set .tmi_fog .data 2

execute if score .tmi_fog .data matches 0 run item replace block 235 -49 -223 container.26 with pink_dye[custom_name={"text":"No Fog","italic":false}]
execute if score .tmi_fog .data matches 1 run item replace block 235 -49 -223 container.26 with purple_dye[custom_name={"text":"Fog","italic":false}]
execute if score .tmi_fog .data matches 2 run item replace block 235 -49 -223 container.26 with black_dye[custom_name={"text":"Blindness","italic":false}]

#item replace block 235 -49 -224 container.0 with gray_stained_glass_pane{custom_name={"text":"Bow Slot","italic":false}}}
#item replace block 235 -49 -224 container.17 with gray_stained_glass_pane{custom_name={"text":"Arrow Slot","italic":false},lore=[{"text":"Unable to be changed","italic":false,"color":"gray"}]}}

item replace block 235 -49 -224 container.0 with black_stained_glass_pane[custom_name={"text":""},tooltip_display={hide_tooltip:true}]
item replace block 235 -49 -224 container.1 with black_stained_glass_pane[custom_name={"text":""},tooltip_display={hide_tooltip:true}]
item replace block 235 -49 -224 container.2 with black_stained_glass_pane[custom_name={"text":""},tooltip_display={hide_tooltip:true}]
item replace block 235 -49 -224 container.3 with black_stained_glass_pane[custom_name={"text":""},tooltip_display={hide_tooltip:true}]
item replace block 235 -49 -224 container.4 with black_stained_glass_pane[custom_name={"text":""},tooltip_display={hide_tooltip:true}]
item replace block 235 -49 -224 container.5 with black_stained_glass_pane[custom_name={"text":""},tooltip_display={hide_tooltip:true}]
item replace block 235 -49 -224 container.6 with black_stained_glass_pane[custom_name={"text":""},tooltip_display={hide_tooltip:true}]
item replace block 235 -49 -224 container.7 with black_stained_glass_pane[custom_name={"text":""},tooltip_display={hide_tooltip:true}]
item replace block 235 -49 -224 container.8 with black_stained_glass_pane[custom_name={"text":""},tooltip_display={hide_tooltip:true}]

item replace block 235 -49 -224 container.9 with purple_stained_glass_pane[custom_model_data={strings:["1"]},custom_name={"text":"Start Items","italic":false},lore=[{"text":"These slots control items you have","italic":false},{"text":"given at start of game.","italic":false}]]
item replace block 235 -49 -224 container.14 with purple_stained_glass_pane[custom_model_data={strings:["2"]},custom_name={"text":"Life Items","italic":false},lore=[{"text":"These slots control items you have","italic":false},{"text":"given at start of a life.","italic":false}]]

item replace block 235 -49 -224 container.18 with purple_stained_glass_pane[custom_model_data={strings:["3"]},custom_name={"text":"Every _ Kills [1/3/5/7]","italic":false},lore=[{"text":"These slots control items you are","italic":false},{"text":"given after an amount of kills.","italic":false}]]
item replace block 235 -49 -224 container.23 with purple_stained_glass_pane[custom_model_data={strings:["4"]},custom_name={"text":"Every _ Seconds [12/20/31]","italic":false},lore=[{"text":"These slots control items you are","italic":false},{"text":"given after a set amount of time.","italic":false}]]

tag @a remove tmi_chest_clear
execute as @a[tag=lobby] if items entity @s player.cursor #game:lobby_no_hold run tag @s add tmi_chest_clear
execute as @a[tag=lobby] if items entity @s player.cursor black_stained_glass_pane[custom_name={"text":""},tooltip_display={hide_tooltip:true}] run tag @s add tmi_chest_clear
execute as @a[tag=lobby] if items entity @s player.cursor arrow[custom_data={chest:1}] run tag @s add tmi_chest_clear
execute as @a[tag=lobby] if items entity @s hotbar.* #game:lobby_no run tag @s add tmi_chest_clear
execute as @a[tag=lobby] if items entity @s hotbar.* snowball[custom_model_data={strings:["0"]}] run tag @s add tmi_chest_clear
execute as @a[tag=lobby] if items entity @s hotbar.* gray_dye[custom_data={chest:1}] run tag @s add tmi_chest_clear
execute as @a[tag=lobby] if items entity @s hotbar.* arrow[custom_data={chest:1}] run tag @s add tmi_chest_clear
execute as @a[tag=lobby] if items entity @s hotbar.* black_stained_glass_pane[custom_name={"text":""},tooltip_display={hide_tooltip:true}] run tag @s add tmi_chest_clear
execute as @a[tag=lobby] if items entity @s inventory.* #game:lobby_no run tag @s add tmi_chest_clear
execute as @a[tag=lobby] if items entity @s inventory.* snowball[custom_model_data={strings:["0"]}] run tag @s add tmi_chest_clear
execute as @a[tag=lobby] if items entity @s inventory.* gray_dye[custom_data={chest:1}] run tag @s add tmi_chest_clear
execute as @a[tag=lobby] if items entity @s inventory.* arrow[custom_data={chest:1}] run tag @s add tmi_chest_clear
execute as @a[tag=lobby] if items entity @s inventory.* black_stained_glass_pane[custom_name={"text":""},tooltip_display={hide_tooltip:true}] run tag @s add tmi_chest_clear
execute as @a[tag=tmi_chest_clear] run function game:tmi/clear_lobby

# clear things that don't belong
execute if items block 235 -49 -224 container.10 #game:chest_no run item replace block 235 -49 -224 container.10 with air
execute if items block 235 -49 -224 container.11 #game:chest_no run item replace block 235 -49 -224 container.11 with air
execute if items block 235 -49 -224 container.12 #game:chest_no run item replace block 235 -49 -224 container.12 with air
execute if items block 235 -49 -224 container.13 #game:chest_no run item replace block 235 -49 -224 container.13 with air

execute if items block 235 -49 -224 container.15 #game:chest_no run item replace block 235 -49 -224 container.15 with air
execute if items block 235 -49 -224 container.16 #game:chest_no run item replace block 235 -49 -224 container.16 with air
execute if items block 235 -49 -224 container.17 #game:chest_no run item replace block 235 -49 -224 container.17 with air

execute if items block 235 -49 -224 container.19 #game:chest_no run item replace block 235 -49 -224 container.19 with air
execute if items block 235 -49 -224 container.20 #game:chest_no run item replace block 235 -49 -224 container.20 with air
execute if items block 235 -49 -224 container.21 #game:chest_no run item replace block 235 -49 -224 container.21 with air
execute if items block 235 -49 -224 container.22 #game:chest_no run item replace block 235 -49 -224 container.22 with air

execute if items block 235 -49 -224 container.23 #game:chest_no run item replace block 235 -49 -224 container.23 with air
execute if items block 235 -49 -224 container.24 #game:chest_no run item replace block 235 -49 -224 container.24 with air
execute if items block 235 -49 -224 container.25 #game:chest_no run item replace block 235 -49 -224 container.25 with air