Minecraft – How to setup a clock in 1.9

minecraft-commandsminecraft-java-edition

enter image description here

Hello, I'm trying to set a clock but been having difficulties with the arrangement of the blocks and deciding which if the blocks are condition or unconditional setting. I am testing for a button being pressed thus activating following fill commands.

Commands in order:

/testforblock X Y Z minecraft:stone_button 
/fill X1 Y1 Z1 X2 Y2 Z2 minecraft:air
/fill X1 Y1 Z1 X2 Y2 Z2 minecraft:stone

In the repeating block there is no command and is working as a clock

enter image description here

In 1.8.9. I could set a clock connecting to a command block /testforblock -89 57 678 minecraft:stone_button 5 which means it's active/true. The comparator does not repeat the signal but still active the command block /say hey. Once the button is pressed the /testforblock block is inactive but is then active again because it is testing for the button that isn't pressed. I am trying to do this into 1.9.

Best Answer

Without the use of redstone and block updates, it can become a bit complicated to replicate it. You will need to check the SuccessCount value of the command block running the initial /testforblock command to determine when the block is no longer there. Image setup:

RCB > CCCB > CCB > CCCB > ICB

  1. The initial /testforblock command, checking for the stone button.

    /testforblock -89 57 678 minecraft:stone_button 5
    
  2. Conditional. If the /testforblock command succeeded, set the impulse command block (#5) to have an auto tag value of 1, which causes it to run its command. Unlike a repeating command block, it will only run its command a single time. auto has to be set back to 0 before it can activate again. Change "X Y Z" to the coordinates of the impulse block.

    /blockdata X Y Z {auto:1b}
    
  3. A secondary /testforblock that checks the SuccessCount tag value of the repeating command block. If the value was 0, that means the stone button was not at the location, which means the impulse command block must have auto set back to 0.

    /testforblock X Y Z minecraft:repeating_command_block -1 {SuccessCount:0}
    
  4. Conditional. If the SuccessCount value was indeed 0, set the impulse block's auto tag value to 0.

    /blockdata X Y Z {auto:0b}
    
  5. This would be the command you want to run a single time when the stone button is at the location, but will be able to run a single time again if the stone button were to be removed and placed back down.

    /say Test
    

The benefit of doing it this way is to reduce the number of block updates occur, as /blockdata does not create block updates. The reduction is good for server performance.