Hostile mobs will spawn in and around your builds if there is not a high enough light level or if it is night time. Mobs such as creepers have the potential to destroy your creations, while others may attack you. There are many ways of preventing hostile creatures from spawning.
- Light blocks
- One of the most basic ways to prevent mob spawning is by placing torches. These will increase the light level around them, stopping hostiles from spawning. Other blocks such as glowstone or shroomlight emit higher light levels, but are harder to come by. This method does not work with mobs whose spawning does not rely on low light level, such as slimes, magma cubes and hoglins.
- Mobs cannot spawn on blocks that are less than a full block in height. Areas covered in bottom half slabs will be unable to spawn mobs, no matter the light level, although double slabs, top half slabs and upside down stairs are still spawnable.
- Transparent Blocks
- Mobs will also not be able to spawn on top of transparent blocks, such as glass, or partially transparent blocks, such as leaves.
- One exception is the scaffolding, which is transparent but allows mobs to spawn. This odd fact allows a very efficient mob farm by ianxofour.
- Mobs cannot spawn on carpets because they are not a full block. It also makes nice art.
- Snow layers of thicknesses 2 to 7 prevent hostile mobs from spawning.
- Mobs other than water mobs are unable to spawn in water. Mobs other than striders are unable to spawn on lava.
(Side note: You can download mods to show where you have to spawn-proof for your mob farm or entity removing needs.)
- Mob switch
- Minecraft has a mob cap. That mob cap increases by 70 for each player online, unless it is altered through commands. This is to ensure that the world is not flooded with mobs. If you use name tag on a mob, it no longer counts towards the mob cap, but it does not despawn either, i.e it won't disappear if you go away. Some mobs are an exception to this despawn rule, like withers and shulkers. Therefore if you put more than the mob cap of either of these mob in the spawn chunks, you prevent mobs from spawning in the world. If those mobs are put on the edges of the spawn chunks, you can move them in and out (in mine carts), turning it on or off.
- Another alternative to the spawn chunks is loading the area with nether portals. This is useful because it allows you to locate the mob switch anywhere in the world.