summon armor_stand ~ ~ ~ {Tags:[data],Invisible:1b}
ride @s mount @n[tag=data]
summon armor_stand ~ ~ ~ {Marker:1b,Invisible:1b,Tags:[spawn_egg]}
loot replace entity @n[tag=spawn_egg] weapon.mainhand loot survivalplus:ngtools/capturebag_full

data modify entity @n[tag=spawn_egg] equipment.mainhand.components."minecraft:custom_name" set from entity @n[tag=capturename] text
data modify entity @n[tag=spawn_egg] equipment.mainhand.components."minecraft:entity_data".data."capture" set from entity @n[tag=data] Passengers[0]
data remove entity @n[tag=spawn_egg] equipment.mainhand.components."minecraft:entity_data".data."capture".Pos
execute if entity @n[tag=capturename,nbt={billboard:"center"},distance=..1] run data modify entity @n[tag=spawn_egg] equipment.mainhand.components."minecraft:entity_data".data."capture".CustomName set from entity @n[tag=capturename] CustomName
execute if entity @n[tag=capturename,nbt={billboard:"fixed"},distance=..1] run data remove entity @n[tag=spawn_egg] equipment.mainhand.components."minecraft:entity_data".data."capture".CustomName

#replace creative item
execute if data entity @p SelectedItem.components."minecraft:custom_data".capturedevice run item replace entity @p[gamemode=creative,advancements={survivalplus:tools/titan/capture=true}] weapon.mainhand from entity @n[tag=spawn_egg] weapon.mainhand
execute if data entity @p equipment.offhand.components."minecraft:custom_data".capturedevice unless data entity @p SelectedItem.components."minecraft:custom_data".capturedevice run item replace entity @p[advancements={survivalplus:tools/titan/capture=true}] weapon.offhand from entity @n[tag=spawn_egg] weapon.mainhand

#drop and copy captured item
execute at @p[advancements={survivalplus:tools/titan/capture=true},gamemode=!creative] run summon item ~ ~ ~ {Tags:[makemecapture],Item:{id:"minecraft:skeleton_spawn_egg",components:{}}}
data modify entity @n[tag=makemecapture] Item.components set from entity @n[tag=spawn_egg] equipment.mainhand.components

kill @e[tag=data]
kill @e[tag=spawn_egg]
function survivalplus:mobs/vanish