Store an item in storage [duplicate]
You can copy the entire SelectedItem
tag to the Item
tag of the item entity:
/data modify entity @e[type=item,limit=1] Item set from entity @s SelectedItem
The existing item can be anything, it gets overwritten anything. Example summoning command:
/summon item ~ ~ ~ {Item:{id:"stone",Count:1}}
Just /summon item
does not work, because it would be a stack of air with size 0.
More information about /data modify
is in my other answer.