Clear item with custom name?
How do you clear 1 item from the inventory that has a custom name? What I'm trying to do is make a torch that when you hold it, it gives you Night Vision effect but after like 400 ticks or so I want the torch to run out of fuel and clear 1 torch away from the inventory, I have the potion effects (giving and taking away) working and the testfor command but how do I clear the item? this is my code I'm trying to use /clear @a torch 1 1 {display:{Name:"Special Torch"}}
Best Answer
The accepted answer is now outdated. Please read this answer if you are playing in 1.13+.
1.13+ Update
The syntax of the clear command changed in version 1.13; the NBT data is now incorporated into the item parameter, the data value has been removed, and JSON formatting has been added to the Name The updated command would now be the following:
/clear @a minecraft:torch{display:{Name:'{"text":"Special Torch"}'}} 1
You can omit the count (last parameter) to clear all items that match.
Pictures about "Clear item with custom name?"



How do you clear a named item in Minecraft?
You can clear items from a player's inventory using the /clear command in Minecraft....Clear Command in Minecraft Java Edition (PC/Mac)Using Commands in Minecraft: /clear and Custom Item Names! | 1.11.2
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Skylar Kang, Max Vakhtbovych, Brett Sayles, cottonbro
