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 . edit: dataValue
(set to -1
) in the original command-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?
Best Answer
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:
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 keeprun execute
in on this command because my practice is to keep it in only for the last subcommand.