Minecraft – Clear item player holding with mouse

minecraft-commandsminecraft-java-edition

If you open your inventory and then hold an item, for example a diamond, with your mouse (when you want to move the item in your inventory you can grab it with your mouse to move it)…

If you do /clear @a while a player is holding an item with their mouse, the item the player is holding doesn't get removed. I also tried to do /kill @e[type=minecraft:item] but the item still doesn't get removed.

Is removing the item even possible?

I'm playing in 1.16 (snapshot 20w22a)

Best Answer

The reason why /clear doesn't work in your tests is because you're in Creative Mode. /clear only affects the grabbed item in GUIs if the user is in Survival or Adventure Mode.

Try switching to Survival mode before attempting /clear using a command block.

If you need to get it done to players in Creative, you're out of luck. Sorry.