Self-Building Procedural Dungeon

Autonomous glowing builder entities step along a 5-block grid to carve out a procedural deepslate dungeon with rooms, doorways, and loot in real time.

Java EditionComplex Contraptions & CinematicsExpert24 commandsTested on a real 26.2 & 26.3 server
Glowing armor stands procedurally generate an open-roofed deepslate dungeon with soul fire particles. Download the GIF Video & GIF © www.9minecraft.net

Self-building StructuresDarkMedievalBlackCyanGoldBuilding ToolAdventure MapMap MakingArmor standsBlock building (fill/setblock/clone)Rotation math21+ commands

Watch an intricate dungeon build itself right before your eyes. Glowing spectral builders step across a 5-block grid, randomly turning left, right, or moving straight ahead to construct open-roofed deepslate brick chambers, polished tile floors, soul lanterns, and treasure chests while carving connecting doorways.

Because the builders choose random directions every few ticks and check the floor underneath before moving, the layout is different every time it generates.

1. Setup - type these once 10 commands

  1. /scoreboard objectives add c9_t dummy
  2. /scoreboard players set #tick c9_t 0
  3. /fill ~-17 ~-1 ~-17 ~17 ~6 ~17 air
  4. /fill ~-17 ~-1 ~-17 ~17 ~-1 ~17 polished_blackstone_bricks
  5. /fill ~-12 ~-2 ~-12 ~12 ~-2 ~12 crying_obsidian
  6. /fill ~-2 ~ ~-2 ~2 ~3 ~2 deepslate_bricks outline
  7. /fill ~-2 ~3 ~-2 ~2 ~3 ~2 air
  8. /fill ~-1 ~-1 ~-1 ~1 ~-1 ~1 deepslate_tiles
  9. /summon armor_stand ~ ~ ~ {Tags:["c9_gen","c9_b"],Invisible:1b,NoGravity:1b,Glowing:1b,ArmorItems:[{},{},{},{id:"minecraft:sea_lantern",count:1}],Rotation:[0f,0f]}
  10. /summon armor_stand ~ ~ ~ {Tags:["c9_gen","c9_b"],Invisible:1b,NoGravity:1b,Glowing:1b,ArmorItems:[{},{},{},{id:"minecraft:shroomlight",count:1}],Rotation:[180f,0f]}

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

  1. /scoreboard players add #tick c9_t 1
  2. /execute as @e[tag=c9_b] at @s run particle soul_fire_flame ~ ~1.5 ~ 0.3 0.3 0.3 0.03 4 force
  3. /execute if score #tick c9_t matches 4.. as @e[tag=c9_b] at @s run tp @s ~ ~ ~ ~90 0
  4. /execute if score #tick c9_t matches 4.. as @e[tag=c9_b,limit=1,sort=random] at @s run tp @s ~ ~ ~ ~-90 0
  5. /execute if score #tick c9_t matches 4.. as @e[tag=c9_b,limit=1,sort=random] at @s run tp @s ~ ~ ~ ~180 0
  6. /execute if score #tick c9_t matches 4.. as @e[tag=c9_b] at @s if block ^ ^-2 ^5 crying_obsidian run fill ^-1 ^ ^2 ^1 ^2 ^3 air
  7. /execute if score #tick c9_t matches 4.. as @e[tag=c9_b] at @s if block ^ ^-2 ^5 crying_obsidian run tp @s ^ ^ ^5
  8. /execute if score #tick c9_t matches 4.. as @e[tag=c9_b] at @s unless block ~ ~-1 ~ deepslate_tiles run fill ~-2 ~ ~-2 ~2 ~2 ~2 deepslate_bricks outline
  9. /execute if score #tick c9_t matches 4.. as @e[tag=c9_b] at @s unless block ~ ~-1 ~ deepslate_tiles run fill ~-1 ~ ~-1 ~1 ~2 ~1 air
  10. /execute if score #tick c9_t matches 4.. as @e[tag=c9_b] at @s unless block ~ ~-1 ~ deepslate_tiles run fill ~-2 ~2 ~-2 ~2 ~2 ~2 chiseled_deepslate replace deepslate_bricks
  11. /execute if score #tick c9_t matches 4.. as @e[tag=c9_b] at @s unless block ~ ~-1 ~ deepslate_tiles run particle flash ~ ~2 ~ 0 0 0 0 1 force
  12. /execute if score #tick c9_t matches 4.. as @e[tag=c9_b] at @s unless block ~ ~-1 ~ deepslate_tiles run setblock ~ ~ ~ soul_lantern
  13. /execute if score #tick c9_t matches 4.. as @e[tag=c9_b] at @s unless block ~ ~-1 ~ deepslate_tiles run fill ~-1 ~-1 ~-1 ~1 ~-1 ~1 deepslate_tiles
  14. /execute if score #tick c9_t matches 4.. run scoreboard players set #tick c9_t 0

How it works

Frames from the test run

Self-Building Procedural Dungeon - frame 1Self-Building Procedural Dungeon - frame 2Self-Building Procedural Dungeon - frame 3

Recorded on our own test server: 69 frames at about 9.7 fps. Our image check saw: Glowing armor stands move around a grid, progressively generating an open-roofed deepslate dungeon with soul fire particles and lanterns.

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 in the center of a flat open area at least 35x35 blocks wide.
  2. Run each of the 10 setup commands in chat to prepare the foundation, boundary layer, starting room, and two glowing builder entities.
  3. Place 14 repeating command blocks in a row or stack near your build area and set every block to Repeat, Unconditional, and Always Active.
  4. Paste the 14 loop commands in order from 1 to 14 into the repeating command blocks.
  5. Watch the glowing builders step across the grid every 0.2 seconds, carving doorways and generating new rooms automatically.
  6. When the dungeon reaches a size you like, run the removal commands or kill the <code>c9_b</code> entities to freeze the structure.

Use it with real players

To let a player guide or spawn new dungeon branches manually, summon a builder at your position facing a cardinal direction with /summon armor_stand ~ ~ ~ {Tags:["c9_gen","c9_b"],Invisible:1b,NoGravity:1b,Rotation:[0f,0f]} (make sure you stand aligned to the 5-block grid from the center).

Remove it again 4 commands

  1. /kill @e[tag=c9_gen]
  2. /scoreboard objectives remove c9_t
  3. /fill ~-17 ~-2 ~-17 ~17 ~6 ~17 air
  4. /fill ~-17 ~-1 ~-17 ~17 ~-1 ~17 grass_block

FAQ

Why did the builders stay inside the starting room in the old version?

The old version checked for polished blackstone bricks at ^ ^ ^5 (air level) instead of ^ ^-1 ^5 (floor level), so the check always failed and the builders never moved. Checking the underground crying obsidian boundary at ^ ^-2 ^5 fixes both movement and stage bounds.

How can I make the dungeon generate over a larger area?

Expand the crying obsidian layer in setup command 5 to cover a larger area, and the builders will automatically explore the full size of that underground grid.

Commands used

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

Similar creations

Join 9Minecraft News & Guides