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.
- Mobs cannot spawn on blocks that are less than a full block in height. Areas covered in bottom, half height, slabs will be unable to spawn mobs, no matter the light level, although double slabs, top slabs and upside down stairs will not work. The same rules apply to transparent blocks such as glass.
- Mobs cannot spawn if you place carpet.
- Pressure Plate
- Mobs cannot spawn where there are pressure plates.
- Mobs cannot spawn where there are buttons.
- Mob switches
- 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 nametag a mob, it does no longer count towards the mobcap, 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 mobs 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, turning it on or off.
- Another alternative to the spawn chunks is loading the area with portals. This is useful because it allows you to locate the mob switch anywhere in the world.