How do you make a redstone clock that has four outputs and doesn't break when leaving/returning to the chunk?

I'm trying to make a block cycle between four colors of wool with about 3 seconds in between each color. I built a four output circuit hooked up to four command blocks:

Piston clock

This is the design I was using but sometimes when I unloaded the chunks a piston would get stuck on powered without actually powering. I was wondering if there was a good four output timer that doesn't break when getting unloaded.


You can use Sethbling's four output hopper clock. These clocks use the duration it takes to move a specific stack of items between hoppers. I built one to get the timing for you. You would have to place a stack of any 6 items (that can be stacked to 64) in one hopper to get about 3 second durations.
Hopper clock

In the image you can see two repeaters on at once, this will always be the case. It will not be a problem as you are pulsing impulse command blocks. It will work properly.

As noted by Fabian's bug mention in the comments, it would be best to make sure this entire circuit is inside one chunk. You can toggle the chunk borders by pressing F3 + G. Another option would be to contain it all in the spawn chunks so it never unloads.


However

It is highly recommended to never rely on redstone in command block creations because of problems like that bug. When something needs to be timed on an interval, a scoreboard timer is a very good way to accomplish this. This involves creating a dummy scoreboard objective and repeatedly adding to it's value. This value can then be used as a timer.


Marker Armor Stand

In my example, the scoreboard timer value will be stored to an armor stand. This armor stand is also used to mark where the wool block will be. Go stand in the exact block you want the changing wool block to be and use the command:

/summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,CustomName:"BlockMarker"}

The armor stand will be invisible and invulnerable. To test that you got it in the right location, run command:

execute @e[type=armor_stand,name=BlockMarker] ~ ~ ~ setblock ~ ~ ~ minecraft:wool 0

If you need to get rid of it because it is in the wrong location, use the command:

/kill @e[type=armor_stand,name=BlockMarker]

Scoreboard timer

You have to manually create the scoreboard objective:

/scoreboard objectives add Timer dummy

Then we need a Repeat Unconditional Always Active command block to add to that value with command:

scoreboard players add @e[type=armor_stand,name=BlockMarker] Timer 1

Set block and reset timer

The previous command block will add one to the value every game tick which works out to about 20 ticks a second. You want it to change every three seconds which means 60 ticks.

All the following commands will be in command blocks that are chained after the repeating command block. They will all be Chain Unconditional Always Active. There will be a total of 5 chain blocks for a total of 6 command blocks in one chain.

The first four chain blocks will contain the 4 setblock commands which change the color of the wool block. The setblock commands will be run using execute commands as this allows the timer to be tested and the setblock to be run at the location of the armor stand for placement of the wool block. These commands are:

execute @e[type=armor_stand,name=BlockMarker,score_Timer_min=0,score_Timer=60] ~ ~ ~ setblock ~ ~ ~ minecraft:wool 0

execute @e[type=armor_stand,name=BlockMarker,score_Timer_min=61,score_Timer=120] ~ ~ ~ setblock ~ ~ ~ minecraft:wool 1

execute @e[type=armor_stand,name=BlockMarker,score_Timer_min=121,score_Timer=180] ~ ~ ~ setblock ~ ~ ~ minecraft:wool 2

execute @e[type=armor_stand,name=BlockMarker,score_Timer_min=181,score_Timer=240] ~ ~ ~ setblock ~ ~ ~ minecraft:wool 3

As you see, the scores are all a range of 60 ticks. You could change the values to be shorter or longer durations. You can change the data values to change the wool colors to whatever you like. You could also add more blocks to have more then 4 colors.

The last chain block is used to reset the timer so it can start all over again. It's command:

execute @e[type=armor_stand,name=BlockMarker,score_Timer_min=241] ~ ~ ~ scoreboard players reset @e[type=armor_stand,name=BlockMarker] Timer 

This will set a wool block at the base of the invisible armor stand and change it's color every three seconds.