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]

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]


Is there any way into the Abandoned the Zelda Hebra Mine forge tower? Is there any way into the Abandoned the Zelda Hebra Mine forge tower?

Posted On: July 7, 2023
In the Abandoned Hebra Mine, on top of the forge construct tower there is some unusual smoke coming out of the chimney. Is there any way into this tower? Or is there nothing more to it?. I've d...[More]


Is shoving enemies supposed to make you an oath breaker? Is shoving enemies supposed to make you an oath breaker?

Posted On: June 9, 2025
I'm confused. Got into a conflict in act one with zarys and her goons. They initiate combat and my paladin shoved one of them off a cliff. Immediate oathbreaker. I reloaded and just killed them normal...[More]


Does Improved Catalyst increase self-damage from Rigged Bombs? Does Improved Catalyst increase self-damage from Rigged Bombs?

Posted On: August 20, 2023
The description for Improved Catalyst says that Bombs and Rigged Bombs will deal +10 damage. Normally Rigged Bombs deal 150 damage to enemies and 3 self damage to the player. Does Improved Catalyst...[More]


How do I reveal the bonus art in the Art Gallery? How do I reveal the bonus art in the Art Gallery?

Posted On: April 24, 2024
After using a key to open the first Concept Art room in the Art Gallery, I noticed some of the pictures were missing, displaying as a blue question mark. If I go to examine them, they are labeled as "...[More]


how exactly did nocturne become a woman? how exactly did nocturne become a woman?

Posted On: December 11, 2024
Not to be rude but im a divinity player interested in baulders gate so how exactly did it happen is it kinda like elder scrolls where a necromancer goes into a thingy becomes immoble eventually and th...[More]


How do I climb tall vertical shafts in Dead Cells? How do I climb tall vertical shafts in Dead Cells?

Posted On: April 6, 2023
I keep running into tall vertical shafts that I can't get past. There aren't any plant vines I can grow to climb up. How do I get up these shafts? Is there a wall jump upgrade I'm missing?...[More]


Why does my map have exclamation points marked on it? Why does my map have exclamation points marked on it?

Posted On: April 19, 2024
I have just started playing and some locations on my compass have an exclamation point marked and I have no idea what this is telling me. I have highlighted it below.What are these exclamation points ...[More]


How do you gauge the Near Pin Percent of a transaction? How do you gauge the Near Pin Percent of a transaction?

Posted On: January 23, 2023
In Recettear, when you're buying/selling, the tutorial gives you the base "range" of acceptable percents to offer to the customers. It seems that there's a magic number to put down in order to get the...[More]


What is the True Ending in Hogwarts Legacy? What is the True Ending in Hogwarts Legacy?

Posted On: July 19, 2023
What is the True Ending in Hogwarts Legacy after you've completed the main storyline? The answer in this question explains the main storyline endings, but I'm looking for the so-called &quo...[More]