How Mob Spawning Starts
Minecraft does not pick a random dark block and drop a zombie onto it. A natural spawn has to pass several checks before the mob actually appears.
The exact rules depend on the mob, but the game usually cares about light, distance from a player, available space, the block underneath the mob, biome or dimension rules, and how many mobs are already loaded.
A normal Overworld monster generally needs a dark enough position, a valid place to stand, enough space to fit, the right distance from a player, and room under the mob cap.
Check the Light Level
Common Overworld monsters such as zombies, skeletons, creepers, and spiders normally need a block light level of 0 at the spawning position.
That means block light level 1 is already enough to stop those ordinary hostile mob spawns.
Where do I see the light level?
Open the F3 debug screen in Java Edition. Look for the light information near your position. Minecraft shows sky light and block light separately.
For torches, lanterns, glowstone, and other placed light sources, the block light value is the important one.
Some mobs have special spawning rules. Slimes in slime chunks are one well-known exception, and structure-specific or Nether mobs can use different requirements too.
Stay the Right Distance Away
Most naturally spawning hostile mobs cannot spawn within 24 blocks of a player.
Once a location is more than 24 blocks away, it can become eligible. For normal hostile mobs, the useful outer range is around 128 blocks from the player.
Give the Mob Somewhere to Spawn
A dark block at the correct distance still does not guarantee a spawn. The mob needs a valid physical position too.
The exact requirements depend on the mob, but the game checks whether its body fits, whether the floor is valid, and whether any special environmental requirements are satisfied.
Enough Room
The mob's hitbox needs enough empty space to fit without intersecting solid blocks.
Valid Floor
Most land mobs need a suitable block beneath the spawning position.
Correct Environment
Some mobs also care about biome, dimension, structure, fluid, or Y level.
Understand the Mob Cap
Minecraft does not keep spawning mobs forever. Naturally spawned mobs are split into categories, and each category has a limit.
In a normal Java Edition single-player situation, the monster category has a base mob cap of 70.
That does not mean exactly 70 monsters will always be standing around you. Eligible chunks, loaded areas, multiplayer, and other spawning rules affect the actual result.
If monsters are filling dark caves underneath your farm, those mobs can use part of the available hostile mob cap. Fewer spawning opportunities are then left for the farm itself.
How Despawning Works
Most naturally spawned hostile mobs are temporary. Once every player is far enough away, Minecraft can remove them.
Random Despawning
Eligible mobs more than 32 blocks from every player can begin randomly despawning after enough time has passed.
Immediate Despawn
Most ordinary hostile mobs immediately despawn when no player is within 128 blocks.
After an eligible mob has had no player within 32 blocks for more than 30 seconds, it normally receives a 1 in 800 chance each game tick to despawn.
Not every mob can disappear normally. Naming a mob is one common way to make it persistent, and some mob types are persistent by default.
Spawn-Proof an Area
If you just want creepers and zombies to stop appearing around your base, you usually do not need to think about every part of the spawning algorithm.
For ordinary Overworld monsters, finding every block-light-0 area is a great place to start.
- Light dark floors, roofs, caves, basements, and hidden corners.
- Use the F3 screen when you cannot tell whether an area is actually dark enough to spawn mobs.
- Check behind buildings and underneath decorative structures.
- Use non-spawnable surfaces where adding visible lighting would look bad.
- Remember that special mobs can have their own rules.
Why Mob Farms Use These Rules
A mob farm is basically an attempt to give the spawning system one really good place to spawn mobs while making the surrounding area much worse.
The spawning platforms need to be more than 24 blocks from the player, but the mobs also need to remain inside the useful 128-block range.
That is why the AFK position matters, and why farms are often built high above oceans or high in the sky. Fewer caves and other spawnable surfaces are competing with the farm.
0 light / 24 blocks / 32 blocks / 128 blocks
Those four numbers explain a huge amount of ordinary Java hostile mob behavior: block light 0 for common monster spawning, 24 blocks for the close-player restriction, 32 blocks for random despawning, and 128 blocks for the outer despawn range.