I run a private server for my friends, and want to make a specific area mob-safe, without placing any block or light it. Changing the global difficulty or mob-spawning server property with command block is not an option: even if somebody is insed the area (enterieur of a huge building, actually), I need the mob spawning on the rest of the map work normally. Changing the biom to mushroom island is also not very good, because it is in the middle of a huge desert, and I want weather to work the same as its surroundings (ie. the rest of the desert).

Is there any way to do this, via command block, map edition, or maybe modding, scripting, etc.?

  • I don't know how to achieve this on an existing map, but if you can change the biome of the desired area to Mooshroom Island, no mobs will spawn. But this may also change grass colors and have other side effects.
    – Dan Bron
    Apr 20, 2017 at 19:50
  • Mods or plugins can manage it for sure. Just look for admin utility mods on Curse or so. Sep 20, 2017 at 7:01

2 Answers 2


This doesn't disable spawning, exactly, but it will kill all mobs within a certain radius. First, you have to create a team for your friends and you to stop yourselves getting killed when you enter that location. So, run a repeating command block with this command:

/kill @e[type=!Player,r=RADIUS]

Replace RADIUS with the amount of blocks you want the command block to check for in each direction. For example, if you had a 5x5x5 room, and the command block was in the center of the room, your radius would be two.

So, now, whenever mobs that are not players spawn in that area, it'll kill them.

However, mobs count as both hostile ones (like creepers) and docile ones (like chickens). If you, for example, want sheep to survive in that area, change the command to this:

/kill @e[type=!Player,type=!Sheep,r=RADIUS]

So now, the command block will allow sheep to spawn in that area. If you wanted to add a pig, do the same for the entity type Pig:

/kill @e[type=!Player,type=!Sheep,type=!Pig,r=RADIUS]

And so on.

If the command block output in the chat is getting annoying, type this into the chat, not the command block:

/gamerule commandBlockOutput false

Hope this helps!

  • 1.13 syntax: /kill @e[type=!player,type=!sheep,type=!pig,distance=..radius]
    – pppery
    Apr 10, 2020 at 21:08

I know this is an old question, but still relevant.

This is the best command I've come up with- put it into a Repeating Command Block that's always active. Don't create a lot of these in the same area, or they'll slow the game, but one isn't a problem. Also, teleporting hostile mobs to the bottom of the world won't leave behind rotten flesh, bones, gunpowder, or other evidence. If you look closely at night or in the darkness, it's still possible to see hostile mobs blinking in and out of existence.

tp @e[type=!allay,type=!axolotl,type=!bat,type=!bee,type=!camel,type=!cat,type=!chicken,type=!cod,type=!cow,type=!donkey,type=!dolphin,type=!fox,type=!frog,type=!goat,type=!glow_squid,type=!horse,type=!iron_golem,type=!llama,type=!mooshroom,type=!mule,type=!ocelot,type=!panda,type=!parrot,type=!pig,type=!piglin,type=!polar_bear,type=!pufferfish,type=!rabbit,type=!salmon,type=!sheep,type=!skeleton_horse,type=!snow_golem,type=!squid,type=!strider,type=!tadpole,type=!tropical_fish,type=!turtle,type=!villager,type=!wandering_trader,type=!trader_llama,type=!wolf,type=!zombie_horse,type=!armor_stand,type=!boat,type=!chest_boat,type=!item,type=!item_frame,type=!glow_item_frame,type=!minecart,type=!chest_minecart,type=!hopper_minecart,type=!furnace_minecart,type=!command_block_minecart,type=!player,distance=..100] ~ ~-500 ~

This is current as of 1.19. It has to be added to with each release that adds passive/neutral mobs.

Mojang, please add a hostile mob target selector!!!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .