How to I /setblock repeaters facing different directions?

I want to know how I can use /setblock to spawn repeaters facing different directions. Like if I wanted to have a repeater facing east what command do I write?


You can set a block to repeater via this command:

/setblock ~ ~ ~ minecraft:unpowered_repeater  

That places a repeater facing north, with a one tick delay. If you want to create a different repeater you have to calculate a datavalue, with this formula:

datavalue = direction + (4 * delay)

Where the delay goes from 0 to 3, and the direction goes like this:

  • 0: North
  • 1: East
  • 2: South
  • 3: West

For example, if you want to create a repeater facing east with the least amount of delay you calculate:

datavalue = 1 + (4 * 0) = 1

To then create that repeater execute this command:

/setblock ~ ~ ~ minecraft:unpowered_repeater 1