2

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.

4

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.

0

IronAnvil's answer is spot on when it comes to command block contraptions. Minecraft is at a point where there just is no need for any redstone in command block contraptions at all (in fact, you don't even need command blocks anymore when using functions). However the question may arise for normal survival or non-command-block gameplay as well.


There is a plethora of clock designs in minecraft with vastly different properties. There probably is a compact, unload-friendly 4-output clock somewhere (in fact, it appears it's in the edit of IronAnvil's answer... oh well), however I just want to address your specific approach. Unless I missed something important, there is actually no need for the pistons you are using when working with a redstone pulse to begin with.

The probably easiest solution if you need a simple clock, that however is not very resource-friendly nor elegant, is a closed loop of repeaters with the four (or however many) outputs taken from evenly spread points in the loop. It uses a redstone pulse propagating through the repeater loop. In order to start the clock you have to insert a short (enough) pulse into the loop. This can be done by placing a button somewhere on the loop and pressing it or use a lever and flick it very quickly if the pulse length of a button is too long.

repeater loop clock A repeater loop clock. Four outputs (represented by the lamps) can be taken from the four corners, however more outputs are possible. The button in the lower right corner was used to introduce the pulse into the loop.

The advantage of this design is that you can take as many outputs as you want and you can also have uneven intervals between the outputs by not spreading them evenly over the loop. Additionally there is some flexibility with the clock rate by fine-tuning the repeater delay.

The disadvantages are that it takes a lot of repeaters for longer clock cycles. I am pretty sure that this design does not have any specific issue with chunk-unloading, however having it span across several chunks always can introduce unwanted behaviour.

Note that the hopper clock shown in IronAnvil's answer is certainly more elegant to this one. The big advantage of the redstone loop clock is that it's very easy to set-up and memorize.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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