Minecraft-Java-Edition,Minecraft-Commands – How to Make Command Block Output a Negative Signal

minecraft-commandsminecraft-java-edition

Im trying to make a wave spawn kind of thing and i would like a command block to activate its comparator redstone signal when the command blocks command is negative.

I tried this using /testfor @e[type=!Zombie] but that does not work as it detects the player or any other mob. any way to do this without a redstone torch ?

Best Answer

One way to do this is to have a second command block testing if the previous one failed:

Chain command block leading off of an impulse command block

The impulse command block would have your current command (/testfor @e[type=Zombie]).

The chain command block, which is the one you should run comparators/conditionals off of, would then have:

/testforblock X Y Z command_block -1 {SuccessCount:0}

X Y Z should be the coordinates of the impulse command block.

This makes the chain block succeed when the impulse block fails.