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. Mar 22 at 13:22
  • @ExpertCoder14 I've updated the final line to indicate my question more clearly. – David Bailey Mar 22 at 17:33
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.

I have found a solution which unfortunately involves an arbitrary storage location (scoreboard) but works:

execute store success score @p test run execute if score @p test matches 0

You will have to set up a scoreboard objective named test and have this command store its success in the score.


P.S. For all you command gurus out there who want me to remove run execute from my command, I would prefer to keep run execute in on this command because my practice is to keep it in only for the last subcommand.

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.