Self-Generating Dungeon Maze

Build a self-generating dungeon maze in vanilla Minecraft using command blocks, display entities, and directional armor stands that carve glowing corridors.

Java EditionComplex Contraptions & CinematicsExpert24 commandsTested on a real 26.2 & 26.3 server
Glowing amethyst blocks line the carved corridors of a stone brick and deepslate maze in Minecraft. Download the GIF Video & GIF © www.9minecraft.net

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.

1. Setup - type these once 10 commands

  1. /scoreboard objectives add c9_t dummy
  2. /fill ~-16 ~-1 ~-16 ~16 ~-1 ~16 minecraft:deepslate_tiles
  3. /fill ~-16 ~ ~-16 ~16 ~2 ~16 minecraft:stone_bricks
  4. /fill ~-16 ~3 ~-16 ~16 ~3 ~16 minecraft:chiseled_stone_bricks
  5. /fill ~-1 ~ ~-1 ~1 ~3 ~1 minecraft:air
  6. /fill ~-1 ~-1 ~-1 ~1 ~-1 ~1 minecraft:gilded_blackstone
  7. /setblock ~ ~ ~ minecraft:soul_lantern
  8. /summon minecraft:armor_stand ~ ~1 ~ {Tags:["c9_m","c9_b"],Invisible:1b,Marker:1b,NoGravity:1b,Rotation:[0f,0f]}
  9. /summon minecraft:armor_stand ~ ~1 ~ {Tags:["c9_m","c9_b"],Invisible:1b,Marker:1b,NoGravity:1b,Rotation:[90f,0f]}
  10. /summon minecraft:armor_stand ~ ~1 ~ {Tags:["c9_m","c9_b"],Invisible:1b,Marker:1b,NoGravity:1b,Rotation:[180f,0f]}

2. Loop - one repeating command block each (Always Active) 14 commands

  1. /scoreboard players add #t c9_t 1
  2. /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]}
  3. /execute if score #t c9_t matches 4.. run scoreboard players set #t c9_t 0
  4. /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
  5. /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
  6. /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
  7. /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
  8. /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
  9. /execute if score #t c9_t matches 1 as @e[tag=c9_b] at @s run tp @s ^ ^ ^4
  10. /execute if score #t c9_t matches 1 as @e[tag=c9_b] at @s run setblock ~ ~-2 ~ minecraft:chiseled_deepslate
  11. /execute if score #t c9_t matches 1 as @e[tag=c9_b] at @s run setblock ~ ~-1 ~ minecraft:sea_lantern
  12. /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]}}
  13. /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}
  14. /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 ~

How it works

Frames from the test run

Self-Generating Dungeon Maze - frame 1Self-Generating Dungeon Maze - frame 2Self-Generating Dungeon Maze - frame 3

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.

Build it in your world

  1. Find a flat area with at least 35x35 blocks of clear space and stand at the center.
  2. Run each of the 10 setup commands in order to create the scoreboard objective, build the solid dungeon block, and place the initial carvers.
  3. Place a line of 14 command blocks nearby. Set the first one to Repeat, Unconditional, and Always Active, and chain the other 13 to it as Chain, Unconditional, Always Active.
  4. Paste the 14 loop commands in order into the command blocks. Remember to wrap coordinates or place the command blocks right below the center of the maze.
  5. Watch from above as the glowing cyan amethyst nodes branch out and excavate the dungeon corridors automatically.

Use it with real players

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.

Remove it again 4 commands

  1. /kill @e[tag=c9_m]
  2. /scoreboard objectives remove c9_t
  3. /fill ~-16 ~ ~-16 ~16 ~4 ~16 minecraft:air
  4. /fill ~-16 ~-1 ~-16 ~16 ~-1 ~16 minecraft:grass_block

FAQ

Why did the builders stop moving?

Builders 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.

Can I make the corridors have a closed ceiling?

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.

Commands used

/execute/fill/kill/particle/scoreboard/setblock/summon/tp

Similar creations

Join 9Minecraft News & Guides