
execute unless block ~ ~ ~ trapped_chest{Items:[{Slot:0b}]} run replaceitem block ~ ~ ~ container.0 minecraft:wooden_sword{display:{Name:'{"text":"Re-Roll Quality of Tools,","color":"gray"}',Lore:['{"text":"Weapons and Armor.","color":"gray"}']},HideFlags:63,CustomModelData:1412004,nl_UI:1b}

execute if block ~ ~ ~ trapped_chest{Items:[{Slot:0b}]} unless block ~ ~ ~ trapped_chest{Items:[{Slot:0b,tag:{nl_UI:1b}}]} run function next_level:custom_blocks/global/spit_out/slot_0

execute if block ~ ~ ~ trapped_chest{Items:[{Slot:1b}]} unless block ~ ~ ~ trapped_chest{Items:[{Slot:1b,tag:{nl_UI:1b}}]} run function next_level:custom_blocks/global/spit_out/slot_1
execute if block ~ ~ ~ trapped_chest{Items:[{Slot:2b}]} unless block ~ ~ ~ trapped_chest{Items:[{Slot:2b,tag:{nl_UI:1b}}]} run function next_level:custom_blocks/global/spit_out/slot_2
execute if block ~ ~ ~ trapped_chest{Items:[{Slot:3b}]} unless block ~ ~ ~ trapped_chest{Items:[{Slot:3b,tag:{nl_UI:1b}}]} run function next_level:custom_blocks/global/spit_out/slot_3
execute if block ~ ~ ~ trapped_chest{Items:[{Slot:4b}]} unless block ~ ~ ~ trapped_chest{Items:[{Slot:4b,tag:{nl_UI:1b}}]} run function next_level:custom_blocks/global/spit_out/slot_4
execute if block ~ ~ ~ trapped_chest{Items:[{Slot:5b}]} unless block ~ ~ ~ trapped_chest{Items:[{Slot:5b,tag:{nl_UI:1b}}]} run function next_level:custom_blocks/global/spit_out/slot_5
execute if block ~ ~ ~ trapped_chest{Items:[{Slot:6b}]} unless block ~ ~ ~ trapped_chest{Items:[{Slot:6b,tag:{nl_UI:1b}}]} run function next_level:custom_blocks/global/spit_out/slot_6
execute if block ~ ~ ~ trapped_chest{Items:[{Slot:7b}]} unless block ~ ~ ~ trapped_chest{Items:[{Slot:7b,tag:{nl_UI:1b}}]} run function next_level:custom_blocks/global/spit_out/slot_7
execute if block ~ ~ ~ trapped_chest{Items:[{Slot:8b}]} unless block ~ ~ ~ trapped_chest{Items:[{Slot:8b,tag:{nl_UI:1b}}]} run function next_level:custom_blocks/global/spit_out/slot_8
execute if block ~ ~ ~ trapped_chest{Items:[{Slot:9b}]} unless block ~ ~ ~ trapped_chest{Items:[{Slot:9b,tag:{nl_UI:1b}}]} run function next_level:custom_blocks/global/spit_out/slot_9

execute if block ~ ~ ~ trapped_chest{Items:[{Slot:11b}]} unless block ~ ~ ~ trapped_chest{Items:[{Slot:11b,tag:{nl_UI:1b}}]} run function next_level:custom_blocks/global/spit_out/slot_11
execute if block ~ ~ ~ trapped_chest{Items:[{Slot:12b}]} unless block ~ ~ ~ trapped_chest{Items:[{Slot:12b,tag:{nl_UI:1b}}]} run function next_level:custom_blocks/global/spit_out/slot_12

execute if block ~ ~ ~ trapped_chest{Items:[{Slot:14b}]} unless block ~ ~ ~ trapped_chest{Items:[{Slot:14b,tag:{nl_UI:1b}}]} run function next_level:custom_blocks/global/spit_out/slot_14
execute if block ~ ~ ~ trapped_chest{Items:[{Slot:15b}]} unless block ~ ~ ~ trapped_chest{Items:[{Slot:15b,tag:{nl_UI:1b}}]} run function next_level:custom_blocks/global/spit_out/slot_15

execute if block ~ ~ ~ trapped_chest{Items:[{Slot:17b}]} unless block ~ ~ ~ trapped_chest{Items:[{Slot:17b,tag:{nl_UI:1b}}]} run function next_level:custom_blocks/global/spit_out/slot_17
execute if block ~ ~ ~ trapped_chest{Items:[{Slot:18b}]} unless block ~ ~ ~ trapped_chest{Items:[{Slot:18b,tag:{nl_UI:1b}}]} run function next_level:custom_blocks/global/spit_out/slot_18
execute if block ~ ~ ~ trapped_chest{Items:[{Slot:19b}]} unless block ~ ~ ~ trapped_chest{Items:[{Slot:19b,tag:{nl_UI:1b}}]} run function next_level:custom_blocks/global/spit_out/slot_19
execute if block ~ ~ ~ trapped_chest{Items:[{Slot:20b}]} unless block ~ ~ ~ trapped_chest{Items:[{Slot:20b,tag:{nl_UI:1b}}]} run function next_level:custom_blocks/global/spit_out/slot_20
execute if block ~ ~ ~ trapped_chest{Items:[{Slot:21b}]} unless block ~ ~ ~ trapped_chest{Items:[{Slot:21b,tag:{nl_UI:1b}}]} run function next_level:custom_blocks/global/spit_out/slot_21
execute if block ~ ~ ~ trapped_chest{Items:[{Slot:22b}]} unless block ~ ~ ~ trapped_chest{Items:[{Slot:22b,tag:{nl_UI:1b}}]} run function next_level:custom_blocks/global/spit_out/slot_22
execute if block ~ ~ ~ trapped_chest{Items:[{Slot:23b}]} unless block ~ ~ ~ trapped_chest{Items:[{Slot:23b,tag:{nl_UI:1b}}]} run function next_level:custom_blocks/global/spit_out/slot_23
execute if block ~ ~ ~ trapped_chest{Items:[{Slot:24b}]} unless block ~ ~ ~ trapped_chest{Items:[{Slot:24b,tag:{nl_UI:1b}}]} run function next_level:custom_blocks/global/spit_out/slot_24
execute if block ~ ~ ~ trapped_chest{Items:[{Slot:25b}]} unless block ~ ~ ~ trapped_chest{Items:[{Slot:25b,tag:{nl_UI:1b}}]} run function next_level:custom_blocks/global/spit_out/slot_25
execute if block ~ ~ ~ trapped_chest{Items:[{Slot:26b}]} unless block ~ ~ ~ trapped_chest{Items:[{Slot:26b,tag:{nl_UI:1b}}]} run function next_level:custom_blocks/global/spit_out/slot_26

execute unless block ~ ~ ~ trapped_chest{Items:[{Slot:1b}]} run replaceitem block ~ ~ ~ container.1 minecraft:structure_block{CustomModelData:1412002,display:{Name:'{"text":"Re-Roll Quality of Tools,","color":"gray"}',Lore:['{"text":"Weapons and Armor.","color":"gray"}']},nl_UI:1b}
execute unless block ~ ~ ~ trapped_chest{Items:[{Slot:2b}]} run replaceitem block ~ ~ ~ container.2 minecraft:structure_block{CustomModelData:1412002,display:{Name:'{"text":"Re-Roll Quality of Tools,","color":"gray"}',Lore:['{"text":"Weapons and Armor.","color":"gray"}']},nl_UI:1b}
execute unless block ~ ~ ~ trapped_chest{Items:[{Slot:3b}]} run replaceitem block ~ ~ ~ container.3 minecraft:structure_block{CustomModelData:1412002,display:{Name:'{"text":"Re-Roll Quality of Tools,","color":"gray"}',Lore:['{"text":"Weapons and Armor.","color":"gray"}']},nl_UI:1b}
execute unless block ~ ~ ~ trapped_chest{Items:[{Slot:4b}]} run replaceitem block ~ ~ ~ container.4 minecraft:structure_block{CustomModelData:1412002,display:{Name:'{"text":"Re-Roll Quality of Tools,","color":"gray"}',Lore:['{"text":"Weapons and Armor.","color":"gray"}']},nl_UI:1b}
execute unless block ~ ~ ~ trapped_chest{Items:[{Slot:5b}]} run replaceitem block ~ ~ ~ container.5 minecraft:structure_block{CustomModelData:1412002,display:{Name:'{"text":"Re-Roll Quality of Tools,","color":"gray"}',Lore:['{"text":"Weapons and Armor.","color":"gray"}']},nl_UI:1b}
execute unless block ~ ~ ~ trapped_chest{Items:[{Slot:6b}]} run replaceitem block ~ ~ ~ container.6 minecraft:structure_block{CustomModelData:1412002,display:{Name:'{"text":"Re-Roll Quality of Tools,","color":"gray"}',Lore:['{"text":"Weapons and Armor.","color":"gray"}']},nl_UI:1b}
execute unless block ~ ~ ~ trapped_chest{Items:[{Slot:7b}]} run replaceitem block ~ ~ ~ container.7 minecraft:structure_block{CustomModelData:1412002,display:{Name:'{"text":"Re-Roll Quality of Tools,","color":"gray"}',Lore:['{"text":"Weapons and Armor.","color":"gray"}']},nl_UI:1b}
execute unless block ~ ~ ~ trapped_chest{Items:[{Slot:8b}]} run replaceitem block ~ ~ ~ container.8 minecraft:structure_block{CustomModelData:1412002,display:{Name:'{"text":"Re-Roll Quality of Tools,","color":"gray"}',Lore:['{"text":"Weapons and Armor.","color":"gray"}']},nl_UI:1b}
execute unless block ~ ~ ~ trapped_chest{Items:[{Slot:9b}]} run replaceitem block ~ ~ ~ container.9 minecraft:structure_block{CustomModelData:1412002,display:{Name:'{"text":"Re-Roll Quality of Tools,","color":"gray"}',Lore:['{"text":"Weapons and Armor.","color":"gray"}']},nl_UI:1b}

execute unless block ~ ~ ~ trapped_chest{Items:[{Slot:11b}]} run replaceitem block ~ ~ ~ container.11 minecraft:structure_block{CustomModelData:1412002,display:{Name:'{"text":"Re-Roll Quality of Tools,","color":"gray"}',Lore:['{"text":"Weapons and Armor.","color":"gray"}']},nl_UI:1b}
execute unless block ~ ~ ~ trapped_chest{Items:[{Slot:12b}]} run replaceitem block ~ ~ ~ container.12 minecraft:structure_block{CustomModelData:1412002,display:{Name:'{"text":"Re-Roll Quality of Tools,","color":"gray"}',Lore:['{"text":"Weapons and Armor.","color":"gray"}']},nl_UI:1b}

execute unless block ~ ~ ~ trapped_chest{Items:[{Slot:14b}]} run replaceitem block ~ ~ ~ container.14 minecraft:structure_block{CustomModelData:1412002,display:{Name:'{"text":"Re-Roll Quality of Tools,","color":"gray"}',Lore:['{"text":"Weapons and Armor.","color":"gray"}']},nl_UI:1b}
execute unless block ~ ~ ~ trapped_chest{Items:[{Slot:15b}]} run replaceitem block ~ ~ ~ container.15 minecraft:structure_block{CustomModelData:1412002,display:{Name:'{"text":"Re-Roll Quality of Tools,","color":"gray"}',Lore:['{"text":"Weapons and Armor.","color":"gray"}']},nl_UI:1b}

execute if block ~ ~ ~ trapped_chest{Items:[{Slot:16b}]} unless block ~ ~ ~ trapped_chest{Items:[{Slot:16b,tag:{nl_ValidOp:1b}}]} run function next_level:custom_blocks/global/spit_out/slot_16

execute unless block ~ ~ ~ trapped_chest{Items:[{Slot:17b}]} run replaceitem block ~ ~ ~ container.17 minecraft:structure_block{CustomModelData:1412002,display:{Name:'{"text":"Re-Roll Quality of Tools,","color":"gray"}',Lore:['{"text":"Weapons and Armor.","color":"gray"}']},nl_UI:1b}
execute unless block ~ ~ ~ trapped_chest{Items:[{Slot:18b}]} run replaceitem block ~ ~ ~ container.18 minecraft:structure_block{CustomModelData:1412002,display:{Name:'{"text":"Re-Roll Quality of Tools,","color":"gray"}',Lore:['{"text":"Weapons and Armor.","color":"gray"}']},nl_UI:1b}
execute unless block ~ ~ ~ trapped_chest{Items:[{Slot:19b}]} run replaceitem block ~ ~ ~ container.19 minecraft:structure_block{CustomModelData:1412002,display:{Name:'{"text":"Re-Roll Quality of Tools,","color":"gray"}',Lore:['{"text":"Weapons and Armor.","color":"gray"}']},nl_UI:1b}
execute unless block ~ ~ ~ trapped_chest{Items:[{Slot:20b}]} run replaceitem block ~ ~ ~ container.20 minecraft:structure_block{CustomModelData:1412002,display:{Name:'{"text":"Re-Roll Quality of Tools,","color":"gray"}',Lore:['{"text":"Weapons and Armor.","color":"gray"}']},nl_UI:1b}
execute unless block ~ ~ ~ trapped_chest{Items:[{Slot:21b}]} run replaceitem block ~ ~ ~ container.21 minecraft:structure_block{CustomModelData:1412002,display:{Name:'{"text":"Re-Roll Quality of Tools,","color":"gray"}',Lore:['{"text":"Weapons and Armor.","color":"gray"}']},nl_UI:1b}
execute unless block ~ ~ ~ trapped_chest{Items:[{Slot:22b}]} run replaceitem block ~ ~ ~ container.22 minecraft:structure_block{CustomModelData:1412002,display:{Name:'{"text":"Re-Roll Quality of Tools,","color":"gray"}',Lore:['{"text":"Weapons and Armor.","color":"gray"}']},nl_UI:1b}
execute unless block ~ ~ ~ trapped_chest{Items:[{Slot:23b}]} run replaceitem block ~ ~ ~ container.23 minecraft:structure_block{CustomModelData:1412002,display:{Name:'{"text":"Re-Roll Quality of Tools,","color":"gray"}',Lore:['{"text":"Weapons and Armor.","color":"gray"}']},nl_UI:1b}
execute unless block ~ ~ ~ trapped_chest{Items:[{Slot:24b}]} run replaceitem block ~ ~ ~ container.24 minecraft:structure_block{CustomModelData:1412002,display:{Name:'{"text":"Re-Roll Quality of Tools,","color":"gray"}',Lore:['{"text":"Weapons and Armor.","color":"gray"}']},nl_UI:1b}
execute unless block ~ ~ ~ trapped_chest{Items:[{Slot:25b}]} run replaceitem block ~ ~ ~ container.25 minecraft:structure_block{CustomModelData:1412002,display:{Name:'{"text":"Re-Roll Quality of Tools,","color":"gray"}',Lore:['{"text":"Weapons and Armor.","color":"gray"}']},nl_UI:1b}
execute unless block ~ ~ ~ trapped_chest{Items:[{Slot:26b}]} run replaceitem block ~ ~ ~ container.26 minecraft:structure_block{CustomModelData:1412002,display:{Name:'{"text":"Re-Roll Quality of Tools,","color":"gray"}',Lore:['{"text":"Weapons and Armor.","color":"gray"}']},nl_UI:1b}

execute as @a[scores={nl.Reroll=..0}] store result score @s nl.Reroll run clear @s minecraft:barrier{nl_Reroll.Tool:1b} 0
execute as @a[scores={nl.Reroll=1..}] run function next_level:custom_blocks/diamond_anvil/reroll/tools/check_xp
execute as @a[scores={nl.Reroll=..0}] store result score @s nl.Reroll run clear @s minecraft:barrier{nl_Reroll.Armor:1b} 0
execute as @a[scores={nl.Reroll=1..}] run function next_level:custom_blocks/diamond_anvil/reroll/gear/check_xp
execute unless block ~ ~ ~ trapped_chest{Items:[{Slot:10b},{Slot:13b}]} run replaceitem block ~ ~ ~ container.16 minecraft:air
execute if block ~ ~ ~ trapped_chest{Items:[{Slot:13b}]} run function next_level:custom_blocks/diamond_anvil/check_op