6

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?

10

In 1.13 and above, this can be done with the following command:

/kill @e[type=item,nbt=!{Item:{id:"minecraft:blue_banner"}}]

The following solution is for version 1.8:

First, create a dummy scoreboard objective:

/scoreboard objectives add ItemToRemove dummy

Whenever you want to clean up the dropped items, run these commands in this order:

/scoreboard players set @e[type=Item] ItemToRemove 1
/scoreboard players set @e[type=Item,x=40,y=1,z=40,dx=40,dy=27,dz=80] ItemToRemove 0 {Item:{id:"minecraft:banner",Damage:4s}}
/kill @e[score_ItemToRemove_min=1]

What this does is set all item's ItemToRemove score to 1, sets the banner's ItemToRemove score back to 0, then kills everything with a minimum of 1 ItemToRemove score.

  • 1
    I wish I could upvote this twice. – Albert Bori Nov 27 '14 at 20:13
  • I'll do it for you. XD – Xandawesome Jun 17 '15 at 17:13
5

Starting with Minecraft 1.9, you can use a scoreboard tag to mark the flag rather than a dummy objective as outlined in colorfusion's answer.

/scoreboard players tag @e[type=Item,tag=!isFlag] add isFlag {Item:{id:"minecraft:banner",Damage:4s}}
/kill @e[type=Item,tag=!isFlag]

This has three benefits:

  1. You don't need to set up an objective.
  2. Note how there is no command to tag every item. This is because tags are initialized as an empty list by default, meaning tag=!isFlag works on entities by default. This is unlike scoreboard objectives, which are initialized to Null/None, which fails all comparisons with numbers (for the purpose of target selector arguments), e.g. (Null>=0)==False, (Null<0)==False.
  3. As a result of 2, we can make it so every flag is only tagged once, rather than once per tick.
0

Try:

/kill @e[type=Item,name=!Flag]

Alternatively, you can have it check for the dropped flag (remove the !) and then send the result through a NOT gate to a command block that runs:

/kill @e[type=Item]
-1

do /kill @e[type=Item] then run the command that will spawn the flag :o

-1

I had the same problem with my PVP game, a 'dogtag' gamemode (like from Call of Duty). We have to deliver a specific dropped item from a dead player to earn a point and before I knew it I had the whole map covered with weapons, armor and more which annoyed me.

To solve this, I made a plugin for a Bukkit server. What it does is:

  • Deletes all the items when someone dies
  • Drops 32 arrows
  • Drops 1 nametag
  • Drops 1XP

The drops can be set manually to which item you would like to drop (or just nothing)

I have no idea if this plugin will work without a Bukkit server.

  • 2
    You should provide a link to the plugin you made. Without even a name, it's not too helpful to mention a plugin like this. – Vemonus Nov 27 '16 at 0:37
  • Please provide the name & link to the plugin, or go through how you implemented it, because this answer is next to useless without one of those things. – Robotnik Nov 27 '16 at 4:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.