Commands
How to Use the /execute Command
/execute is the most powerful command in Minecraft because it reshapes the context for any other command. Learn to read the clause chain, as @a at @s run …, and you can run anything from anyone, anywhere.
Read it like a sentence
- 1Start with /executeType /execute on its own. It does nothing yet, it is a wrapper that changes the context for the command you attach at the end.
- 2Add an “as” clauseas @a sets the executor to every online player, one run each. Use @e[type=zombie] or @p to target other entities instead.
- 3Add an “at” clauseat @s moves the execution position to wherever the current executor stands, so relative ~ ~ ~ coords resolve from them.
- 4Filter with conditionalsChain if/unless to gate the command, e.g. if block ~ ~-1 ~ minecraft:water before the run clause.
- 5End with runrun is always last. Everything after it is the actual command: run tp @s ~ ~5 ~ or run particle flame ~ ~1 ~.
What you need
Command block or chat
as / at clauses
@s & @a selectors
run subcommand
Quick answers
?
What does /execute actually do?
It runs another command in a modified context, a different executor (as), position (at), rotation (rotated), or dimension (in). The command after run is what runs.
?
What is the difference between as and at?
as changes WHO runs the command (@s and selectors update). at changes WHERE it runs from (relative coords and ^ local coords resolve there). You usually want both: as @a at @s.
?
What does @s mean inside /execute?
@s refers to the current executor of that clause. After as @a, @s is each individual player in turn, which is why as @a at @s is the standard player loop.
?
Can I chain more than one condition?
Yes. Stack as many if and unless clauses as you like before run, e.g. /execute as @a if entity @s[scores={kills=1..}] run say got a kill.
?
What replaced the old /execute syntax?
Since Java 1.13 the command uses subcommands (as, at, run) instead of the legacy /execute <target> <pos> <command> form. Old syntax no longer works.
?
How do I store a result in a scoreboard?
Use store: /execute store result score @s health run data get entity @s Health writes the command's output into a fakeplayer or score.