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 Hollow Knight, What is the creature that appears after beating False Knight? In Hollow Knight, What is the creature that appears after beating False Knight?

Posted On: February 16, 2023
Immediately after beating False Knight in Steel Soul mode this thing popped up and started scurrying away slowly: .What is it? I seem to be able to knock it around, but once I stop it quickly gets up ...[More]


How do I trigger the effect of the new item, Enduring Brooch? How do I trigger the effect of the new item, Enduring Brooch?

Posted On: November 21, 2023
According to the description in the game for the Enduring Brooch, it's:. A brooch that will prevent you from going down once per battle. But what exactly does it mean by "going down?&qu...[More]


Whats the best possible score on the credits mini game? Whats the best possible score on the credits mini game?

Posted On: November 7, 2023
In the credits minigame you get a point for every name you hit and lose points whenever an enemy hits you. Since there's only a limited number of names to hit, what's the best possible score y...[More]


PS5 controller doesnt charge PS5 controller doesnt charge

Posted On: July 5, 2023
I have bought controller to use on PC. But when I connect it to USB to charge, orange light glows once and stops. If I connect it to Mac, it glows solid orange with white middle light. It should...[More]


Do the Illithid powers have any negative consequences? Do the Illithid powers have any negative consequences?

Posted On: August 11, 2023
Throughout the game, you can improve your hidden Illithid Powers skilltree by consuming more mindflayer worms. You also get [Illithid] skillchecks from time to time. However when you do either of t...[More]


lost my honour mode run in the most embarrassing way ever lost my honour mode run in the most embarrassing way ever

Posted On: January 17, 2025
So, here I am. .I have just defeated the emerald grove or whatever it's called and am now looting the empty goblin camp. It's really dark so I walk with a torch equipped in my hand and see some crate...[More]


How can I jump across the bridge? How can I jump across the bridge?

Posted On: December 30, 2023
I'm playing Half-Life 2 Episode 2 and I need to get this car to the other side of the bridge. Perhaps I'm missing something dead obvious, but how on earth do I do this? It seemed some in-ga...[More]


Is there anyway to help a pinned down teammate? Is there anyway to help a pinned down teammate?

Posted On: June 12, 2023
A reoccurring theme in the game is you will often get jumped by a hostile who will pin you to the ground and pummel you until you mash a button enough times to get them off of you. If this happens to ...[More]


I beg your pardon? I beg your pardon?

Posted On: August 30, 2025
She just,,,,teleported back up?? It didn't say she used her special ability, homegirl just changed her mind.Question from user Unique_Interview_193 at BaldursGate3 at reddit.com.Answer:They added thin...[More]


Is there a way to easily spot unopened chests in Genshin Impact? Is there a way to easily spot unopened chests in Genshin Impact?

Posted On: February 20, 2023
I was looking at the Genshin Impact trophies I had left, and most of them are 'Open 100, 200, 300, 400 chests in the Area'. I did not note which chests I did or not open; so having a map th...[More]