tellraw @a[tag=K] ["",{"text":"A random event has occured!","color":"yellow","italic":true}]
tellraw @a[tag=K] ["",{"text":"Copycat!","color":"gold","italic":true}]

tag @e[tag=K,type=minecraft:husk] add CopyKyu
tag @e[tag=K,type=minecraft:zombie] add CopyKyu
tag @e[tag=K,type=minecraft:skeleton] add CopyKyu
tag @e[tag=K,type=minecraft:stray] add CopyKyu
tag @e[tag=K,type=minecraft:zombified_piglin] add CopyKyu
tag @e[tag=K,type=minecraft:wither_skeleton] add CopyKyu
execute at @e[tag=CopyKyu] run execute as @p[tag=K] run execute positioned ~ ~ ~ run loot spawn ~ ~ ~ loot minecraft:randomevents/player
execute as @e[tag=CopyKyu] run execute at @s run data modify entity @s ArmorItems[3] set from entity @e[type=item,sort=nearest,limit=1,nbt={Item:{id:"minecraft:player_head"}}] Item
execute as @e[tag=CopyKyu] run execute at @s run data modify entity @s ArmorItems[2] set from entity @p[tag=K] Inventory[{Slot:102b}]
execute as @e[tag=CopyKyu] run execute at @s run data modify entity @s ArmorItems[1] set from entity @p[tag=K] Inventory[{Slot:101b}]
execute as @e[tag=CopyKyu] run execute at @s run data modify entity @s ArmorItems[0] set from entity @p[tag=K] Inventory[{Slot:100b}]
execute as @e[tag=CopyKyu] run execute at @s run data modify entity @s HandItems[1] set from entity @p[tag=K] Inventory[{Slot:-106b}]
execute as @e[tag=CopyKyu] run data merge entity @s {PersistenceRequired:1b,HandDropChances:[0.085F,0.000F],ArmorDropChances:[0.00F,0.000F,0.00F,0.00F]}
execute at @e[tag=CopyKyu] run kill @e[distance=..5,type=item,sort=nearest,limit=1,nbt={Item:{id:"minecraft:player_head"}}]
tag @e[tag=CopyKyu] add RemovePersist