How do I kill all mobs in a world without being in it?

I used a command block that was set to repeat with the command /summon slime and accidentally turned on a lever next to it. Now my screen is full of slimes, the world is lagging, and I can't turn off the lever as the game won't completely load. Is there a way to stop the mobs?


This is a bit of a complex way to kill the slimes, but it technically should work.

  1. Set your render distance to one chunk. By doing this, you will be able to move slightly faster while doing everything after this, as it won’t render all the slimes.
  2. Place down a command block. Make this command block a repeating one and enter this command: /kill @e[type=minecraft:slime]and add a redstone block next to this command block. This will kill all slimes rendered in your world.
  3. Turn up your render chunks. By turning up this, you will be able to kill all slimes in your visible area. Then, destroy the command block summoning all the slimes.

Source: I tested it myself for good measure.


There are multiple ways to remove all slimes. For all listed methods you should set your render distance and entity render distance to the lowest value possible. This will eliminate some lag by rendering less slimes.

After every method you should change everything back to how you prefer it.


The methods are listed in order of simplicity:

Method 1

  • Load the world and set the gamemode to peaceful.

Method 2

  • Load the world and type:

      /tp @e[type=Slime] ~ -300 ~
    

    to teleport all slimes into the void. (You can press open to LAN and enable cheats if you haven't.)

Method 3

  1. Load the world and type:

     /gamerule doMobLoot False
    

    (To stop slimes from dropping loot)

  2. Type:

     /kill @e[type=minecraft:slime]
    

    and repeat it at least 3 times. (To kill all slimes with different sizes)

  3. Type:

     /gamerule doMobLoot True
    

    to re-enable mob loot.


And if all of those in-game solutions fail you, there's this program called MCedit which can do all kinds of stuff including removing the command block and removing all slimes. However, development seems halted since 2016 so it might not work. MCEdit Unified is a continueation of the original MCEdit project by the community but hasn't been updated since 2017. The latest supported version was 1.11.2 but might still work. It also added support for the Bedrock editions. MCCToolChestPE is a comparable tool for the Bedrock editions and has some world conversion options.

Source