Using - execute command, how do I check if a block is one of multiple possibilities?

[BACK]
Using - execute command, how do I check if a block is one of multiple possibilities?
Posted On: April 8, 2024

Using an /execute command, I want to check if a certain block is, for example, either oak_fence, OR iron_bars.


However, in my specific case, I can't just use two command blocks to check for either one separately. I tried doing so, like this:.


/execute as @a[tag=tagA] at @s unless block ~ ~-1 ~ oak_fence run tag @s remove tagA.


/execute as @a[tag=tagA] at @s unless block ~ ~-1 ~ iron_bars run tag @s remove tagA.


Note: I set both command blocks to "Repeat", "Unconditional", and "Always active".


The result is not what I expected, because:.


if the block is oak_fence, the tag should be left on, however the second command removes it.


if the block is iron_bars, the tag should be left on, however the first command removes it.


What I need is to check, in a single command, for the tag to be removed only when the block is neither oak_fence OR iron_bars.


A possible solution I've thought of, but haven't tested yet, could be: setting up another 2 tags, check_oak_fence and check_iron_bars, which are given to players standing on either oak_fence or iron_bars.


/execute as @a[tag=!tagA] at @s if block ~ ~-1 ~ oak_fence run tag @s add check_oak_fence.


/execute as @a[tag=!tagA] at @s if block ~ ~-1 ~ iron_bars run tag @s add check_iron_bars.


And then checking for those 2 tags in the as portion of the /execute command, which apparently does permit an OR gate, like this:.


/execute as @a[tag=!check_oak_fence, tag=!check_iron_bars].


I also tested this question's only answer, modifying it so it checks the same block twice:.


/execute if block ~ ~-1 ~ oak_fence if block ~ ~-1 ~ iron_bars.


But that obviously can't work, because that's an AND gate, meaning it checks if a block is simultaneously two types of block at once, which is impossible, thus it can never return true.


Question from user Gaetano96 at gaming.stackexchange.com.


Answer:

You essentially want:.


not(OF or IB).


which, using De Morgan's law, is equal to:.


(not OF) and (not IB).


Giving that, you should be able to chain the last command you found, but with inverted conditions:.


/execute as @a[tag=tagA] at @s unless block ~ ~-1 ~ oak_fence unless block ~ ~-1 ~ iron_bars run tag @s remove tagA.


Answer from user pinckerman at gaming.stackexchange.com.


[BACK]
Using - execute command, how do I check if a block is one of multiple possibilities?
Posted On: April 8, 2024

Using an /execute command, I want to check if a certain block is, for example, either oak_fence, OR iron_bars.


However, in my specific case, I can't just use two command blocks to check for either one separately. I tried doing so, like this:.


/execute as @a[tag=tagA] at @s unless block ~ ~-1 ~ oak_fence run tag @s remove tagA.


/execute as @a[tag=tagA] at @s unless block ~ ~-1 ~ iron_bars run tag @s remove tagA.


Note: I set both command blocks to "Repeat", "Unconditional", and "Always active".


The result is not what I expected, because:.


if the block is oak_fence, the tag should be left on, however the second command removes it.


if the block is iron_bars, the tag should be left on, however the first command removes it.


What I need is to check, in a single command, for the tag to be removed only when the block is neither oak_fence OR iron_bars.


A possible solution I've thought of, but haven't tested yet, could be: setting up another 2 tags, check_oak_fence and check_iron_bars, which are given to players standing on either oak_fence or iron_bars.


/execute as @a[tag=!tagA] at @s if block ~ ~-1 ~ oak_fence run tag @s add check_oak_fence.


/execute as @a[tag=!tagA] at @s if block ~ ~-1 ~ iron_bars run tag @s add check_iron_bars.


And then checking for those 2 tags in the as portion of the /execute command, which apparently does permit an OR gate, like this:.


/execute as @a[tag=!check_oak_fence, tag=!check_iron_bars].


I also tested this question's only answer, modifying it so it checks the same block twice:.


/execute if block ~ ~-1 ~ oak_fence if block ~ ~-1 ~ iron_bars.


But that obviously can't work, because that's an AND gate, meaning it checks if a block is simultaneously two types of block at once, which is impossible, thus it can never return true.


Question from user Gaetano96 at gaming.stackexchange.com.


Answer:

You essentially want:.


not(OF or IB).


which, using De Morgan's law, is equal to:.


(not OF) and (not IB).


Giving that, you should be able to chain the last command you found, but with inverted conditions:.


/execute as @a[tag=tagA] at @s unless block ~ ~-1 ~ oak_fence unless block ~ ~-1 ~ iron_bars run tag @s remove tagA.


Answer from user pinckerman at gaming.stackexchange.com.


[BACK]

In EVE, What happens to skills in the training queue when an account reverts to alpha clone status? In EVE, What happens to skills in the training queue when an account reverts to alpha clone status?

Posted On: March 9, 2023
I have a bunch of skills queued to train, which includes advanced skills that an Alpha clone cannot train and several skills that are scheduled to start several days out. Since these two conditions ar...[More]


How do you clear all item drops in Minecraft? How do you clear all item drops in Minecraft?

Posted On: April 21, 2023
How do you clear all item drops in Minecraft? I want to have something activated by an Item landing on a golden pressure plate, but It can only be activated once. Is there any command block command...[More]


Lost in the Hogwarts School Lost in the Hogwarts School

Posted On: July 7, 2023
Does anyone get easily lost in the hogwarts school or is it just me?. Question from user Apprehensive_Ad832 at HogwartsLegacyGaming at reddit. Answer: I’m on my second play through and ...[More]


What is the Font Used in Pokemon Conquest? What is the Font Used in Pokemon Conquest?

Posted On: January 26, 2023
What's the font used in Pokemon Conquest's dialogue? More specifically, since I assume it's some proprietary font compiled in the game, where have I seen it before? It looked extremely familiar as soo...[More]


Is there a way to de-fuse weapons in Zelda Tears of the Kingdom? Is there a way to de-fuse weapons in Zelda Tears of the Kingdom?

Posted On: May 17, 2023
Sometimes I want to de-fuse a weapon because I've found a better component I want to add, or a better weapon to use that component. Is there a way to de-fuse a weapon or shield? Question from u...[More]


Sheathe wand Sheathe wand

Posted On: September 15, 2023
If there are going to be any dlc or a second game , i beg you game developers to make a button to sheathe the wand or to have it in your hand until you manually put it back . It is a nice little detai...[More]


How do you get to these chests in Hogwarts Legacy? How do you get to these chests in Hogwarts Legacy?

Posted On: August 22, 2023
In the gatehouse of the High Keep you can see a loft and Revelio reveals some chests up there but I can’t figure out how to reach them. It looks like you should be able to climb this pile of cra...[More]


Lost connection in clan war attack Lost connection in clan war attack

Posted On: July 3, 2023
I just finished deploying dragons in a clan war attack when the connection was lost. Looking at the replay, I see that the server only registered deploying the first few dragons, which resulted in ...[More]


How long do I need to survive on the Hyperbolica rocket skis? How long do I need to survive on the Hyperbolica rocket skis?

Posted On: May 9, 2023
In the Frosted Fields there is an inventor who created a pair of rocket skis. They ask you to prove the rocket skis are safe by testing them and surviving until they run out of fuel. How long do I ...[More]


Can you control what ore a drill harvests when its placed over multiple ores? Can you control what ore a drill harvests when its placed over multiple ores?

Posted On: January 5, 2024
I'm trying to harvest the maximum amount of uranium possible from a small patch. Unfortunately, there is a bordering coal patch nearby as well, and two of my electric mining drills are within rang...[More]