Skip to content


Minecraft monster spawning ideas

With the recent 2010 Halloween update to Minecraft, players are complaining about some of the changes to monster-spawning code which causes them to appear in otherwise-safe areas. After kicking some ideas around, I figured they might be worth a blog-post or two.

I’d like to present three ideas that should make the lighting-based monsters spawning system more viable. While it may seem to make players safer in their bases, it actually means that the game can place a greater emphasis on spawning lots of monsters because it reduces the chance of “weird” or “unfair” monster appearances.

Suggestion 1: Bright ceilings also deter monster spawns.

The order in which cells are checked before spawning a creeper

Currently, monsters will spawn based on the brightness of the bottommost “floor” tiles. While this makes some sense from a technical standpoint, it neglects to consider how players prefer to light their buildings, and leads to cases where an area that seems properly lit can still be vulnerable.

To fix this: When deciding whether to spawn a monster, check any empty-space around the spot and make sure the surroundings (especially upwards) are either “solid” or else are also dark enough.

Blocks checked for light when obstructions are present

On the left you can see that for a 2×1 creeper (side-view) the spawning system checks each of the blocks in the order shown. If a block on the path is “solid”, the checking on that line stops. If any “open” block visited has a light-level that is too high, the creeper cannot spawn.

In conclusion, monsters can–as before–spawn in very small dark places. However, if the area is larger, some of the extra space is checked to make sure it is also dark-enough.

Suggestion 2: Player “scent” trails.

Some people may be familiar with this as “breadcrumbs” from AI terminology. Basically, the player leaves behind a “smell” in the world as they move around. This smell goes a small distance from them, and then hangs around areas they’ve been for a while before fading. A given area will have a smell that depends on how close the player was, and how long ago they were nearby.

Technical details: Each block (or perhaps each “floor” surface) has a special counter. Counters which are above zero will decrease with time (and are zeroed when the chunk is unloaded.) If the player is near a block, that block’s counter cannot be lower than an a certain amount based on how close the player is. This means that the “smell” of a block depends both on how long ago the player was nearby, and how close the player was to to that block before they moved away.

This basic idea provides two very useful possibilities in terms of both making players less-frustrated and also making monsters a slightly bigger challenge:

  1. Most immediately-useful: Monsters can be prevented from spawning anywhere the player has very recently been, even if that place is poorly lit. This prevents annoying (and impossible) cases where you walk around a large room, and then a monster appears on the far side of it behind you as you are leaving through the only door.

  2. It provides a way to make monsters smarter! OK, not very much, but smart enough to actually follow you around small corners. If they can’t directly reach you, they can try to follow the path you took by looking at gradients in the smells.

Suggestion 3: Additive lighting

Currently, Minecraft’s lighting model is not additive.  This means that (compared to the real world) adding more torches doesn’t always make certain areas any brighter than they were before. I’ve made a quick animation to illustrate what I mean by “non-additive”. In the real world, you would expect the area between both torches to become brighter, but it does not.

Click to see an animation showing how light is non-additive in Minecraft

This lighting model is partly responsible for the frustration people are having in deep areas of the world: They place torches in a way which seems correct based on real-world lighting, but it doesn’t really work. Every time you see someone make a 1×1 pillar with torches on all four sides, it’s an example of this mistaken belief. The way the minecraft world currently works,  the ideal way to light things is to avoid grouping any torches together, yet players do this all the time because it’s what we “know” works.

Changing to an additive model (with an upper cap on brightness) would add visual realism and reduce the amount of frustration players will feel when trying to make areas safe.

Posted in Games, Programming.

Tagged with .


2 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Shadow14l says

    Good suggestions, but this has very little to do with “programming”.

  2. Darien says

    So describing neither (A) cell-by-cell algorithms for changing the behavior existing game code nor (B) ways of annotating the huge array that comprises the game-world don’t count? Because… what, because it’s done with words and pictures?

    You’re thinking of “data entry”, not programming.