Monster Room

Dungeons are structures that appear in the Overworld.

Generation
Dungeons generate naturally in the Overworld at any level below layer 48, regardless of whether Generate structures has been toggled off for said world. 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 with a width and length of 7, 9, or 11 and a height of 6) 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 ceiling blocks may be gravity-affected such as gravel or sand, which fall if disturbed by the player.
 * 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.

Cobblestone has a $4/5$ chance to be mossy when it is on the floor 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 unlikely but possible. Additionally, there is a slight chance of a dungeon being found without a spawner. Occasionally, a dungeon generates 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 20% chance of being cobblestone, and a 80% 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 tiny 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 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.