Command block says "get off the grass" if a player is on grass next to it
-
I want to make it so when any player comes onto the grass block the command block tells them to get off I think my problem is a misunderstanding of how the syntax works and how command blocks "communicate" with each other
The bottom command block: Impulse Unconditional Always active
execute if entity @a[distance=..15] run say "working?"
The top command block: Repeat Conditional Always active
execute as @a if block ~ ~-1 ~ minecraft:grass_block run say "off the grass"
-
You need to change the top command block to
chain unconditional always-active
and the bottom block torepeating unconditional always-active
. Other then that, I can see no other reason why you would be experiencing any issues.A few notes on how command blocks can "chain together".
1 : The arrow(s) on the side of the block indicate the direction the block is facing, and therefore which way it can chain.
2 : In order to create a chain you need an "initializer" block, which runs the first command that the next blocks need in order to function, and also triggers the rest of the chain. When this block runs, all the others run with it. Creating a "chain" of commands. Usually, this block is a repeating command block that is always active, but this is not necessary.
3 : All blocks need to be set to
Always Active
notRedstone Activated
. You can set them to this but it's messy and not recommended. If you want the chain to be togglable via redstone, set the first block toRedstone Activated
and attach your switch accordingly. And the chain will run normally.4 : When the block is set to
impulse
, it can only trigger once, then it is done.repeating
means it will constantly run as long as it either has a redstone pulse and it is set toRedstone Activated
or your tick rate is reasonable and it is set toAlways Active
. Thechain
setting allows you to build more advanced features by running many commands in a reliable order.5 : Command blocks don't really "communicate" per se. They can if you set up some
scoreboard
stuff and/or utilize a interesting tagging structure. Otherwise, the most communicating they will do is telling the next block to execute.