17

Often, when asking about command block contraptions, people suggest using a "setblock" or "fill" clock?

What are those and how do I make them?

1
  • I often tell people to do this, and I always wanted to have a good reference for it to link to.
    – MrLemon
    Commented Jul 7, 2015 at 15:16

1 Answer 1

17

First off, if you are playing in Minecraft 1.9 or later, you don't need to use these clocks. Repeating and chain command blocks have the same functionality (see below) and more, and are much easier to use. Use them instead.

What are those?

A setblock or fill clock is a command block contraption based on using the /setblock or /fill commands to alternately set redstone blocks and regular blocks in the same spot, therefore activating adjacent command blocks 20 times a second. They are therefore also referred to as "20Hz" clocks.

They are extremely useful for making command block contraptions for multiple reasons:

  • Faster than any redstone based clock.
  • Well-defined execution order: This may seem odd, but while every command is executed at the same time, the placement of the command blocks still determines the order this happens in.
    This allows you to, for example, set a scoreboard objective to 0 for everyone, and to 1 for certain players directly afterwards, without their score "flickering".
  • Virtually lag-free: Redstone dust is laggy, mostly due to block updates and lighting updates around it. Don't use redstone dust. Just don't. A setblock/fill clock has no lighting updates, and few block updates. By a similar logic, you should limit your use of comparators and repeaters, even though they're not quite as bad as redstone dust.

How do I make them?

Both clocks require two command blocks as a base. One to set the redstone blocks, the other to set the regular block.

Setblock clock

A setblock clock is slightly simpler than it's larger cousin. It creates and destroys a single redstone block between the two command blocks.

Place two command blocks in a line, with a single free space in between. Remember what I said about the well-ordered execution earlier? This is based on the (relative) coordinates the command blocks are placed in, so let's find out!

Press F3 to enter the debug screen. If you are playing on 1.8+ and the gamerule reducedDebugInfo is false (the default), your cursor turns into a red green and blue thingy. This tells you the direction of the three major coordinate axes. Red points towards positive X, Green towards positive Y and Blue towards positive Z, that is RGB corresponds to XYZ.

No matter how you oriented your command blocks, locate the one at the lower coordinate and set it to

/setblock ~1 ~ ~ stone

In the other one, put

/setblock ~-1 ~ ~ redstone_block

This example is for the X-axis, for another axis, move the ~1 and ~-1 to the corresponding position in the setblock command, e.g. ~ ~ ~1/~-1 for the Z-axis. I used smoothstone as my alternate block, but you can use any other solid, non-transparent block (transparent blocks, including air blocks, would cause lighting updates!).

Place a redstone block in the center to jump-start the clock. If everything is done correctly, this block is immediately recreated when you break it.

setblock clock

You can now place up to 4 other command blocks next to the redstone block. Command blocks on the same axis activate from lower to higher coordinate. The execution order can be more difficult when working on different axes at the same time though. If more than two of your commands require to be run in a specific order, I suggest using a fill clock instead.

Fill clock

A fill clock uses the same basic principles as the setblock clock, but allows for more commands to be run by creating a line of redstone blocks rather than a single block.

Instead of the commands above, use (again, command blocks along the X-axis)

/fill ~1 ~ ~ ~1 ~ ~4 stone
/fill ~-1 ~ ~ ~-1 ~ ~4 redstone_block

This creates a 1 block wide, 5 block long line of redstone blocks along the z-axis. The length is determined by the second set of coordinates.

Place your other commands along this line. The activation order will be along this line: At every redstone block the command block at the lower coordinate will be executed first. Afterwards, this continues at the next redstone block in the line.

fill clock

Wait, what? How does that work?

The way this works is that at the beginning of every game tick, the game sees a newly created redstone block next to the command blocks, and starts to execute the commands. It always starts at the lower coordinate, so it replaces the redstone block with stone. Directly afterwards, the second command is executed. While the command block is technically not powered at the moment, it was triggered and runs, immediately re-replacing the stone with a redstone block. Rinse and repeat 20 times a second.

6
  • 1
    Note, to reduce lag with a fill clock and make it more customizable, you could add 0 replace stone 0 after /fill ~1 ~ ~ ~1 ~ ~4 redstone_block and add 0 replace stone 0 after /fill ~-1 ~ ~ ~-1 ~ ~4. Then add the redstone blocks that you want to use in the fill area and remove the ones you don't want. Commented Jul 7, 2015 at 15:52
  • 1
    Also never use air in the place of the stone. It causes lag. Commented Jul 7, 2015 at 15:58
  • 1
    Personally, I prefer to have my fill clock command blocks vertical since then I don't have to worry which direction is positive X.
    – MBraedley
    Commented Jul 7, 2015 at 22:29
  • And you don't need to use 2 command blocks for a setblock clock, you can use seblock ~ ~1 ~ redstone_block 0 destroy and it will destroy the block above it and replace it with a redstone block all in once command. Do note that this does create particles which may lag slow machines.
    – Shadowtrot
    Commented Jul 8, 2015 at 5:13
  • Faster than any redstone based clock. Just not, pure redstone can reach 20Hz, but just no survival-obtainable thing can handle it
    – l4m2
    Commented May 28, 2018 at 5:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.