I want to create an item which you cannot get rid of, so if you throw it on the ground that item (snowball) will be deleted. But I don't want to kill all items using /kill @e[type=Item], I just want to kill just the snowball. Can anyone help?
5 Answers
You will have to use scoreboards for this:
Setup a dummy scoreboard (ex.
/scoreboard objectives add Sample_OBJ dummy)Add this command to at the most a 4 tick clock (hopper or fill clock will do):
/scoreboard players set @e[type=Item] Sample_OBJ 1 {Item:{id:minecraft:wool}}Add Another command block that needs To be on a clock:
/kill @e[type=Item,score_Sample_OBJ_min=1]
You need a scoreboard because you can't put NBT in selectors/there is no ID tag in item selectors.
Here is a solution that uses scoreboard tags. It will tag any item matching the exact criteria which could include custom names, lore, enchantments, any NBT information. This tag can then be used to target only those items to be killed. In my example, a snowball named Test will be the only item that gets killed. You can throw out unnamed snowballs and they will be safe.
You need two command blocks in a chain.
The first command block is RepeatUnconditionalAlways Active and it's command is:
scoreboard players tag @e[type=Item] add KillItem {Item:{id:"minecraft:snowball",tag:{display:{Name:Test}}}} The second command block is ChainUnconditionalAlways Active and it's command is:
kill @e[tag=KillItem] To destroy a certain item, rename it and use
/kill @e[type=Item, name={item name here}]That should do the trick. You could also look up a way to destroy all of one item.
3/kill @e[Type=Item.{Item or Block}.{Item}]
Example : /kill @e[Type=Item.Item.leather]
In version 1.11.2, data tags were added to /kill!
/kill @e[type=Item] {Item:{id:minecraft:wool}} 1