Minecraft – clear item from player’s inventory

minecraft-commandsminecraft-java-edition

/summon Item ~ ~3 ~ {CustomName:"banana",CustomNameVisible:1,Item:{id:dye,Damage:11,Count:1,tag:{display:{Name:"banana",Lore:[Good to your body!]}}},Age:100000}

This command will drop a dye named "banana" and with Lore.

How do I use the /clear command to clear this item from a player's inventory?

Best Answer

/clear syntax:

/clear <player> [id] [Damage] [maximum amount] {dataTags}

The dataTags for /clear start directly within the tag compound, as the rest of the data (minus Count and Slot) is specified within the command's syntax already.

/clear @p minecraft:dye 11 -1 {display:{Name:"banana",Lore:[Good to your body!]}}

Your command itself is malformed. Age is a Short tag, with a range between -32768 and 32767, of which your input greatly exceeds this and will overflow to -31072. If the Age tag of an item is 6000 or higher, the item will despawn, which does not appear to be what you want to have happen.

You should not just toss in a random high value for data because it will not function as you expect it to.

If you want an item to never despawn, you can set it to -32768 which will cause it to be locked at that value.

/summon Item ~ ~3 ~ {CustomName:"banana",CustomNameVisible:1,Item:{id:"minecraft:dye",Damage:11s,Count:1b,tag:{display:{Name:"banana",Lore:["Good to your body!"]}}},Age:-32768s}