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]

How does Health and Healing work in BattleBit Remastered How does Health and Healing work in BattleBit Remastered

Posted On: July 6, 2023
I am new to Battlebit Remastered and am a bit confused on how the healing works as it seems to be different from most traditional FPS games (especially Battlefield 4 which it seems to draw a lot of in...[More]


What build order should I use for Zerg in StarCraft 2? What build order should I use for Zerg in StarCraft 2?

Posted On: March 14, 2013
I'm familiar with the general mechanics of the game, but what's the best build order for the beginning of the game? Question from user McKay at gaming.stackexchange.com. Answer: An op...[More]


I deleted the portal to the end city in minecraft I deleted the portal to the end city in minecraft

Posted On: February 3, 2023
I was messing around with my Minecraft world and accidentally deleted the portal on the main end island that leads to the first end city (don't ask me how). Does anyone know how I can put it ba...[More]


Is there a way to not kill rolan? Is there a way to not kill rolan?

Posted On: February 27, 2026
I killed loroakan and rolan just immediately attacked me. Is there anyway to avoid that? I don't like killing people i saved previously.Question from user pillar_of_nothing at BaldursGate3 at reddit.c...[More]


How does the Hard Light Swords damage scale with gun marks? How does the Hard Light Swords damage scale with gun marks?

Posted On: April 7, 2023
The Hard Light Sword's description says it "Deals critical damage depending on the number of gun marks on the target". How exactly does the damage scaling work? How much extra damage get...[More]


How can I disable use of a macro if a spell is on cooldown? How can I disable use of a macro if a spell is on cooldown?

Posted On: January 29, 2023
As a Shadow Priest, I use a macro to announce to those nearby who I'm casting Power Infusion on. I do this for clarity in a raid and Mythic+ setting. It works fairly well.The problem I'm encountering ...[More]


In Lost Ruins, Does the Goblin Shamans Mask work on Rosies second form? In Lost Ruins, Does the Goblin Shamans Mask work on Rosies second form?

Posted On: March 26, 2023
The description for the Goblin Shaman's Mask says it increases damage to goblins and orcs by 50%. Does this include Rosie's second form during her boss fight when she transforms into a goblin?...[More]


How do I check if the HD textures are correctly loaded? How do I check if the HD textures are correctly loaded?

Posted On: February 15, 2023
Is there a way to check if the HD textures of Skyrim are correctly loaded in the game? I installed them without an error, but I'm not quite sure whether they are actually active, as I can't re...[More]


This happened when giving Karlach a soul coin in Act 3 This happened when giving Karlach a soul coin in Act 3

Posted On: November 13, 2025
I recently posted about a scene that happens if you have Karlach consume a soul coin after transforming into an Illithid. It was requested I provide a video, so after far too much frustration to get t...[More]


Minecraft 1.16 Nether Fortress Location - Generation Minecraft 1.16 Nether Fortress Location - Generation

Posted On: June 20, 2023
The new Nether update has been released. I am asking about what is known about how the generation of nether fortresses will've been affected by this update. My old strategy for quickly locat...[More]