What are If Not Statements for Minecraft Bedrock Edition

If not statements in commands allow you to test whether or not an event is true. These can be used in both functions and regular command blocks. You are not required to use this method for scoring. Use the! operator to see if someone does not have a specific score. This is extremely beneficial for developing advanced command systems in your domains.

 

Non-Score Examples:
- Testing if someone is NOT on top of or relatively positioned to a certain block
- Testing if a block is NOT placed in a certain location
- Testing if a certain entity is NOT near another entity
- Testing if a player does NOT have a certain item
- Testing if a player is NOT standing inside a rectangular selected area (dx,dy,dz)
- Testing if a player is NOT standing in multiple areas located in different locations

 

For each event you need to create a boolean objective. In this example I will create one called onBedrock to test if a player is or is NOT on top of a bedrock block. You will need to set up this chain:

scoreboard players set @a onBedrock 0
execute @a ~~~ detect ~~-1~ bedrock 0 scoreboard players set @s onBedrock 1

FALSE: onBedrock = 0
TRUE: onBedrock = 1

You begin with the assumption that the event is false for everyone in this statement. Then, in the second command, you execute the command that causes the event to occur. When someone stands on top of a bedrock block, their score is set to 0, but in an instant, the second command runs, making their score 1 (true), negating the first command and making it appear as if it never happened. When someone steps off the bedrock block, their score is reset to 0, but the second command has no effect.

 

To do this for the other examples, simply change the second command that makes the event true.