execute unless entity @n[distance=..3,tag=necromancer_summon] run title @s actionbar {"color":"red", "text": "No valid summons nearby!"}
execute unless entity @n[distance=..3,tag=necromancer_summon] run playsound entity.arrow.hit_player master @s ~ ~ ~ 1 0.5
execute unless entity @n[distance=..3,tag=necromancer_summon] run give @s minecraft:bone[minecraft:custom_name='{"italic":false,"text":"[ Soul of Ash ]"}',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 Wither Skeleton summon to evolve it into a Death Knight."}]}','{"text":""}','{"color":"gray","italic":false,"text":"Upgrades:"}','{"color":"#d79e2b","italic":false,"text":"[ STAT ] ","extra":[{"color":"red","bold":false,"italic":false,"text":"+40 Health"}]}','{"color":"#d79e2b","italic":false,"text":"[ STAT ] ","extra":[{"color":"green","bold":false,"italic":false,"text":"+25% Scale"}]}','{"color":"#d79e2b","italic":false,"text":"[ STAT ] ","extra":[{"color":"white","bold":false,"italic":false,"text":"+10 Armor"}]}','{"color":"#d79e2b","italic":false,"text":"[ STAT ] ","extra":[{"color":"white","bold":false,"italic":false,"text":"+5 Armor Toughness"}]}','{"color":"#d79e2b","italic":false,"text":"[ STAT ] ","extra":[{"color":"gray","bold":false,"italic":false,"text":"+9 Attack Damage"}]}','{"color":"#b62020","italic":false,"text":"[ ON-DEATH ] ","extra":[{"color":"gray","bold":false,"italic":false,"text":"Drop its own skull on death, allowing it to be revived by a necromancer."}]}','{"text":""}','{"color":"gray","italic":false,"text":"Existing weapons and armors will be carried over."}'],minecraft:rarity=epic,minecraft:enchantment_glint_override=true,minecraft:custom_data={necromancer_soul_of_ash:1b,necromancer_soul_upgrade:1b},minecraft:consumable={consume_seconds:0,animation:none,sound:"minecraft:block.trial_spawner.ambient_ominous",has_consume_particles:false},minecraft:item_model="minecraft:ender_eye"] 1

execute if entity @n[distance=..3,tag=wither_skeleton_evolved] run title @s actionbar {"color":"red", "text": "This summon has already evolved!"}
execute if entity @n[distance=..3,tag=wither_skeleton_evolved] run playsound entity.arrow.hit_player master @s ~ ~ ~ 1 0.5
execute if entity @n[distance=..3,tag=wither_skeleton_evolved] run give @s minecraft:bone[minecraft:custom_name='{"italic":false,"text":"[ Soul of Ash ]"}',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 Wither Skeleton summon to evolve it into a Death Knight."}]}','{"text":""}','{"color":"gray","italic":false,"text":"Upgrades:"}','{"color":"#d79e2b","italic":false,"text":"[ STAT ] ","extra":[{"color":"red","bold":false,"italic":false,"text":"+40 Health"}]}','{"color":"#d79e2b","italic":false,"text":"[ STAT ] ","extra":[{"color":"green","bold":false,"italic":false,"text":"+25% Scale"}]}','{"color":"#d79e2b","italic":false,"text":"[ STAT ] ","extra":[{"color":"white","bold":false,"italic":false,"text":"+10 Armor"}]}','{"color":"#d79e2b","italic":false,"text":"[ STAT ] ","extra":[{"color":"white","bold":false,"italic":false,"text":"+5 Armor Toughness"}]}','{"color":"#d79e2b","italic":false,"text":"[ STAT ] ","extra":[{"color":"gray","bold":false,"italic":false,"text":"+9 Attack Damage"}]}','{"color":"#b62020","italic":false,"text":"[ ON-DEATH ] ","extra":[{"color":"gray","bold":false,"italic":false,"text":"Drop its own skull on death, allowing it to be revived by a necromancer."}]}','{"text":""}','{"color":"gray","italic":false,"text":"Existing weapons and armors will be carried over."}'],minecraft:rarity=epic,minecraft:enchantment_glint_override=true,minecraft:custom_data={necromancer_soul_of_ash:1b,necromancer_soul_upgrade:1b},minecraft:consumable={consume_seconds:0,animation:none,sound:"minecraft:block.trial_spawner.ambient_ominous",has_consume_particles:false},minecraft:item_model="minecraft:ender_eye"] 1

tag @n[distance=..3,limit=1,type=wither_skeleton,tag=wither_skeleton,tag=!wither_skeleton_evolved] add death_knight
attribute @n[distance=..3,limit=1,tag=death_knight,tag=!wither_skeleton_evolved] max_health modifier add necromancer_death_knight_max_health 40 add_value
attribute @n[distance=..3,limit=1,tag=death_knight,tag=!wither_skeleton_evolved] armor modifier add necromancer_death_knight_armor 10 add_value
attribute @n[distance=..3,limit=1,tag=death_knight,tag=!wither_skeleton_evolved] armor_toughness modifier add necromancer_death_knight_armor_toughness 5 add_value
attribute @n[distance=..3,limit=1,tag=death_knight,tag=!wither_skeleton_evolved] scale modifier add necromancer_death_knight_scale 0.25 add_multiplied_total
attribute @n[distance=..3,limit=1,tag=death_knight,tag=!wither_skeleton_evolved] attack_damage modifier add necromancer_death_knight_attack_damage 9 add_value
effect give @n[distance=..3,limit=1,tag=death_knight,tag=!wither_skeleton_evolved] instant_damage 3 25 true
data merge entity @n[distance=..3,limit=1,tag=death_knight,tag=!wither_skeleton_evolved] {CustomName:'{"text":"[ Death Knight ]"}'}
data merge entity @n[distance=..3,limit=1,tag=death_knight,tag=!wither_skeleton_evolved] {DeathLootTable:"kiwi2:entities/custom_mob_items/death_knight"}
execute as @n[distance=..3,limit=1,tag=death_knight,tag=!wither_skeleton_evolved] at @s run particle minecraft:large_smoke ~ ~ ~ 2.5 1 2.5 0 75
execute as @n[distance=..3,limit=1,tag=death_knight,tag=!wither_skeleton_evolved] at @s run particle minecraft:explosion ~ ~ ~ 2.5 1 2.5 1 35
execute as @n[distance=..3,limit=1,tag=death_knight,tag=!wither_skeleton_evolved] at @s run particle minecraft:sculk_soul ~ ~1 ~ 0.5 0.8 0.5 0.2 40
execute as @n[distance=..3,limit=1,tag=death_knight,tag=!wither_skeleton_evolved] at @s run effect give @a[distance=..12] darkness 2 1 true
execute as @n[distance=..3,limit=1,tag=death_knight,tag=!wither_skeleton_evolved] at @s run playsound minecraft:block.trial_spawner.ambient_ominous master @a[distance=..64] ~ ~ ~ 10 0
execute as @n[distance=..3,limit=1,tag=death_knight,tag=!wither_skeleton_evolved] at @s run playsound minecraft:entity.ravager.stunned master @a[distance=..64] ~ ~ ~ 10 0
execute as @n[distance=..3,limit=1,tag=death_knight,tag=!wither_skeleton_evolved] at @s run playsound minecraft:entity.skeleton_horse.death master @a[distance=..64] ~ ~ ~ 10 0
tag @n[distance=..3,limit=1,type=wither_skeleton,tag=death_knight] add wither_skeleton_evolved
