I'm trying to remove a specific, named, item if it is dropped on the floor. I have the following on my command block:

kill @e[type=Item] {Item:{tag:{display:{Name:"RedFlag"}}}

But it's removing all items, not just the one I want. What am I doing wrong?

I also tried

kill @e[type=Item] {Item:{id:"red_flower",Damage:2}}

But that didn't work either, it's still removing all items, even things that aren't red flowers!

  • I'm trying to come up with a way of doing this in my head, and the only thing I can think of is 1) give the items a custom name or 2) give the item a score. Can item entities even have a score though? – MBraedley Dec 20 '14 at 13:46
  • @MBraedley I've given them a custom name, but that requires all the {tag stuff} – fredley Dec 20 '14 at 13:57
  • You should be able to use e[name=<name>]. At least I think you can do that. – MBraedley Dec 20 '14 at 13:58

The /kill command does not support killing objects (not yet anyway) who fit through a NBT citeria. Only identifiers with the @e command will be considered.

When you entered:

kill @e[type=Item] {Item:{tag:{display:{Name:"RedFlag"}}}
kill @e[type=Item] {Item:{id:"red_flower",Damage:2}}

It is considered as:

kill @e[type=Item]
kill @e[type=Item]

Regardless of how much NBT data an object has, it'll always kill all the entities of the type specified.

This means that /kill @e[type=Sheep] {CustomName:"Sheep"} will kill all sheep(s) in the world. Even if they have/don't have the custom name "Sheep", or a completely different name altogether.
Think about all the sheeps! (Those loaded in anyway)

| improve this answer | |
  • 1
    According to the wiki, you're correct. – MBraedley Dec 20 '14 at 13:38
  • Nope. I've tested it. It doesn't take that long to type (and use): /summon Sheep ~ ~ ~ {CustomName:"No. 1"}, /summon Sheep ~ ~ ~ {CustomName:"No. 2"} and /kill @e[type=Sheep] {CustomName:"No. 1"}. – aytimothy Dec 20 '14 at 13:38
  • 1
    Shucks. I guess I'll have to do it a different way! – fredley Dec 20 '14 at 14:32
  • You could always use an item dropper system to identify the items (though putting them back where they were will be a problem). – aytimothy Dec 20 '14 at 14:49
  • 1
    @fredley Use scoreboard command to match NBT and then do kill @e[score_name=X,score_name_min=X] – Q20 Dec 20 '14 at 21:04

Maybe you can do it by using the new /execute command;

  1. Give the item you want to remove a scoreboard objective: /scoreboard objectives add RedFlag dummy RedFlag
  2. Set the score for the item to 1: /scoreboard players set @e[type=Item,r=5] RedFlag 1
  3. Than use this command: /execute @e[score_RedFlag=1,score_RedFlag_min=1,type=Item] ~ ~ ~ kill @e[r=0,type=Item]

Maybe if you use this it will work.

| improve this answer | |
  • So what you're saying is that you haven't tested this for yourself? Before you give an answer, you should test it to see if it actually works. – MBraedley Mar 22 '15 at 13:53

Very few data tags can be used to select entities, and the format you are trying is not how it works. Try:

/entitydata @e[type=Item,c=1] {CustomName:"killitem"}

and then


The selector c=1 in the first command could be changed to match the amount of items you want to name.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.