How to kill all Items except for ones that players drop [duplicate]
You can simply teleport all hostile mobs in a certain radius 256 blocks down. May they, and their drops, rest in peace in the void below the world.
The DeathLootTable
string tag can modify which loot table the mob will use when killed. The "empty" loot table will cause it to drop nothing:
1.12 and lower:
/entitydata @e[type=Zombie,r=40] {DeathLootTable:"minecraft:empty"}
1.13:
/execute as @e[type=zombie,distance=..40] run data merge entity @s {DeathLootTable:"minecraft:empty"}
You should teleport the entity into the void. That will drop the items, but in the void too.
/tp @e[selector] ~ -100000 ~
This will take a few gameticks to kill the mob, but with the amount of natural spawns, this does not matter.
I have a not so compact idea, but it will fit for your needs:
-
First you will need to give a score for each item you don't need to be on ground. I added the r selector, the number depending of your spawn radius
/scoreboard objectives add trash dummy - Add the scoreboard
Now these command in a clock / repeating command block:
/scoreboard players set @e[type=Item,r=50] trash 1 {Item:{id:"minecraft:bone"}}
/scoreboard players set @e[type=Item,r=50] trash 2 {Item:{id:"minecraft:rotten_flesh"}}
Explanation : Each type of item will have their own number in the scoreboard to diffetentiate them later. I wrote only some examples above. You can continue the list
-
Now that all your "trash" has their own "recognize ID" just simply run this command in a repeating command block.
/kill @e[score_trash_min=1,score_trash=#]
Explanation : Where I put the # mark , you need to put the maximum number of item you put on your "kill list". So I pretend I choose 6 type of items to be erased, so I will put put 6 instead of #.