execute as @a[predicate=survivalplus:tomes/dupe] run tag @s add dupetome
execute at @a[predicate=survivalplus:tomes/dupe] at @n[type=item,nbt={Item:{count:1}},distance=..10,nbt=!{Item:{components:{"minecraft:custom_data":{nodupe:tag}}}}] if predicate survivalplus:50chance run particle minecraft:electric_spark ~ ~.3 ~ .1 .1 .1 .05 1
execute as @a[predicate=survivalplus:tomes/dupe] at @s unless entity @n[type=item,nbt={Item:{count:1}},distance=..10,nbt=!{Item:{components:{"minecraft:custom_data":{nodupe:tag}}}}] run title @s actionbar {"text":"Nothing to dupe!"}
execute as @a[predicate=survivalplus:tomes/dupe] at @s if entity @n[type=item,nbt={Item:{count:1}},distance=..10,nbt=!{Item:{components:{"minecraft:custom_data":{nodupe:tag}}}}] run title @s actionbar {"text":""}
execute as @a[predicate=survivalplus:tomes/dupe] at @s if entity @n[type=item,nbt={Item:{count:1,components:{"minecraft:custom_data":{enchantments:{}}}}},distance=..10,nbt=!{Item:{components:{"minecraft:custom_data":{nodupe:tag}}}}] run title @s actionbar {"text":"Enchantments will not be duplicated!","color":"red"}
execute as @a[predicate=survivalplus:tomes/dupe] at @s if entity @n[type=item,nbt={Item:{count:1,components:{"minecraft:container":[]}}},distance=..10] run title @s actionbar {"text":"Contents will not be duplicated!","color":"red"}
execute as @a[predicate=survivalplus:tomes/dupe] at @s if entity @n[type=item,nbt={Item:{count:1,components:{"minecraft:bundle_contents":[]}}},distance=..10] run title @s actionbar {"text":"Contents will not be duplicated!","color":"red"}
#execute as @a[scores={usetome=1..},tag=dupetome] unless entity @n[type=item,nbt={Item:{count:1b}},distance=..10] run tellraw @s {"text": "Tome refunded","color": "gray","italic": true}
#execute as @a[scores={usetome=1..},tag=dupetome] unless entity @n[type=item,nbt={Item:{count:1b}},distance=..10] run give @s knowledge_book[custom_data={dupetome:tag},recipes:["survivalplus:tomes/dupe"],item_name={"text":"Duplication Tome","italic":false,"color":"light_purple"},lore=[{"text":"Duplicates the closest sparkling single item","italic":false,"color":"gray"}],enchantment_glint_override:1b]
execute at @a[tag=dupetome,scores={usetome=1..},] run function survivalplus:tools/tomes/dupe
execute as @a[scores={usetome=1..}] run scoreboard players reset @s usetome