How can I delete just one type of entity from the ground? I am only killing creepers using the /kill @e[type=creeper] command in a repeating command block, but it litters the ground with gunpowder. I want to delete only gunpowder from the ground but not any other ground item. Ideas?
I'm using Minecraft 1.12.2.
12 Answers
This can be done by using scoreboard tags. You can tag the items that have the specific NBT you want to select and then kill all entities with that tag.
This will use two command blocks in a chain.
Tag the items with a Repeat Unconditional Always active command block with command:
scoreboard players tag @e[type=Item] add Items {Item:{id:"minecraft:gunpowder"}}Kill the items with a Chain Conditional Always active command block with command:
/kill @e[tag=Items] Here's a simpler version. It takes a few ticks but it doesn't bear any side effects like /kill has.
/tp @e[type=Creeper] ~ -1 ~
Credit to sumurai8's post for mentioning this brilliant idea.