Procedural Infinite Corridor Generator

Build a self-expanding sci-fi laboratory in vanilla Minecraft using glowing probe entities that carve out lighted corridors, junctions, and glass windows.

Java EditionComplex Contraptions & CinematicsHard24 commandsTested on a real 26.2 & 26.3 server
A cross-shaped white iron corridor with sea lantern ceiling strips and a central beacon. Download the GIF Video & GIF © www.9minecraft.net

Self-building StructuresTechnologyIndustrialSpaceWhiteCyanBuilding ToolMap MakingAdventure MapBlock displaysArmor standsBlock building (fill/setblock/clone)Rotation math21+ commands

Watch an automated laboratory complex assemble itself right in front of you. Starting from a glowing central beacon hub, four glowing builder probes shoot outward in cardinal directions, stamping down clean white iron walls, cyan glass viewing windows, and overhead sea lantern light strips.

As the probes travel, they periodically branch off at 90-degree angles to form intersections and side hallways, emitting bursts of cyan energy particles as each slice of the corridor is constructed.

1. Setup - type these once 10 commands

  1. /scoreboard objectives add c9_t dummy
  2. /fill ~-17 ~ ~-17 ~17 ~6 ~17 air
  3. /fill ~-2 ~ ~-2 ~2 ~4 ~2 iron_block hollow
  4. /fill ~-1 ~4 ~-1 ~1 ~4 ~1 sea_lantern
  5. /summon marker ~ ~1 ~ {Tags:["c9_all","c9_center"]}
  6. /summon block_display ~-0.5 ~1.5 ~-0.5 {Tags:["c9_all","c9_core"],Glowing:1b,glow_color_override:65535,block_state:{Name:"minecraft:beacon"}}
  7. /summon armor_stand ~ ~1 ~ {Tags:["c9_all","c9_b"],NoGravity:1b,Glowing:1b,Small:1b,Rotation:[0f,0f]}
  8. /summon armor_stand ~ ~1 ~ {Tags:["c9_all","c9_b"],NoGravity:1b,Glowing:1b,Small:1b,Rotation:[90f,0f]}
  9. /summon armor_stand ~ ~1 ~ {Tags:["c9_all","c9_b"],NoGravity:1b,Glowing:1b,Small:1b,Rotation:[180f,0f]}
  10. /summon armor_stand ~ ~1 ~ {Tags:["c9_all","c9_b"],NoGravity:1b,Glowing:1b,Small:1b,Rotation:[270f,0f]}

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

  1. /scoreboard players add @e[tag=c9_b] c9_t 1
  2. /execute as @e[tag=c9_b,scores={c9_t=3..}] at @s if block ^ ^ ^3 iron_block run fill ^-1 ^ ^1 ^1 ^2 ^3 air
  3. /execute as @e[tag=c9_b,scores={c9_t=3..}] at @s if block ^ ^ ^3 iron_block run kill @s
  4. /execute as @e[tag=c9_b,scores={c9_t=3..}] at @s run tp @s ^ ^ ^1
  5. /execute as @e[tag=c9_b,scores={c9_t=3..}] at @s run fill ^-2 ^-1 ^2 ^2 ^3 ^2 iron_block
  6. /execute as @e[tag=c9_b,scores={c9_t=3..}] at @s run fill ^-2 ^1 ^2 ^2 ^1 ^2 cyan_stained_glass
  7. /execute as @e[tag=c9_b,scores={c9_t=3..}] at @s run fill ^-1 ^ ^1 ^1 ^2 ^2 air
  8. /execute as @e[tag=c9_b,scores={c9_t=3..}] at @s run setblock ^ ^3 ^2 sea_lantern
  9. /execute as @e[tag=c9_b,scores={c9_t=3..}] at @s run particle dust{color:[0.1,0.9,1.0],scale:1.6} ^ ^1.2 ^2 0.8 0.8 0.8 0 15
  10. /execute as @e[tag=c9_b,scores={c9_t=4..},limit=12] at @s if entity @e[tag=c9_center,distance=4..12] unless entity @e[tag=c9_b,distance=0.1..4] run summon armor_stand ~ ~ ~ {Tags:["c9_all","c9_b","c9_turn"],NoGravity:1b,Glowing:1b,Small:1b}
  11. /execute as @e[tag=c9_turn] at @s store result entity @s Rotation[0] float 90 run random value 0..3
  12. /tag @e[tag=c9_turn] remove c9_turn
  13. /execute at @e[tag=c9_center] run kill @e[tag=c9_b,distance=14..]
  14. /scoreboard players set @e[tag=c9_b,scores={c9_t=3..}] c9_t 0

How it works

Frames from the test run

Procedural Infinite Corridor Generator - frame 1Procedural Infinite Corridor Generator - frame 2Procedural Infinite Corridor Generator - frame 3

Recorded on our own test server: 57 frames at about 9.4 fps. Our image check saw: A four-way cross-shaped corridor made of iron blocks, cyan glass, and sea lanterns sits stationary without branching off or changing across the frames.

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 open area and stand where you want the central hub of the laboratory to appear.
  2. Run each of the 10 setup commands in chat one by one to create the scoreboard objective, the starter chamber, the center marker, and the four initial builder probes.
  3. Place a repeating command block set to Always Active, followed by a chain of 13 chain command blocks (all Conditional: Unconditional, Always Active).
  4. Paste the 14 loop commands in order into the repeating and chain command blocks.
  5. Watch the glowing probes march outward and carve out branching corridors, junctions, and glass windows.
  6. To generate a fresh layout, run the cleanup commands and re-run the setup commands.

Use it with real players

To let a player carve corridors manually wherever they look, remove the automatic tp and branching commands, and instead run the local ^ ^ ^ fill commands at @a[nbt={SelectedItem:{id:"minecraft:Debug_stick"}}] rotated ~ 0 so walking forward stamps out a tunnel around you in real time.

Remove it again 4 commands

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

FAQ

How can I make the corridors generate over a much larger area?

Increase the distance check in loop command 10 (for example, <code>distance=4..40</code>) and raise the cleanup radius in loop command 13 (for example, <code>distance=45..</code>).

Why do the commands use caret (^ ^ ^) coordinates instead of tilde (~ ~ ~)?

Caret coordinates are relative to the direction an entity is facing, allowing a single set of <code>/fill</code> commands to build walls, windows, and ceilings correctly whether the probe faces north, south, east, or west.

Commands used

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

Similar creations

Join 9Minecraft News & Guides