Article Categories
- Baldur's Gate 3
- Diablo
- Elder Scrolls
- General
- Hogwarts Legacy
- League of Legends
- Minecraft
- Pokemon Go
- Sims 4
- StarCraft
- Steam Platform
- Xbox Game Console
More Articles
Using - execute command, how do I check if a block is one of multiple possibilities?
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
/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.
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
/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.
What is the True Ending in Hogwarts Legacy?
How are the structure decks in Yu-Gi-Oh 5Ds World Championship 2010: Reverse of Arcadia unlocked?
Will a Star Fragment disappear if I use fast travel in Tears of the Kingdom?
Villager breeder not working, showing angry particles: 1.17.1
What language is Space Engineers programmed in?
Bad graphics in Hogwarts Legacy
Marked as a quest item. Reading it never updated my journal?
How do I find: inactive jump gate At the beginning of Kingdoms End in X4: Foundations?
What is the Font Used in Pokemon Conquest?



