Monster Room

Dungeons are structures that appear in the Overworld.

Generation
Dungeons generate naturally in the Overworld at any level below layer 48. For each chunk, 8 attempts are made to generate a dungeon; it's possible, though unlikely, for multiple attempts to succeed.

For each attempt, a location and size (an open area of 5×5×4, 5×7×4, or 7×7×4) is chosen. The attempt succeeds if the following conditions are met:
 * The floor area (including under the walls) of the potential dungeon must be entirely solid.
 * The ceiling area (including over the walls) of the potential dungeon must be entirely solid.
 * The walls of the potential dungeon must have 1–5 openings (2-high air blocks) at floor level.

If the location passes, air and cobblestone are placed, then 3 attempts are made to generate each of 2 chests. To generate a chest, the chosen block must be empty and must have a solid block on exactly one of its four sides. The spawner is placed at the center of the dungeon.

Structure
Dungeons are small rooms made of cobblestone and mossy cobblestone and contain a spawner and up to 2 chests. Finding a dungeon without a chest is very unlikely but possible. Additionally, there is a slight chance of a dungeon being found without a spawner. Occasionally, a dungeon will generate with its chests in such a way as to create a double chest. Dungeons generate with either a zombie (50% chance), skeleton (25% chance), or spider (25% chance) spawner. The spawner is always in the center of the dungeon room, with chests located around the walls of the room (large chests can connect with the short side against the wall). Each block of the floor has a 25% chance of being cobblestone, and a 75% chance of being mossy cobblestone.

Trivia

 * Dungeons are always connected to a cavern or other structure, although it's possible for the dungeon itself to overwrite most of a very small cave.
 * It is possible, though rare, to find connected dungeons with multiple spawners and extra chests. It is also possible for a dungeon to generate over another, replacing the chests and spawner of the first.
 * It is possible, though almost impossibly rare, for a dungeon to be generated at bedrock level, thereby deleting the bedrock. In that case, digging through the moss stone can lead into the Void.
 * Because the air below y=11 replaces itself with lava, this cannot happen in caves. However, it can happen in abandoned mineshafts.
 * Double-chest dungeons, as shown below, may have chests that form a perpendicular barrier between the wall and spawner (an exception to this would be in 7x7 dungeons, in which the chest cannot reach the spawner).


 * Dungeon is the only structure with chest loot that cannot be located using the command.