execute on origin run advancement grant @s only survivalplus:adventure/merchant/reforgekey
data remove entity @s Item.components."minecraft:attribute_modifiers".[{id:"minecraft:1111"}]
data remove entity @s Item.components."minecraft:attribute_modifiers".[{id:"minecraft:2222"}]
data remove entity @s Item.components."minecraft:attribute_modifiers".[{id:"minecraft:3333"}]
data remove entity @s Item.components."minecraft:attribute_modifiers".[{id:"minecraft:4444"}]
data remove entity @s Item.components."minecraft:attribute_modifiers".[{id:"minecraft:5555"}]

execute store result score random itemcount run random value 1..10
execute if score random itemcount matches 1 run function survivalplus:tools/reforge/add/armor
execute if score random itemcount matches 2 run function survivalplus:tools/reforge/add/atkspd
execute if score random itemcount matches 3 run function survivalplus:tools/reforge/add/blockrange
execute if score random itemcount matches 4 run function survivalplus:tools/reforge/add/damage
execute if score random itemcount matches 5 run function survivalplus:tools/reforge/add/entityrange
execute if score random itemcount matches 6 run function survivalplus:tools/reforge/add/health
execute if score random itemcount matches 7 run function survivalplus:tools/reforge/add/knockback
execute if score random itemcount matches 8 run function survivalplus:tools/reforge/add/luck
execute if score random itemcount matches 9 run function survivalplus:tools/reforge/add/mining
execute if score random itemcount matches 10 run function survivalplus:tools/reforge/add/speed

execute positioned ~ ~-.2 ~ run function survivalplus:tools/upgrade_effect_small
data modify entity @s PickupDelay set value 0s
tag @s remove reforging