minecraft
Gear (item)
This article is a work in progress. 
Please help in the expansion or creation of this article by expanding or improving it. The talk page may contain suggestions.

Mob spawning can be irritating and dangerous; however, with the creation of a mob switch, you can disable mob spawning in a certain area without lighting anything up, or covering everything in slabs. In Java Edition, mob spawning can even be disabled in an entire dimension with the help of chunk loading. Without further ado, let's look into the mechanics of how to create one in your world or server!

Java Edition

Basic mechanics

Jigsaw Block (top texture) JE2 BE2
This section needs expansion. 
You can help by expanding it.

In Minecraft, there is a global mob cap for each dimension: in a singleplayer world, the mob cap for hostile mobs is at 70, meaning there can only be 70 hostile mobs loaded in a dimension, and no more hostile mobs may spawn until enough mobs despawn or die, so that number gets below 70; this is to ensure that the world is not flooded with mobs. On multiplayer servers, the mob cap increases by 70 for each player online, unless it is altered through commands.

The basic premise of a mob switch is to keep a certain number of hostile mobs loaded in the world, so that the game fails to spawn more hostile mobs. This mechanic can already be demonstrated by passive mobs: In a singleplayer world, the mob cap for passive mobs is 10, but normally there are way more than 10 animals within the player's render distance, meaning it is practically impossible for passive mobs to spawn naturally after a chunk has been loaded. Passive mobs in Java Edition don't despawn, but count towards the mob cap, meaning their presence acts as a natural "mob switch" for passive mobs.

Unlike passive mobs, it is very difficult to create or find a hostile mob that doesn't despawn, but also counts towards the mob cap. This is because mobs no longer count toward the mob cap if they are marked persistent. The most common way to prevent a mob from despawning is to use a name tag on a mob, but doing so removes the mob from the mob cap, and therefore cannot be used in a mob switch. Similarly, a mob may pick up an item or enter a minecart or boat, all of which prevents it from despawning but also removes it from the mob cap. Only a few hostile mobs are exempt from this rule: for more information, see the "Choice of mob" section.

Note that the mob switch is specific to each dimension, depending on the dimension that the mobs are stored in. Mob switches can be built in both the Overworld and the Nether, but because there is no practical means to load chunks permanently in the End, a mob switch cannot be created in the End.

Options for chunk loading

Spawn chunks

Jigsaw Block (top texture) JE2 BE2
This section needs expansion. 
You can help by expanding it.
Main article: Spawn chunk

The spawn chunks is a 23x23-chunk area around the world spawn point, where the chunks are constantly loaded as long as the player is in the Overworld, or at all times on multiplayer servers. If enough persistent mobs are placed in the spawn chunks, mobs are prevented from spawning elsewhere in the Overworld.

The extent of the spawn chunks.

The extent of the spawn chunks.

The best place to store mobs in Overworld is on the edge of the spawn chunks, so that mobs can be moved in and out of the spawn chunks, turning the mob switch on or off. On the image to the right, the mobs need to be stored in the light blue colored chunks, and moved into the gray colored chunks to turn the mob switch off.

Advantages
Disadvantages

Nether portals

Jigsaw Block (top texture) JE2 BE2
This section needs expansion. 
You can help by expanding it.

Another alternative to the spawn chunks is loading the area with nether portals. This section will not describe how nether portal chunk loaders work; for more information, please see the article above.

The best place to store the mobs used in the mob switch is on the border of the 7x7-chunk loaded area: When mobs are placed in the 3x3 chunks centered on the portal, their AI is constantly loaded, which adds a lot of lag to the server. When they are stored in the outermost ring of chunks in the 7x7-chunk area, their AI is no longer processed, but they still count towards the mob cap.

To turn the mob switch off, simply turn off the chunk loader. The mobs will be unloaded, and hostile mobs are again able to spawn in the dimension they are located in.

Advantages
Disadvantages

Choice of mob

As mentioned above, most hostile mobs are removed from the mob cap once they are marked persistent, meaning they can't be used for the mob switch. However, some mobs are an exception to this rule, and can therefore be used in a mob switch. They are zombie villagers, shulkers, wardens and withers.

Zombie villager

Jigsaw Block (top texture) JE2 BE2
This section needs expansion. 
You can help by expanding it.

Normally, zombie villagers despawn like other hostile mobs do. However, due to the bug MC-182304, zombie villagers that have been traded with do not despawn, but count towards the mob cap.

To build such a mob switch, you will need a villager breeder, a job site block, and a zombie to zombify the villagers. Make sure to put blocks over the head of zombie villagers, so they do not burn in the sun (unless they are stored in water).

A zombie villager mob switch usually consists of a large room to contain at least 70 zombie villagers. If built around the spawn chunks, there needs to be a system that pushes the zombie villagers in and out of the spawn chunks; water is usually the best method, as zombie villagers don't drown unlike normal zombies, and the water additionally prevents them from burning in the sun. Once the first zombie villager is put into the holding chamber, it is typically faster to move more villagers directly into the holding chamber, so that they can be zombified by the zombie villagers already there.

Precautions
Advantages
Disadvantages

Shulker

Jigsaw Block (top texture) JE2 BE2
This section needs expansion. 
You can help by expanding it.

Shulkers are special in that they count towards the hostile mob cap, but do not despawn naturally. This makes them perfect for mob switches. A shulker-based mob switch usually consists of a large chamber where at least 70 shulkers are stored, enclosed on all sides so they do not see nearby players.

To set up a shulker mob switch, one has to transport at least one shulker from the End to the Overworld, transport them to the location where the mob switch will be built, and duplicate them in a shulker farm. More information about transporting and duplicating shulkers can be obtained from the shulker farming tutorial mentioned above.

As with other mobs used in mob switches, make sure not to name tag the shulkers, or keep them in boats or minecarts when the mob switch is finished.

Advantages
Disadvantages

Warden

Jigsaw Block (top texture) JE2 BE2
This section needs expansion. 
You can help by expanding it.

Wardens are another type of mob that counts toward the hostile mob cap, but can be prevented from despawning. The way to do so is to constantly distract them: when a warden does not detect any vibrations, it despawns after one minute; however, when a vibration is detected nearby, the warden refreshes its despawn timer, and will not despawn for another minute. This behavior can be utilized to create a mob switch.

A warden-based mob switch typically involves a warden farm that produces wardens, a way to transport the warden away so new wardens may spawn, and a holding chamber where a vibration source (such as a note block or a piston) is constantly triggered to distract the wardens and keep them from despawning. The wardens can then be loaded with a nether portal chunk loader. For more information on creating a warden farm, see the warden farm tutorial mentioned above.

An essential component of a warden-based mob switch is a way to remotely turn off the vibration source and kill the wardens, if the player wishes to get rid of the wardens and repurpose the area for something else. It also ensures that if something goes wrong in the building process, the player can safely remove the wardens and rebuild the mob switch without risking getting killed by wardens.

Advantages
Disadvantages

Wither

This section of the article is empty. 
You can help by adding to it.

Lazy mob switch

This variant of a mob switch is unique, since it uses silverfish, which was a fairly useless and annoying mob because of their ability to hide in blocks. This means that this version requires a stronghold.

Advantages

Disadvantages

Bedrock Edition

Jigsaw Block (top texture) JE2 BE2
This section needs expansion. 
You can help by expanding it.

Unlike in Java Edition, there is not a global mob cap in Bedrock Edition, and it is not possible to load chunks permanently[needs testing], meaning a global mob switch cannot be created. However, by trapping a certain amount of mobs in an area, the local mob cap can be filled, preventing more mobs from spawning nearby.