2

I'm new to command blocks and I was watching this garage door tutorial which uses the following command to implement a T Flip Flop, i.e. it alternates between success and failure upon each activation:

testforblock ~ ~ ~ minecraft:command_block -1 {SuccessCount:0}

However, I'm using Minecraft 1.16.5 - I'm aware that testforblock was removed in Minecraft 1.13 and onwards in favour of execute if.

I tried the following:

execute if block ~ ~ ~ minecraft:command_block{SuccessCount:0}

However this seems to result in continuous success, due to the missing dataValue (set to -1) in the original command. edit: -1 is the same as not specifying anything according to the wiki

The following doesn't work due to a syntax error:

execute if block ~ ~ ~ minecraft:command_block -1 {SuccessCount:0}

How can I implement a T Flip Flop using a command block in Minecraft Java Edition versions 1.13 and newer?

2
  • 2
    I've removed the minecraft-redstone tag. Implementing T flip-flop in redstone is pretty easy but completely different than doing it with command blocks.
    – SF.
    Commented Mar 22, 2021 at 13:22
  • @ExpertCoder14 I've updated the final line to indicate my question more clearly. Commented Mar 22, 2021 at 17:33

1 Answer 1

2

It seems like the technique used to test for a success count in previous versions does not work in 1.13+, due to unknown reasons.

To invert a score you can check if the score is not 1, and store the success of that check back to the same score:

execute store success score @s objective unless score @s objective matches 1

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.