How do I test if a block is anything but a certain block?

How do I test if a block is anything but a certain block? - Blood Sugar Meter and Sweets on the Blue Background

I would like to test for a player standing on anything apart from ice.

/execute @p ~ ~ ~ detect ~ ~-1 ~ minecraft:ice 0 


Best Answer

Write this:

/execute @p ~ ~ ~ testforblock ~ -1 ~ minecraft:ice

then link it with a comparator to a block with a redstone torch on the opposite side, then connect that to the command block saying what you want it to do.




Pictures about "How do I test if a block is anything but a certain block?"

How do I test if a block is anything but a certain block? - Brown and White Brick Wall
How do I test if a block is anything but a certain block? - White and Brown Brick Wall
How do I test if a block is anything but a certain block? - White shabby concrete wall with cracked stucco



How do I find a specific block in Minecraft?

The blank is for the particular block you are looking for. Let's say you're lost in the Nether and need to find your Nether Portal, you could type : /locateblock obsidian, and get the coordinates for the nearest obsidian, most likely being your, said, Portal.

How do you test a player on a particular block?

No item would drop and the block break would not be detected. If the player simply drops an item, a "block break" would be detected. If a mob dies and drops items, a "block break" would be detected. (But who knows, maybe you have a large bedrock room filled with nothing but sand; this solution would work.)



BLOCK BREAKING DETECTION!? -- Command Block Tutorial




More answers regarding how do I test if a block is anything but a certain block?

Answer 2

You can use a scoreboard objective to "invert" the command for multiple players and without needing a comparator

Create the objective using

scoreboard objectives add onIce dummy

Now, create a fill/setblock clock (do not use another clock!), and run the following two commands in order:

scoreboard players set @a onIce 0
execute @a ~ ~ ~ detect ~ ~-1 ~ minecraft:ice scoreboard players set @p onInce 1

Now, you can use the target selector argument score_onIce=0 to select only players not on ice, or score_onIce_min=1 for the opposite. For example,

testfor @a[score_onIce=0] 

will check if there are any players that are not currently on ice.

Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

Images: Nataliya Vaitkevich, Alex Tepetidis, Alex Tepetidis, Tatiana Syrikova