Villager Traffic Light Intersection

Watch a bustling crowd of villagers commute along a paved road, halting at a glowing red traffic signal and marching ahead as it turns green.

Java EditionMobs & PetsMedium24 commandsTested on a real 26.2 & 26.3 server
Minecraft villagers cross a stone road under an automated traffic light switching between red and green. Download the GIF Video & GIF © www.9minecraft.net

Mob ParadesTechnologyIndustrialRedGreenDecorationMap MakingLearningSummoned mobsBlock building (fill/setblock/clone)21+ commands

Even Minecraft villagers need road safety when commuting through a busy town. This command creation builds a crosswalk equipped with an automated overhead traffic signal and a steady stream of commuting villagers walking down a paved stone road.

When the overhead lamp glows emerald green, the villagers march forward across the white zebra stripes. As soon as the signal switches to redstone red and projects a glowing stop line across the pavement, every villager waiting before the crosswalk comes to an orderly halt while villagers already past the crossing continue to their destination.

1. Setup - type these once 10 commands

  1. /scoreboard objectives add c9_timer dummy
  2. /scoreboard players set #tick c9_timer 0
  3. /fill ~-12 ~-1 ~-2 ~12 ~-1 ~2 stone_bricks
  4. /fill ~-12 ~-1 ~-2 ~12 ~-1 ~-2 smooth_stone_slab[type=double]
  5. /fill ~-12 ~-1 ~2 ~12 ~-1 ~2 smooth_stone_slab[type=double]
  6. /fill ~-2 ~-1 ~-1 ~-1 ~-1 ~1 quartz_block
  7. /fill ~-1 ~ ~3 ~-1 ~4 ~3 cobblestone_wall
  8. /fill ~-1 ~5 ~ ~-1 ~5 ~3 cobblestone_wall
  9. /setblock ~-1 ~4 ~ emerald_block
  10. /summon marker ~ ~ ~ {Tags:["c9_ctrl"]}

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

  1. /scoreboard players add #tick c9_timer 1
  2. /execute if score #tick c9_timer matches 160.. run scoreboard players set #tick c9_timer 0
  3. /execute if score #tick c9_timer matches 0 run setblock ~-1 ~4 ~ emerald_block
  4. /execute if score #tick c9_timer matches 80 run setblock ~-1 ~4 ~ redstone_block
  5. /execute if score #tick c9_timer matches 0..79 run particle dust{color:[0.1,1.0,0.2],scale:1.5} ~-1 ~4 ~ 0.4 0.4 0.4 0 3 force
  6. /execute if score #tick c9_timer matches 80..159 run particle dust{color:[1.0,0.1,0.1],scale:1.5} ~-1 ~4 ~ 0.4 0.4 0.4 0 3 force
  7. /execute if score #tick c9_timer matches 80..159 run particle dust{color:[1.0,0.2,0.2],scale:1.0} ~-3 ~0.2 ~ 0.1 0.1 1.4 0 8 force
  8. /execute if score #tick c9_timer matches 20 run summon villager ~-11 ~ ~-1 {NoAI:1b,Silent:1b,Rotation:[-90f,0f],Tags:["c9_vil"],VillagerData:{profession:"minecraft:farmer",level:2,type:"minecraft:plains"}}
  9. /execute if score #tick c9_timer matches 60 run summon villager ~-11 ~ ~1 {NoAI:1b,Silent:1b,Rotation:[-90f,0f],Tags:["c9_vil"],VillagerData:{profession:"minecraft:librarian",level:2,type:"minecraft:plains"}}
  10. /execute if score #tick c9_timer matches 100 run summon villager ~-11 ~ ~ {NoAI:1b,Silent:1b,Rotation:[-90f,0f],Tags:["c9_vil"],VillagerData:{profession:"minecraft:armorer",level:2,type:"minecraft:plains"}}
  11. /execute if score #tick c9_timer matches 0..79 as @e[type=villager,tag=c9_vil] at @s run tp @s ~0.12 ~ ~ ~ ~
  12. /execute if score #tick c9_timer matches 80..159 as @e[type=villager,tag=c9_vil] at @s unless entity @e[tag=c9_ctrl,dx=8,dy=4,dz=4] run tp @s ~0.12 ~ ~ ~ ~
  13. /execute positioned ~11 ~ ~ as @e[type=villager,tag=c9_vil,distance=..2] at @s run particle poof ~ ~1 ~ 0.2 0.4 0.2 0.02 5 force
  14. /execute positioned ~11 ~ ~ run kill @e[type=villager,tag=c9_vil,distance=..2]

How it works

Frames from the test run

Villager Traffic Light Intersection - frame 1Villager Traffic Light Intersection - frame 2Villager Traffic Light Intersection - frame 3

Recorded on our own test server: 58 frames at about 9.5 fps. Our image check saw: Villagers walk along a stone brick road beneath a cobblestone arch with an overhead signal block that changes between redstone red and emerald green with matching particles.

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 middle of a flat open area at least 25 blocks wide and run all 10 setup commands in chat to build the road, crosswalk, and traffic pole.
  2. Place a stack of 14 command blocks nearby: one Repeating Always Active block at the bottom followed by 13 Chain Always Active blocks pointing into each other.
  3. Paste each of the 14 loop commands in order into the command blocks, wrapping coordinates or placing the stack under the exact centre block where you stood.
  4. Watch the signal switch between green emerald and red redstone every four seconds while villagers spawn on the west end and obey the light.
  5. When finished, deactivate the repeating block and run the remove commands to clear the road and entities.

Use it with real players

To make the traffic light enforce rules on real players too, add a repeating command during the red phase (ticks 80..159) that applies slowness to any player standing in the stopping zone before the crosswalk: /execute if score #tick c9_timer matches 80..159 positioned ~-5 ~ ~ run effect give @a[distance=..2.5] slowness 1 10 true.

Remove it again 5 commands

  1. /kill @e[tag=c9_vil]
  2. /kill @e[tag=c9_ctrl]
  3. /fill ~-12 ~ ~-3 ~12 ~6 ~4 air
  4. /fill ~-12 ~-1 ~-2 ~12 ~-1 ~2 grass_block
  5. /scoreboard objectives remove c9_timer

FAQ

Why do the villagers have NoAI enabled?

Setting NoAI to 1b stops villagers from wandering off the road or turning their heads randomly, allowing the teleport loop commands to move them smoothly in straight lanes.

How can I make the green or red light last longer?

Increase the reset threshold in loop command 2 (currently 160 ticks, or 8 seconds) and adjust the tick ranges in the red light commands accordingly.

Commands used

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

Similar creations

Join 9Minecraft News & Guides