execute if entity @s[nbt={SelectedItem:{id:"minecraft:wooden_sword",components:{"minecraft:custom_data":{necromancer_wooden_sword_upgrade:1b}}}}] run item replace entity @n[distance=..3,limit=1,tag=necromancer_summon,tag=!necromancer_summon_unwieldy] weapon.mainhand with wooden_sword
execute if entity @s[nbt={SelectedItem:{id:"minecraft:stone_sword",components:{"minecraft:custom_data":{necromancer_stone_sword_upgrade:1b}}}}] run item replace entity @n[distance=..3,limit=1,tag=necromancer_summon,tag=!necromancer_summon_unwieldy] weapon.mainhand with stone_sword
execute if entity @s[nbt={SelectedItem:{id:"minecraft:iron_sword",components:{"minecraft:custom_data":{necromancer_iron_sword_upgrade:1b}}}}] run item replace entity @n[distance=..3,limit=1,tag=necromancer_summon,tag=!necromancer_summon_unwieldy] weapon.mainhand with iron_sword
execute if entity @s[nbt={SelectedItem:{id:"minecraft:golden_sword",components:{"minecraft:custom_data":{necromancer_golden_sword_upgrade:1b}}}}] run item replace entity @n[distance=..3,limit=1,tag=necromancer_summon,tag=!necromancer_summon_unwieldy] weapon.mainhand with golden_sword
execute if entity @s[nbt={SelectedItem:{id:"minecraft:diamond_sword",components:{"minecraft:custom_data":{necromancer_diamond_sword_upgrade:1b}}}}] run item replace entity @n[distance=..3,limit=1,tag=necromancer_summon,tag=!necromancer_summon_unwieldy] weapon.mainhand with diamond_sword
execute if entity @s[nbt={SelectedItem:{id:"minecraft:netherite_sword",components:{"minecraft:custom_data":{necromancer_netherite_sword_upgrade:1b}}}}] run item replace entity @n[distance=..3,limit=1,tag=necromancer_summon,tag=!necromancer_summon_unwieldy] weapon.mainhand with netherite_sword

execute at @n[distance=..3,limit=1,tag=necromancer_summon,tag=!necromancer_summon_unwieldy] run particle crit ~ ~1 ~ 0.3 0.8 0.3 0.3 50
execute at @n[distance=..3,limit=1,tag=necromancer_summon,tag=!necromancer_summon_unwieldy] run particle end_rod ~ ~1 ~ 0.3 0.8 0.3 0.1 15

execute unless entity @n[distance=..3,limit=1,tag=necromancer_summon,tag=!necromancer_summon_unwieldy] run title @s actionbar {"color":"red", "text": "No valid summons nearby!"}
execute unless entity @n[distance=..3,limit=1,tag=necromancer_summon,tag=!necromancer_summon_unwieldy] run playsound entity.arrow.hit_player master @s ~ ~ ~ 1 0.5
execute if entity @s[nbt={SelectedItem:{id:"minecraft:wooden_sword",components:{"minecraft:custom_data":{necromancer_wooden_sword_upgrade:1b}}}}] unless entity @n[distance=..3,limit=1,tag=necromancer_summon] run give @s minecraft:wooden_sword[minecraft:custom_name='{"italic":false,"text":"[ Wooden Sword Upgrade ]"}',minecraft:lore=['{"color":"gray","italic":false,"text":"[","extra":[{"color":"dark_green","bold":false,"italic":false,"keybind":"key.use"},{"color":"gray","italic":false,"text":"] on a summon to equip it with a wooden sword."}]}','{"text":""}','{"color":"#d79e2b","italic":false,"text":"[ STAT ] ","extra":[{"color":"gray","bold":false,"italic":false,"text":"+8 Attack Damage"}]}','{"text":""}','{"color":"gray","italic":false,"text":"This replaces whatever item it had on hand."}'],minecraft:rarity=common,minecraft:enchantment_glint_override=true,minecraft:custom_data={necromancer_wooden_sword_upgrade:1b,necromancer_sword_upgrade:1b},minecraft:consumable={consume_seconds:0,animation:none,sound:"minecraft:entity.villager.work_toolsmith",has_consume_particles:false}] 1
execute if entity @s[nbt={SelectedItem:{id:"minecraft:stone_sword",components:{"minecraft:custom_data":{necromancer_stone_sword_upgrade:1b}}}}] unless entity @n[distance=..3,limit=1,tag=necromancer_summon] run give @s minecraft:stone_sword[minecraft:custom_name='{"italic":false,"text":"[ Stone Sword Upgrade ]"}',minecraft:lore=['{"color":"gray","italic":false,"text":"[","extra":[{"color":"dark_green","bold":false,"italic":false,"keybind":"key.use"},{"color":"gray","italic":false,"text":"] on a summon to equip it with a stone sword."}]}','{"text":""}','{"color":"#d79e2b","italic":false,"text":"[ STAT ] ","extra":[{"color":"gray","bold":false,"italic":false,"text":"+8 Attack Damage"}]}','{"text":""}','{"color":"gray","italic":false,"text":"This replaces whatever item it had on hand."}'],minecraft:rarity=common,minecraft:enchantment_glint_override=true,minecraft:custom_data={necromancer_stone_sword_upgrade:1b,necromancer_sword_upgrade:1b},minecraft:consumable={consume_seconds:0,animation:none,sound:"minecraft:entity.villager.work_toolsmith",has_consume_particles:false}] 1
execute if entity @s[nbt={SelectedItem:{id:"minecraft:iron_sword",components:{"minecraft:custom_data":{necromancer_iron_sword_upgrade:1b}}}}] unless entity @n[distance=..3,limit=1,tag=necromancer_summon] run give @s minecraft:iron_sword[minecraft:custom_name='{"italic":false,"text":"[ Iron Sword Upgrade ]"}',minecraft:lore=['{"color":"gray","italic":false,"text":"[","extra":[{"color":"dark_green","bold":false,"italic":false,"keybind":"key.use"},{"color":"gray","italic":false,"text":"] on a summon to equip it with an iron sword."}]}','{"text":""}','{"color":"#d79e2b","italic":false,"text":"[ STAT ] ","extra":[{"color":"gray","bold":false,"italic":false,"text":"+8 Attack Damage"}]}','{"text":""}','{"color":"gray","italic":false,"text":"This replaces whatever item it had on hand."}'],minecraft:rarity=uncommon,minecraft:enchantment_glint_override=true,minecraft:custom_data={necromancer_iron_sword_upgrade:1b,necromancer_sword_upgrade:1b},minecraft:consumable={consume_seconds:0,animation:none,sound:"minecraft:entity.villager.work_toolsmith",has_consume_particles:false}] 1
execute if entity @s[nbt={SelectedItem:{id:"minecraft:golden_sword",components:{"minecraft:custom_data":{necromancer_golden_sword_upgrade:1b}}}}] unless entity @n[distance=..3,limit=1,tag=necromancer_summon] run give @s minecraft:golden_sword[minecraft:custom_name='{"italic":false,"text":"[ Golden Sword Upgrade ]"}',minecraft:lore=['{"color":"gray","italic":false,"text":"[","extra":[{"color":"dark_green","bold":false,"italic":false,"keybind":"key.use"},{"color":"gray","italic":false,"text":"] on a summon to equip it with a golden sword."}]}','{"text":""}','{"color":"#d79e2b","italic":false,"text":"[ STAT ] ","extra":[{"color":"gray","bold":false,"italic":false,"text":"+8 Attack Damage"}]}','{"text":""}','{"color":"gray","italic":false,"text":"This replaces whatever item it had on hand."}'],minecraft:rarity=uncommon,minecraft:enchantment_glint_override=true,minecraft:custom_data={necromancer_golden_sword_upgrade:1b,necromancer_sword_upgrade:1b},minecraft:consumable={consume_seconds:0,animation:none,sound:"minecraft:entity.villager.work_toolsmith",has_consume_particles:false}] 1
execute if entity @s[nbt={SelectedItem:{id:"minecraft:diamond_sword",components:{"minecraft:custom_data":{necromancer_diamond_sword_upgrade:1b}}}}] unless entity @n[distance=..3,limit=1,tag=necromancer_summon] run give @s minecraft:diamond_sword[minecraft:custom_name='{"italic":false,"text":"[ Diamond Sword Upgrade ]"}',minecraft:lore=['{"color":"gray","italic":false,"text":"[","extra":[{"color":"dark_green","bold":false,"italic":false,"keybind":"key.use"},{"color":"gray","italic":false,"text":"] on a summon to equip it with a diamond sword."}]}','{"text":""}','{"color":"#d79e2b","italic":false,"text":"[ STAT ] ","extra":[{"color":"gray","bold":false,"italic":false,"text":"+8 Attack Damage"}]}','{"text":""}','{"color":"gray","italic":false,"text":"This replaces whatever item it had on hand."}'],minecraft:rarity=rare,minecraft:enchantment_glint_override=true,minecraft:custom_data={necromancer_diamond_sword_upgrade:1b,necromancer_sword_upgrade:1b},minecraft:consumable={consume_seconds:0,animation:none,sound:"minecraft:entity.villager.work_toolsmith",has_consume_particles:false}] 1
execute if entity @s[nbt={SelectedItem:{id:"minecraft:netherite_sword",components:{"minecraft:custom_data":{necromancer_netherite_sword_upgrade:1b}}}}] unless entity @n[distance=..3,limit=1,tag=necromancer_summon] run give @s minecraft:netherite_sword[minecraft:custom_name='{"italic":false,"text":"[ Netherite Sword Upgrade ]"}',minecraft:lore=['{"color":"gray","italic":false,"text":"[","extra":[{"color":"dark_green","bold":false,"italic":false,"keybind":"key.use"},{"color":"gray","italic":false,"text":"] on a summon to equip it with a netherite sword."}]}','{"text":""}','{"color":"#d79e2b","italic":false,"text":"[ STAT ] ","extra":[{"color":"gray","bold":false,"italic":false,"text":"+8 Attack Damage"}]}','{"text":""}','{"color":"gray","italic":false,"text":"This replaces whatever item it had on hand."}'],minecraft:rarity=epic,minecraft:enchantment_glint_override=true,minecraft:custom_data={necromancer_netherite_sword_upgrade:1b,necromancer_sword_upgrade:1b},minecraft:consumable={consume_seconds:0,animation:none,sound:"minecraft:entity.villager.work_toolsmith",has_consume_particles:false}] 1

advancement revoke @s only kiwi2:necromancer_upgrades_swords

