How can I delete all items but one in a players inventory?

How can I delete all items but one in a players inventory? - A Person Buying From a Grocery

I'm trying to make a map where a player has a diamond chestplate named "Heros Chestplate" and I was wondering if there is a command out there that deletes all items in a player's inventory but that item? I'm currently in 1.8.8 and I'm using the command /clear @a !minecraft:diamond_chestplate 1 0 {display:{Name:"Hero's Chestplate"},ench:[{id:34,lvl:150}]}



Best Answer

The only thing you could do is clear the player's inventory and give them a new hero chestplate

/clear @a
/give @a minecraft:diamond_chestplate 1 0 {display:{Name:"Hero's Chestplate"},ench:[{id:34,lvl:150}]}



Pictures about "How can I delete all items but one in a players inventory?"

How can I delete all items but one in a players inventory? - Man Standing on Stair Case Looking Up
How can I delete all items but one in a players inventory? - Brown and Black Clothes Hanged on Clothes Hanger
How can I delete all items but one in a players inventory? - First Aid and Surival Kits



How do you quickly delete items in Minecraft?

One of the most popular and fastest ways to clear items is the kill command. First, type /kill @e[type=item] in the chat and press enter to remove all dropped items in your Minecraft world instantly.

What is the command to clear someones inventory in Minecraft?

You can use the command /clear [targets] [item] [maxCount] , where: targets is optional. It is the name of the player (or a target selector) whose inventory you wish to clear. If no player is specified, it will default to the player running the command.



Minecraft 1.16.5: How to remove certain items from a players inventory




Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

Images: Julia Avamotive, Kaique Rocha, Ron Lach, Roger Brown