How to copy item NBT into an item entity?

Version 1.14.4:
I am trying to make a commands system that forces a player to drop whatever item is in their main hand. Because I can't use commands to make a player press Q and drop the original item, I need to copy the NBT into a new item on the ground and remove the old one from the player. I obviously want any NBT, including enchantments, names, lore, etc. to be copied over exactly.

I know that I can use /data to get the NBT from the SelectedItem of a player, and execute store can put NBT into an entity. However, /data get only returns numeric data, and execute store only allows me to set one NBT path at a time, so my plan of summoning a generic item on the ground and then just copying the NBT over (including the item ID) does not work.

Am I going about this wrong and there is a way to do this, or is this just impossible? My eventual plan is to implement this into a datapack, so if a method requires moving items into tile entities or something similar involving setting aside a space to spawn blocks in I'd rather avoid that. Of course, if you know a method like that by all means put it as an answer because someone else with the same question may find it useful for their situation.


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.