Build a self-generating dungeon maze in vanilla Minecraft using command blocks, display entities, and directional armor stands that carve glowing corridors.
Self-building StructuresMedievalDarkMysticCyanPurpleBlackAdventure MapMini-gameBuilding ToolBlock displaysArmor standsSummoned mobsBlock building (fill/setblock/clone)Rotation math21+ commands
The Self-Generating Dungeon Maze turns a solid block of stone bricks into an expanding underground labyrinth right before your eyes. Starting from a central gilded hub, glowing amethyst builder cores shoot outward in four directions, carving corridors out of stone bricks and deepslate tiles while leaving behind a trail of lanterns and soul flames.
Each builder core checks the blocks ahead of it before stepping forward, preventing paths from crossing over existing halls and creating a clean, branching dungeon layout automatically.
/scoreboard objectives add c9_t dummy/fill ~-16 ~-1 ~-16 ~16 ~-1 ~16 minecraft:deepslate_tiles/fill ~-16 ~ ~-16 ~16 ~2 ~16 minecraft:stone_bricks/fill ~-16 ~3 ~-16 ~16 ~3 ~16 minecraft:chiseled_stone_bricks/fill ~-1 ~ ~-1 ~1 ~3 ~1 minecraft:air/fill ~-1 ~-1 ~-1 ~1 ~-1 ~1 minecraft:gilded_blackstone/setblock ~ ~ ~ minecraft:soul_lantern/summon minecraft:armor_stand ~ ~1 ~ {Tags:["c9_m","c9_b"],Invisible:1b,Marker:1b,NoGravity:1b,Rotation:[0f,0f]}/summon minecraft:armor_stand ~ ~1 ~ {Tags:["c9_m","c9_b"],Invisible:1b,Marker:1b,NoGravity:1b,Rotation:[90f,0f]}/summon minecraft:armor_stand ~ ~1 ~ {Tags:["c9_m","c9_b"],Invisible:1b,Marker:1b,NoGravity:1b,Rotation:[180f,0f]}/scoreboard players add #t c9_t 1/execute if score #t c9_t matches 1 if entity @e[tag=c9_b,limit=1] at @e[tag=c9_b,limit=1] unless entity @e[tag=c9_b,distance=0.1..] run summon minecraft:armor_stand ~ ~ ~ {Tags:["c9_m","c9_b"],Invisible:1b,Marker:1b,NoGravity:1b,Rotation:[270f,0f]}/execute if score #t c9_t matches 4.. run scoreboard players set #t c9_t 0/execute as @e[tag=c9_b] at @s run particle minecraft:soul_fire_flame ~ ~0.2 ~ 0.3 0.3 0.3 0.03 4 force/execute as @e[tag=c9_b] at @s run particle minecraft:end_rod ~ ~1.5 ~ 0.2 0.5 0.2 0.02 2 force/execute if score #t c9_t matches 1 as @e[tag=c9_b] at @s positioned ^ ^ ^4 unless block ~ ~1 ~ minecraft:stone_bricks run kill @s/execute if score #t c9_t matches 1 as @e[tag=c9_b] at @s run fill ^-1 ^-1 ^1 ^1 ^2 ^4 minecraft:air/execute if score #t c9_t matches 1 as @e[tag=c9_b] at @s run fill ^-1 ^-2 ^1 ^1 ^-2 ^4 minecraft:polished_deepslate/execute if score #t c9_t matches 1 as @e[tag=c9_b] at @s run tp @s ^ ^ ^4/execute if score #t c9_t matches 1 as @e[tag=c9_b] at @s run setblock ~ ~-2 ~ minecraft:chiseled_deepslate/execute if score #t c9_t matches 1 as @e[tag=c9_b] at @s run setblock ~ ~-1 ~ minecraft:sea_lantern/execute if score #t c9_t matches 1 as @e[tag=c9_b] at @s run summon minecraft:block_display ~ ~0.3 ~ {Tags:["c9_m","c9_d"],Glowing:1b,glow_color_override:65535,block_state:{Name:"minecraft:amethyst_block"},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],scale:[0.8f,0.8f,0.8f],translation:[-0.4f,0f,-0.4f]}}/execute if score #t c9_t matches 1 as @e[tag=c9_b,limit=3,sort=random] at @s run summon minecraft:armor_stand ~ ~ ~ {Tags:["c9_m","c9_b","c9_turn"],Invisible:1b,Marker:1b,NoGravity:1b}/execute if score #t c9_t matches 1 as @e[tag=c9_turn] at @s rotated as @e[tag=c9_b,tag=!c9_turn,limit=1,sort=nearest] run tp @s ~ ~ ~ ~90 ~setup #3 Fills the stage with a solid 33x4x33 block of stone bricks and deepslate tiles so the maze carvers have material to tunnel through.setup #8 Summons invisible marker armor stands tagged <code>c9_b</code> facing the cardinal directions; their rotation determines which way each corridor digs.loop #6 Looks 4 blocks ahead of each builder using local coordinates (<code>^ ^ ^4</code>). If the block ahead is not solid <code>stone_bricks</code> (meaning it hit an existing corridor or the edge of the maze), the builder removes itself.loop #7 Carves a 3-wide, 4-tall, 4-long corridor forward using local coordinates and opens the roof so you can watch the maze grow from above.loop #13 Picks up to 3 active builders at random every cycle to spawn a new builder that turns 90 degrees, creating branches and intersections.


Recorded on our own test server: 59 frames at about 9.7 fps. Our image check saw: A stone brick maze is carved into corridors with a deepslate floor and glowing cyan-outlined amethyst blocks.
Commands, video and screenshots: tested and recorded by www.9minecraft.net © 9Minecraft. Sharing a video or screenshot? Please credit www.9minecraft.net.
To let a player trigger a maze anywhere they stand, summon the four starting c9_b armor stands relative to @p when they drop a specific item like an Amethyst Shard, and fill the stone brick volume around their position first.
/kill @e[tag=c9_m]/scoreboard objectives remove c9_t/fill ~-16 ~ ~-16 ~16 ~4 ~16 minecraft:air/fill ~-16 ~-1 ~-16 ~16 ~-1 ~16 minecraft:grass_blockBuilders automatically remove themselves when they no longer detect solid stone bricks 4 blocks ahead, which keeps them from digging outside the platform or breaking into finished hallways.
Yes. In loop command 7, change the upper Y offset in the fill command from ^2 to ^1 so the top layer of chiseled stone bricks stays intact as a roof.
▶Procedural Dungeon BuilderSelf-building StructuresHard26 cmds
▶Procedural Floating Dungeon ComplexSelf-building StructuresExpert24 cmds
▶Self-Assembling Dungeon ComplexSelf-building StructuresExpert24 cmds
▶Self-Assembling LabyrinthSelf-building StructuresMedium22 cmds
▶Self-Building Procedural DungeonSelf-building StructuresHard24 cmds
▶Self-Carving LabyrinthSelf-building StructuresHard24 cmds