/execute
op 2Technical/execute does not do anything by itself: it changes the context another command runs in. Each clause rewrites one part of that context — who is running (as), where from (at), which way they face (rotated), or whether to continue at all (if / unless). Clauses apply left to right, and the command after run is what finally executes.
- Add a command to run at the end of the chain.
Leave this empty only if you want the chain to report whether its checks passed — useful with store, but it will not run anything.
Examples
- Run as every player
/execute as @a run say hello - Only when standing on stone
/execute as @a at @s if block ~ ~-1 ~ stone run effect give @s speed 1 1 - Capture a count into a score
/execute store result score @s zombies run execute if entity @e[type=zombie]
Common questions about /execute
›What is the difference between as and at?
as changes who runs the command, so @s becomes that entity. at changes the position, rotation and dimension it runs from. Most chains need both: execute as @a at @s run ….
›Why does my execute do nothing?
Usually a condition never matches, or as was used without at, so the command still runs at the original position. Chain them: as @a at @s.
›How do I count entities into a scoreboard?
execute store result score <holder> <objective> run execute if entity <selector>. The inner execute returns how many entities matched, and store captures it.
›Can I chain several conditions?
Yes. Add as many if and unless clauses as you like — they all have to pass. There is no or; use two separate commands, or a predicate, for that.