I have a Redstone Power loop that connects to a Command Block that is set to kill all entities except for myself (/kill @e[type=!Player]), because I'm building a creative map, but don't want slimes all over the place. Problem is if I want to place an Item Frame than the Command Block kills it.

So, is there anyway to exclude items from getting deleted, or make it so it will only target mobs?

  • @Unionhawk How do I use that for killing mobs though? – KernelPanic Mar 2 '15 at 3:14
  • @Unionhawk I'm not seeing how that is supposed to kill entities. As far as I can tell that only selects players, and nothing else... – KernelPanic Mar 2 '15 at 3:16
  • You'd use that selector you have set up (select whatever entities you want to exclude) in the context of a /kill command, so /kill @e[score_selectMe_min=1]. – Unionhawk Mar 2 '15 at 3:17
  • @Unionhawk That doesn't seem to do what I want it to do. I can't do [code]/kill @e[!Player, !ItemFrame][/code]. I'm not even sure what that Score thing the other guy is talking about is meant to do. – KernelPanic Mar 2 '15 at 3:20
  • @Unionhawk Yes, but I don't even understand what the code is doing, or how I'm supposed to apply it to what I want to do. Reading =/= understanding. – KernelPanic Mar 2 '15 at 3:21

The simplest way to handle this is with a gamerule. If you don't want any mobs bothering you in your creative world, just turn off spawns with /gamerule doMobSpawning false. No mobs will spawn, which will allow you to have a quiet creative world, free from cows, pigs, sheep, chickens, slimes, etc, while also allowing yourself to do science on mobs at will. Mobs will spawn only when you want them to.

If you're really committed to the idea of doing this with /kill, however, you can do this one of two ways. You can set up individual command blocks to kill each type of mob, which might be a small set of command blocks if your main problem is slimes.

Alternatively, you can use the methods described in this answer to select exceptions. It uses a scoreboard to set a score for all entities to 1, and simultaneously sets the score of all exceptions to 0. From there, you can select the set of all mobs excluding any exceptions you want with @e[score_select_min=1].

The simplest and most flexible way to keep slimes from bothering you though is to turn off mob spawning altogether.

  • Does the /gamerule doMobSpawning false persist when reloading the save? – KernelPanic Mar 2 '15 at 3:44
  • 2
    @KernelPanic Yes, gamerules are stored in level.dat. – Unionhawk Mar 2 '15 at 3:45
  • claps Since when did you start typing this ;-; – 54D Mar 2 '15 at 3:47

All you have to do is /kill @e[type=YourMob]

If you want to kill all mobs except yourself do:

1.12: /kill @e[type=!Player]

1.13: /kill @e[type=!minecraft:player]

  • /kill @e[type=Creeper] worked for me, thanks – Maslow Jan 25 '16 at 0:49
  • @TechnikEmpire what did he lose? – Elliot A. Jun 14 '16 at 10:51
  • @ElliotA. Somehow, every block he placed himself and every mob he placed. – user8381 Jun 14 '16 at 11:58
  • Careful with this command,the type=!Player version deleted all blocks and mobs manually placed by users. I think it was forge 1.7.10 that this happened in. – user8381 Jun 14 '16 at 12:56
  • OH!!! All mobs = all player placed mobs also. As for blocks most modded blocks are also entities and would get killed. – Elliot A. Jun 16 '16 at 21:49

I have a similar problem in my world - how I resolved it was hooking up several command blocks to a hopper clock:

enter image description here

Each command block contains a command to kill a certain enemy type:

/kill @e[type=Slime,r=60]

I only need to worry about zombies, zombie villagers, creepers, skeletons, endermen, spiders, and witches; so I only have 7 command blocks hooked up here. You're welcome to hook up as many more as you see fit.


You can do /kill @e[type=Slime] And you can do /gamerule doMobLoot false so they wont drop anything

protected by Community Jul 26 '15 at 22:10

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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