tell @a[team=nl_dev] "function next_level:custom_blocks/diamond_anvil/reroll/gear/spawn_item ok!"
# Spawn in Item Copy #
execute at @s run summon minecraft:item ~ ~ ~ {Tags:["UI_Reroll"],Item:{id:"minecraft:barrier",Count:1b}}
execute at @s run tp @e[tag=UI_Reroll,limit=1,sort=nearest] ~ ~1 ~
execute at @s as @e[distance=..1,tag=UI_Reroll,limit=1] run data modify entity @s Item set from block ~ ~ ~ Items.[{Slot:10b}]

# Store Enchantments and Define Base Item #
execute at @s run function next_level:custom_blocks/diamond_anvil/reroll/store_enchant
    # Check if Custom Item # 
scoreboard players set #Custom nl.Reroll 0
execute at @s store result score #Custom nl.Reroll run data get block ~ ~ ~ Items.[{Slot:10b}].tag.CustomModelData
execute at @s if block ~ ~ ~ trapped_chest{Items:[{Slot:10b,id:"minecraft:shield"}]} store result score #Custom nl.Reroll run data get block ~ ~ ~ Items.[{Slot:10b}].tag.nl_ItemID
execute at @s if score #Custom nl.Reroll matches 1.. run function next_level:custom_blocks/diamond_anvil/reroll/custom_item
execute at @s if score #Custom nl.Reroll matches ..0 run function next_level:custom_blocks/diamond_anvil/reroll/vanilla_item
scoreboard players set #Custom nl.Reroll 0

# Copy Base Item attributes to Copy Item # 
execute at @s as @e[distance=..1,tag=UI_Reroll,limit=1] run data modify entity @s Item set from block ~ ~ ~ Items.[{Slot:10b}]
# Re-Roll Stats # 
execute at @s as @e[distance=..1,tag=UI_Reroll,limit=1] at @s run function next_level:custom_blocks/diamond_anvil/reroll/gear/reroll_quality

# Clear GUI and Copy # 
tag @e[tag=UI_Reroll] remove UI_Reroll
playsound minecraft:block.anvil.use voice @a[distance=..10]
execute at @s run function next_level:custom_blocks/diamond_anvil/reroll/remove_materials
