Build an /execute chain: as, at, positioned, if block, if entity — and a final command. Java Edition.
The /execute command does nothing on its own — it changes the execution context and then runs another command at the end. It is the foundation of conditional and command-block mechanics.
Conditions build up in a chain: as picks the executor, at changes the position, and if/unless test conditions and either continue or abort the chain.
Order matters: conditions apply left to right, and each step builds on the previous one.
Add the conditions you need — they assemble into a chain.
Configure each condition's arguments.
Type the command to run at the end of the chain.
Copy the result.
Usually a condition fails and the chain aborts. Check the order: a block check must come after the position is set, otherwise it inspects the wrong spot.
The trailing command defines what actually happens. It can give an item, teleport, print a message, or change a block.