I've got a capture the flag arena. One issue we keep running into during play, is that of clutter.
We have /gamerule keepInventory false
, so the pitch gets rather cluttered with armor, weapons and building materials, such that it becomes difficult to pick the flag up, due to full inventories.
I've discovered the following command to remove all drops from the arena:
/kill @e[type=Item]
However, this removes all the floating items from the ground. I'd like, if possible, to preserve the flag from being destroyed.
I have this command for detecting the flag:
/testfor @e[type=Item,x=40,y=1,z=40,dx=40,dy=27,dz=80] {Item:{id:"minecraft:banner",Damage:4s}}
But I'm not sure how to combine the two in a way that it will destroy everything except for the flag.
Any ideas?
Best Answer
In 1.13 and above, this can be done with the following command:
The following solution is for version 1.8:
First, create a dummy scoreboard objective:
Whenever you want to clean up the dropped items, run these commands in this order:
What this does is set all item's
ItemToRemove
score to 1, sets the banner'sItemToRemove
score back to 0, then kills everything with a minimum of 1ItemToRemove
score.