execute unless block ~ ~ ~ trapped_chest{Items:[{Slot:0b}]} run replaceitem block ~ ~ ~ container.0 minecraft:wooden_sword{display:{Name:'{"text":"Enchant Tools, Weapons and","color":"gray"}',Lore:['{"text":"Books with an Emerald Ability.","color":"gray"}']},HideFlags:63,CustomModelData:1412002,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: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:13b}]} unless block ~ ~ ~ trapped_chest{Items:[{Slot:13b,tag:{nl_UI:1b}}]} run function next_level:custom_blocks/global/spit_out/slot_13
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:16b}]} unless block ~ ~ ~ trapped_chest{Items:[{Slot:16b,tag:{nl_UI:1b}}]} run function next_level:custom_blocks/global/spit_out/slot_16
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: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":"Enchant Tools, Weapons and","color":"gray"}',Lore:['{"text":"Books with an Emerald Ability.","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":"Enchant Tools, Weapons and","color":"gray"}',Lore:['{"text":"Books with an Emerald Ability.","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":"Enchant Tools, Weapons and","color":"gray"}',Lore:['{"text":"Books with an Emerald Ability.","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":"Enchant Tools, Weapons and","color":"gray"}',Lore:['{"text":"Books with an Emerald Ability.","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":"Enchant Tools, Weapons and","color":"gray"}',Lore:['{"text":"Books with an Emerald Ability.","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":"Enchant Tools, Weapons and","color":"gray"}',Lore:['{"text":"Books with an Emerald Ability.","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":"Enchant Tools, Weapons and","color":"gray"}',Lore:['{"text":"Books with an Emerald Ability.","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":"Enchant Tools, Weapons and","color":"gray"}',Lore:['{"text":"Books with an Emerald Ability.","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":"Enchant Tools, Weapons and","color":"gray"}',Lore:['{"text":"Books with an Emerald Ability.","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":"Enchant Tools, Weapons and","color":"gray"}',Lore:['{"text":"Books with an Emerald Ability.","color":"gray"}']},nl_UI:1b}
execute unless block ~ ~ ~ trapped_chest{Items:[{Slot:13b}]} run replaceitem block ~ ~ ~ container.13 minecraft:structure_block{CustomModelData:1412002,display:{Name:'{"text":"Enchant Tools, Weapons and","color":"gray"}',Lore:['{"text":"Books with an Emerald Ability.","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":"Enchant Tools, Weapons and","color":"gray"}',Lore:['{"text":"Books with an Emerald Ability.","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":"Enchant Tools, Weapons and","color":"gray"}',Lore:['{"text":"Books with an Emerald Ability.","color":"gray"}']},nl_UI:1b}
execute unless block ~ ~ ~ trapped_chest{Items:[{Slot:16b}]} run replaceitem block ~ ~ ~ container.16 minecraft:structure_block{CustomModelData:1412002,display:{Name:'{"text":"Enchant Tools, Weapons and","color":"gray"}',Lore:['{"text":"Books with an Emerald Ability.","color":"gray"}']},nl_UI:1b}
execute unless block ~ ~ ~ trapped_chest{Items:[{Slot:17b}]} run replaceitem block ~ ~ ~ container.17 minecraft:structure_block{CustomModelData:1412002,display:{Name:'{"text":"Enchant Tools, Weapons and","color":"gray"}',Lore:['{"text":"Books with an Emerald Ability.","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":"Enchant Tools, Weapons and","color":"gray"}',Lore:['{"text":"Books with an Emerald Ability.","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":"Enchant Tools, Weapons and","color":"gray"}',Lore:['{"text":"Books with an Emerald Ability.","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":"Enchant Tools, Weapons and","color":"gray"}',Lore:['{"text":"Books with an Emerald Ability.","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":"Enchant Tools, Weapons and","color":"gray"}',Lore:['{"text":"Books with an Emerald Ability.","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":"Enchant Tools, Weapons and","color":"gray"}',Lore:['{"text":"Books with an Emerald Ability.","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":"Enchant Tools, Weapons and","color":"gray"}',Lore:['{"text":"Books with an Emerald Ability.","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":"Enchant Tools, Weapons and","color":"gray"}',Lore:['{"text":"Books with an Emerald Ability.","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":"Enchant Tools, Weapons and","color":"gray"}',Lore:['{"text":"Books with an Emerald Ability.","color":"gray"}']},nl_UI:1b}

execute as @a[scores={nl.Enchant=..0}] store result score @s nl.Enchant run clear @s minecraft:emerald{nl_Enchant_Slot1:1b} 0
execute as @a[scores={nl.Enchant=1..}] run function next_level:custom_blocks/emerald_enchanter/enchant_slot1/trigger
execute if block ~ ~ ~ trapped_chest{Items:[{Slot:22b}]} unless block ~ ~ ~ trapped_chest{Items:[{Slot:22b,tag:{nl_Enchant_Slot1:1b}}]} run function next_level:custom_blocks/global/spit_out/slot_22

execute unless block ~ ~ ~ trapped_chest{Items:[{Slot:22b}]} run replaceitem block ~ ~ ~ container.22 minecraft:emerald{display:{Name:'{"text":"Click to Enchant","color":"green","italic":false}',Lore:['{"text":" "}','{"text":"Enchant Tools, Weapons and ","color":"gray","italic":false}','{"text":"books with an Emerald Ability.","color":"gray","italic":false}','{"text":" "}','{"text":"Cost: ","color":"red","italic":false}','{"text":" - 10 Levels","color":"red","italic":"false"}','{"text":" - 1 Emerald","color":"red","italic":false}','{"text":" "}','{"text":"Reward:","color":"dark_green","italic":false}','{"text":" + Random Enchantment(s)","color":"dark_green","italic":false}']},nl_Enchant_Slot1:1b}
execute if block ~ ~ ~ trapped_chest{Items:[{Slot:10}]}
execute if block ~ ~ ~ trapped_chest{Items:[{Slot:22b,tag:{nl_Enchant_Slot1:1b}}]} unless block ~ ~ ~ trapped_chest{Items:[{Slot:10b,Count:1b},{Slot:11b,id:"minecraft:emerald"}]} run replaceitem block ~ ~ ~ container.22 minecraft:air 
execute if block ~ ~ ~ trapped_chest{Items:[{Slot:22b,tag:{nl_Enchant_Slot1:1b}},{Slot:10b,Count:1b,tag:{nl_Has_Slot1_Enchantment:1b}}]} run replaceitem block ~ ~ ~ container.22 minecraft:air 