Skip to main content
MC COMMANDS logoMC COMMANDS
Command Reference

Minecraft /execute Command

developerJavaBedrock

Executes a command using modified context: changing the executor entity (as), position (at / positioned), rotation, dimension, or evaluating complex conditions (if / unless).

Version Compatibility

Java Edition:1.21.4 (1.13+)
Bedrock Edition:1.21.60

Command Syntax

Java Edition/execute <subcommands...> run <command>
Bedrock Edition/execute <subcommands...> run <command>

Arguments Explained

Practical Examples

intermediateBoth
/execute as @a at @s if block ~ ~-1 ~ minecraft:water run effect give @s speed 5 1 true

Gives speed boost to players who are currently standing on top of water.

Detecting ground blocks beneath players.

intermediateBoth
/execute as @e[type=cow] at @s run summon lightning_bolt

Strikes a lightning bolt at every cow in loaded chunks.

Changing both identity and position context.

intermediateJava
/execute in minecraft:the_nether run tp @s 0 64 0

Teleports the player to coordinates 0, 64, 0 in the Nether dimension.

Cross-dimensional teleportation.

advancedJava
/execute store result score @p CoinCount run clear @p gold_nugget 0

Counts how many gold nuggets a player holds and stores the number in their CoinCount scoreboard.

Querying inventory amounts into variables without removing items.

advancedBoth
/execute at @e[type=arrow] if block ~ ~-0.5 ~ minecraft:sand run setblock ~ ~-0.5 ~ minecraft:glass

Turns sand into glass wherever an arrow lands.

Dynamic projectile impact mechanics.

Advertisement

Common Mistakes

Mistake:

Confusing "as" and "at": using "as @a" expecting relative coordinates ~ ~ ~ to match the player

Fix:

"as" only changes who @s is. To shift coordinates, you must also specify "at @s": /execute as @a at @s run ...

Mistake:

Forgetting the mandatory "run" keyword before the final command

Fix:

Every modern /execute chain must terminate with "run <command>".

Mistake:

Creating infinite command loops in Repeating Command Blocks that crash the server

Fix:

Add a tag filter (e.g. @e[tag=!processed]) and tag the entity inside the command loop to prevent repeat execution.

Command Block Usage & Automation

The cornerstone of command block logic. Run a Repeating Always Active command block with "/execute as @a at @s if block ~ ~-1 ~ slime_block run effect give @s jump_boost 2 3 true" to create custom trampoline jump pads, or use conditional chain blocks following execute checks to only advance storylines when a puzzle condition is met.

Automation Tip: Command blocks require Operator permissions (permission level 2+) and cheats enabled. In Java Edition, command blocks can execute commands up to 32,767 characters long compared to the 256-character player chat limit.

Useful Tips

  • Use "align xyz" after "positioned" to snap floating decimal coordinates to the nearest block corner.

  • Combine "if entity @a[distance=..5]" to build reliable proximity triggers without bulky redstone sensors.

  • Store command success (/execute store success score ...) to build binary true/false switches in scoreboards.

Important Notes

In Bedrock Edition 1.19.50+, the modern Java-like execute syntax was standardized. Older Bedrock syntax (/execute <origin> <pos> <command>) is deprecated and should not be used in modern worlds.

Frequently Asked Questions

Ready to build your command?

Use our interactive generator to create error-free /execute commands with a visual interface.

Open Command Generator
Advertisement