What is the command to kill all mobs?

What is the command to kill all mobs? - Unrecognizable woman holding paw of dog

I'm building a mini-game on a flat world and slimes are spawning on it. They keep setting off TNT and other traps, forcing me to rebuild every time.

What is a command that I can use to kill all mobs?



Best Answer

Set the difficulty to peaceful in the options menu




Pictures about "What is the command to kill all mobs?"

What is the command to kill all mobs? - Crop hacker silhouette typing on computer keyboard while hacking system
What is the command to kill all mobs? - Top view of slogan Stop Killing Us on surface of square blackboard on black background
What is the command to kill all mobs? - Side view of young woman in hoodie sitting on floor near sofa and playing with obedient brown Labrador while resting during free time





Kill Command Explained




More answers regarding what is the command to kill all mobs?

Answer 2

Type and enter /gamerule doMobSpawning false

Answer 3

If you're willing to start a new superflat world, you can create custom superflat terrain that doesn't consist of 4 layers. The reason why slimes spawn so often in superflat worlds is because you're actually really close to the void.

If you generate a new superflat world that starts at Y level 64, you won't have any slimes spawn.

Answer 4

If you want to kill every single entity, then do this:

/kill @e

Just slimes? Do this:

/kill @e[type=minecraft:slime]

Don't want the death animation or for them to split? Do this:

/execute at @e[type=minecraft:slime] run tp @e[type=minecraft:slime] ~ -1000 ~

I can't take credit for that last tp command, credit for that goes to ExpertCoder14

Answer 5

Put this in a command block ( /kill @e[type=Slime] ), put the command block on repeat, and then place a redstone block next to it.

Answer 6

There are a variety of ways to stop slimes from spawning in your area:

Answer 7

Do /kill @e to kill all entity including dropped items, started TNTs, arrows, yourself and minecarts.

Do /kill @e[type=minecraft:slime] to kill all slimes.

Do /kill @e[type=!minecraft:player] (not !=) to kill everything that is not a player. Note that this removes started TNTs, arrows, minecarts and dropped items too.

EDIT:

  1. If you only want to kill every living creature except player, do /gamemode peaceful or /gamerule doMobSpawning false as suggested in other answers.
  2. Also suggested by others, if you do not want the slimes to split after killing them or other mobs leaving lots of dropped items on the ground, use /execute at x run tp x ~ -1000 ~ where x is one of @e, @e[type!=minecraft:player] or @e[type=minecraft:slime] or other choices you may choose.
  3. Do kill @e[distance=..r] to kill everything within the radius of r. This can be helpful if you are only playing games in a certain area.

NOTE:

  • These commands are tested in 1.16.4, Java Edition. BUT NOT ANY ELSE VERSIONS.

Answer 8

Put this in a command block:

/kill @e [type = Slime]

Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

Images: Ivan Babydov, Anete Lusina, Brett Sayles, Ivan Babydov