Minecraft – Stop command blocks on clock when sign clicked

minecraft-commandsminecraft-java-edition

I am making a one command creation which means that the command blocks are on a constant clock, I can make a sign on the front of it and I was wondering if there was a way to make it so if that sign is clicked they don't work until it is clicked again.

Best Answer

It's possible if your sign do a setblock to make appear a redstone_block next to one of the commands witch make the fill clock work. By keeping the clock command block activated it won't be able to continue looping.

But you will have to do many tests to find the good relative coordinates in the setblock and whenever you add a new command in your one command creation it make not work anymore since your sign may be at a different place so be shure to add it only when you have finished your one command.

To reactivate the clock you must add 3 commands on the sign:

  1. make disappear the redstone_block you made appear earlier to deactivate the clock.
  2. Make appear a air block between the 2 command blocks which makes the fill clock work.
  3. Make appear a redstone_block again between the 2 command blocks which makes the fill clock work.

Here is an example of the json needed to add multiple commands in 1 sign:

/give @p sign 1 0 {
    BlockEntityTag: {
        Text1: "{text:\" \\\/ \",color:\"gold\",bold:true,clickEvent:{action:\"run_command\",value:\"/setblock ... air\"}}",
        Text2: "{text:\"Click\",color:\"blue\",clickEvent:{action:\"run_command\",value:\"/setblock ... air\"}}",
        Text3: "{text:\"Here\",color:\"blue\",bold:true,clickEvent:{action:\"run_command\",value:\"/setblock ... redstone_block\"}}",
        Text4: "{text:\" /\\\ \",color:\"gold\",bold:true}"
    },
    display: {Name: "Custom Sign"}
}

It's almost the same if you want to do it with a /setblock or /blockdata command.