Self-Building Stone Labyrinth

Watch a 23x23 stone labyrinth build itself in real time as glowing spectral mason orbs snake across a tiled courtyard, carving paths and raising stone walls.

Java EditionComplex Contraptions & CinematicsHard24 commandsTested on a real 26.2 & 26.3 server
An overhead view of a mossy stone brick labyrinth with glowing spectral blocks inside. Download the GIF Video & GIF © www.9minecraft.net

Self-building StructuresMedievalMysticNatureGreenCyanWhiteMini-gameAdventure MapBuilding ToolItem displaysSmooth animation (interpolation)Summoned mobsBlock building (fill/setblock/clone)Rotation math21+ commands

This command creation uses the classic Depth-First Search (DFS) recursive backtracking algorithm to build a genuine 23x23 stone labyrinth right before your eyes. Glowing spectral mason orbs snake across a tiled stone courtyard, carving open pathways and raising three-block-tall walls of stone brick, mossy stone brick, and sea lanterns.

Because each mason orb chooses random unvisited directions every single tick and backtracks along its breadcrumb trail when cornered, every labyrinth generated is completely unique and solvable.

1. Setup - type these once 10 commands

  1. /scoreboard objectives add c9_t dummy
  2. /fill ~-12 ~-1 ~-12 ~12 ~-1 ~12 minecraft:chiseled_stone_bricks
  3. /fill ~-11 ~-1 ~-11 ~11 ~-1 ~11 minecraft:polished_andesite
  4. /fill ~-11 ~ ~-11 ~11 ~2 ~11 minecraft:stone_bricks
  5. /fill ~-11 ~2 ~-11 ~11 ~2 ~11 minecraft:mossy_stone_bricks replace minecraft:stone_bricks
  6. /setblock ~ ~-1 ~ minecraft:sea_lantern
  7. /fill ~ ~ ~ ~ ~2 ~ minecraft:air
  8. /summon minecraft:item_display ~0.5 ~3.2 ~0.5 {Tags:["c9_ent","c9_head"],Glowing:1b,glow_color_override:65535,teleport_duration:1,item:{id:"minecraft:conduit"},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[0f,0f,0f],scale:[1.6f,1.6f,1.6f]}}
  9. /summon minecraft:item_display ~-9.5 ~3.2 ~-9.5 {Tags:["c9_ent","c9_head"],Glowing:1b,glow_color_override:16755200,teleport_duration:1,item:{id:"minecraft:shroomlight"},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[0f,0f,0f],scale:[1.5f,1.5f,1.5f]}}
  10. /summon minecraft:item_display ~9.5 ~3.2 ~9.5 {Tags:["c9_ent","c9_head"],Glowing:1b,glow_color_override:16711935,teleport_duration:1,item:{id:"minecraft:sea_lantern"},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[0f,0f,0f],scale:[1.5f,1.5f,1.5f]}}

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

  1. /execute as @e[tag=c9_head] at @s run tag @s remove c9_step
  2. /execute as @e[tag=c9_head] at @s if block ~ ~-4.2 ~-2 minecraft:polished_andesite run summon minecraft:marker ~ ~ ~-2 {Tags:["c9_ent","c9_opt"],Rotation:[180f,0f]}
  3. /execute as @e[tag=c9_head] at @s if block ~ ~-4.2 ~2 minecraft:polished_andesite run summon minecraft:marker ~ ~ ~2 {Tags:["c9_ent","c9_opt"],Rotation:[0f,0f]}
  4. /execute as @e[tag=c9_head] at @s if block ~2 ~-4.2 ~ minecraft:polished_andesite run summon minecraft:marker ~2 ~ ~ {Tags:["c9_ent","c9_opt"],Rotation:[-90f,0f]}
  5. /execute as @e[tag=c9_head] at @s if block ~-2 ~-4.2 ~ minecraft:polished_andesite run summon minecraft:marker ~-2 ~ ~ {Tags:["c9_ent","c9_opt"],Rotation:[90f,0f]}
  6. /execute as @e[tag=c9_head] at @s as @e[tag=c9_opt,distance=..2.5,sort=random,limit=1] at @s run tag @s add c9_pick
  7. /execute as @e[tag=c9_pick] at @s run fill ^ ^-3.2 ^ ^ ^-1.2 ^-1 minecraft:air
  8. /execute as @e[tag=c9_pick] at @s run fill ^ ^-4.2 ^ ^ ^-4.2 ^-1 minecraft:smooth_quartz
  9. /execute as @e[tag=c9_pick] at @s positioned ^ ^ ^-1 run summon minecraft:marker ~ ~ ~ {Tags:["c9_ent","c9_crumb"]}
  10. /execute as @e[tag=c9_head] at @s if entity @e[tag=c9_pick,distance=..2.5] run tag @s add c9_step
  11. /execute as @e[tag=c9_head,tag=c9_step] at @s run tp @s @e[tag=c9_pick,distance=..2.5,limit=1]
  12. /execute as @e[tag=c9_head,tag=!c9_step] at @s as @e[tag=c9_crumb,distance=..1.5,limit=1] at @s run fill ^ ^-4.2 ^ ^ ^-4.2 ^1 minecraft:sea_lantern
  13. /execute as @e[tag=c9_head,tag=!c9_step] at @s as @e[tag=c9_crumb,distance=..1.5,limit=1] at @s positioned ^ ^ ^-1 run tp @e[tag=c9_head,distance=..2.5,limit=1] ~ ~ ~
  14. /kill @e[tag=c9_opt]

How it works

Frames from the test run

Self-Building Stone Labyrinth - frame 1Self-Building Stone Labyrinth - frame 2Self-Building Stone Labyrinth - frame 3

Recorded on our own test server: 53 frames at about 8.8 fps. Our image check saw: A stone brick and mossy stone brick maze with sea lanterns and glowing spectral blocks is shown from above, though all three frames are identical.

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. Stand at the centre of a flat area with at least 15 blocks of clear space in every direction.
  2. Run the 10 setup commands in chat or in an impulse command block sequence to build the 23x23 enclosed stone brick block and summon the three glowing mason orbs.
  3. Place 14 command blocks in a connected chain: the first as a Repeating, Unconditional, Always Active block, and the remaining 13 as Chain, Unconditional, Always Active blocks.
  4. Paste the 14 loop commands in order into the command blocks.
  5. Watch from above as the glowing orbs carve out twisting stone corridors and light the floor with smooth quartz and sea lanterns.

Use it with real players

To let a player manually reset and watch a fresh labyrinth generate around them, place the setup commands inside a chain triggered by a stone button at the entrance, or summon a single c9_head orb at @p aligned to odd coordinates so the maze branches outward from where you stand.

Remove it again 4 commands

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

FAQ

Is the labyrinth different every time I run the setup commands?

Yes. Because the mason orbs pick directions using sort=random every tick, the corridor layout is completely different on every run.

Why do the mason orbs move two blocks at a time?

Stepping by two blocks ensures a one-block-thick stone brick wall always remains between adjacent corridors so rooms never merge into wide open halls.

Commands used

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

Similar creations

Join 9Minecraft News & Guides