How to remove all items of a specific type on the server

My goal is to remove all existing Elytras from our server (only on the overworld, but not much of a problem otherwise, since we can just respawn the end).

I read about the command /kill @e[type=Item] on reddit. It did not work for me somehow. I tried it using: /kill @e[type=elytra] and got the message "Selector '@e[type=minecraft:elytra]' found nothing. Entity type type 'minecraft:elytra' is invalid". I took one out of the chest, threw it on the ground, but I get the same message.

The entity type cannot be invalid IMHO, since /give <playername> elytra works.


Solution 1:

Commands can't target entities in unloaded chunks, and are generally bad at editing the contents of containers. To do what you want to do, you will need to use an external tool.

Here's how to do it with MCEdit Unified:

  1. Double click on any chest containing an elytra to bring up the chest GUI:

MCedit Chest GUI

  1. Select the elytra in the item list
  2. Press Delete All Instances Of This Item From World
  3. You'll get a warning message telling you what you're about to do, to which you should press OK

Warning message

  1. After it's done deleting the item (may take a while) save and exit.

This should only affect the current dimension you're in on MCEdit, so you will not need to regenerate the end.

Solution 2:

An item is always @e[type=item], whether its a stone block or a sapling or a bone or an elytra.
to achieve what you're trying to do, you'd have to tag all items that actually are elyras and kill those.

/scoreboard players tag @e[type=item] add isElytra {Item:{id:"minecraft:elytra",Count:1b}}
/kill @e[type=item,tag=isElytra]

the problem with this is though, that it will only kill all items that are lying around, not in chests or player inventorys, and only in loaded chunks, so not everywhere on the server. if that is a problem for you, you should try the solution of @SirBenet