News
Game
Guides
Downloads
Versions
/execute
COMMANDS COMMAND BLOCKS & MAPS CHEATS · LEVEL 2 14 SUBCOMMANDS Added in 1.14 or earlier

/execute command in Minecraft

/execute runs another command in a changed context: as another entity, from another position or dimension, or only when a test succeeds. It can also save the result of that command in a score or in NBT data. Almost every map and data pack depends on it.

Syntax

/execute (align|anchored|as|at|facing|if|in|on|positioned|rotated|run|store|summon|unless)
All 154 forms
  • /execute align <axes> …
  • /execute anchored <anchor> …
  • /execute as <targets> …
  • /execute at <targets> …
  • /execute facing entity <targets> <anchor> …
  • /execute facing <pos> …
  • /execute if biome <pos> <biome>
  • /execute if biome <pos> <biome> …
  • /execute if block <pos> <block>
  • /execute if block <pos> <block> …
  • /execute if blocks <start> <end> <destination> all
  • /execute if blocks <start> <end> <destination> all …
  • /execute if blocks <start> <end> <destination> masked
  • /execute if blocks <start> <end> <destination> masked …
  • /execute if data block <source> <path>
  • /execute if data block <source> <path> …
  • /execute if data entity <source> <path>
  • /execute if data entity <source> <path> …
  • /execute if data storage <source> <path>
  • /execute if data storage <source> <path> …
  • /execute if dimension <dimension>
  • /execute if dimension <dimension> …
  • /execute if entity <entities>
  • /execute if entity <entities> …
  • /execute if function <name> …
  • /execute if items block <source> <slots> <item_predicate>
  • /execute if items block <source> <slots> <item_predicate> …
  • /execute if items entity <source> <slots> <item_predicate>
  • /execute if items entity <source> <slots> <item_predicate> …
  • /execute if loaded <pos>
  • /execute if loaded <pos> …
  • /execute if predicate <predicate>
  • /execute if predicate <predicate> …
  • /execute if score <target> <targetObjective> < <source> <sourceObjective>
  • /execute if score <target> <targetObjective> < <source> <sourceObjective> …
  • /execute if score <target> <targetObjective> <= <source> <sourceObjective>
  • /execute if score <target> <targetObjective> <= <source> <sourceObjective> …
  • /execute if score <target> <targetObjective> = <source> <sourceObjective>
  • /execute if score <target> <targetObjective> = <source> <sourceObjective> …
  • /execute if score <target> <targetObjective> > <source> <sourceObjective>
  • /execute if score <target> <targetObjective> > <source> <sourceObjective> …
  • /execute if score <target> <targetObjective> >= <source> <sourceObjective>
  • /execute if score <target> <targetObjective> >= <source> <sourceObjective> …
  • /execute if score <target> <targetObjective> matches <range>
  • /execute if score <target> <targetObjective> matches <range> …
  • /execute if slots block <source> <slots>
  • /execute if slots block <source> <slots> …
  • /execute if slots entity <source> <slots>
  • /execute if slots entity <source> <slots> …
  • /execute if stopwatch <id> <range>
  • /execute if stopwatch <id> <range> …
  • /execute in <dimension> …
  • /execute on attacker …
  • /execute on controller …
  • /execute on leasher …
  • /execute on origin …
  • /execute on owner …
  • /execute on passengers …
  • /execute on target …
  • /execute on vehicle …
  • /execute positioned as <targets> …
  • /execute positioned over <heightmap> …
  • /execute positioned <pos> …
  • /execute rotated as <targets> …
  • /execute rotated <rot> …
  • /execute run …
  • /execute store result block <target> <path> byte <scale> …
  • /execute store result block <target> <path> double <scale> …
  • /execute store result block <target> <path> float <scale> …
  • /execute store result block <target> <path> int <scale> …
  • /execute store result block <target> <path> long <scale> …
  • /execute store result block <target> <path> short <scale> …
  • /execute store result bossbar <id> max …
  • /execute store result bossbar <id> value …
  • /execute store result entity <target> <path> byte <scale> …
  • /execute store result entity <target> <path> double <scale> …
  • /execute store result entity <target> <path> float <scale> …
  • /execute store result entity <target> <path> int <scale> …
  • /execute store result entity <target> <path> long <scale> …
  • /execute store result entity <target> <path> short <scale> …
  • /execute store result score <targets> <objective> …
  • /execute store result storage <target> <path> byte <scale> …
  • /execute store result storage <target> <path> double <scale> …
  • /execute store result storage <target> <path> float <scale> …
  • /execute store result storage <target> <path> int <scale> …
  • /execute store result storage <target> <path> long <scale> …
  • /execute store result storage <target> <path> short <scale> …
  • /execute store success block <target> <path> byte <scale> …
  • /execute store success block <target> <path> double <scale> …
  • /execute store success block <target> <path> float <scale> …
  • /execute store success block <target> <path> int <scale> …
  • /execute store success block <target> <path> long <scale> …
  • /execute store success block <target> <path> short <scale> …
  • /execute store success bossbar <id> max …
  • /execute store success bossbar <id> value …
  • /execute store success entity <target> <path> byte <scale> …
  • /execute store success entity <target> <path> double <scale> …
  • /execute store success entity <target> <path> float <scale> …
  • /execute store success entity <target> <path> int <scale> …
  • /execute store success entity <target> <path> long <scale> …
  • /execute store success entity <target> <path> short <scale> …
  • /execute store success score <targets> <objective> …
  • /execute store success storage <target> <path> byte <scale> …
  • /execute store success storage <target> <path> double <scale> …
  • /execute store success storage <target> <path> float <scale> …
  • /execute store success storage <target> <path> int <scale> …
  • /execute store success storage <target> <path> long <scale> …
  • /execute store success storage <target> <path> short <scale> …
  • /execute summon <entity> …
  • /execute unless biome <pos> <biome>
  • /execute unless biome <pos> <biome> …
  • /execute unless block <pos> <block>
  • /execute unless block <pos> <block> …
  • /execute unless blocks <start> <end> <destination> all
  • /execute unless blocks <start> <end> <destination> all …
  • /execute unless blocks <start> <end> <destination> masked
  • /execute unless blocks <start> <end> <destination> masked …
  • /execute unless data block <source> <path>
  • /execute unless data block <source> <path> …
  • /execute unless data entity <source> <path>
  • /execute unless data entity <source> <path> …
  • /execute unless data storage <source> <path>
  • /execute unless data storage <source> <path> …
  • /execute unless dimension <dimension>
  • /execute unless dimension <dimension> …
  • /execute unless entity <entities>
  • /execute unless entity <entities> …
  • /execute unless function <name> …
  • /execute unless items block <source> <slots> <item_predicate>
  • /execute unless items block <source> <slots> <item_predicate> …
  • /execute unless items entity <source> <slots> <item_predicate>
  • /execute unless items entity <source> <slots> <item_predicate> …
  • /execute unless loaded <pos>
  • /execute unless loaded <pos> …
  • /execute unless predicate <predicate>
  • /execute unless predicate <predicate> …
  • /execute unless score <target> <targetObjective> < <source> <sourceObjective>
  • /execute unless score <target> <targetObjective> < <source> <sourceObjective> …
  • /execute unless score <target> <targetObjective> <= <source> <sourceObjective>
  • /execute unless score <target> <targetObjective> <= <source> <sourceObjective> …
  • /execute unless score <target> <targetObjective> = <source> <sourceObjective>
  • /execute unless score <target> <targetObjective> = <source> <sourceObjective> …
  • /execute unless score <target> <targetObjective> > <source> <sourceObjective>
  • /execute unless score <target> <targetObjective> > <source> <sourceObjective> …
  • /execute unless score <target> <targetObjective> >= <source> <sourceObjective>
  • /execute unless score <target> <targetObjective> >= <source> <sourceObjective> …
  • /execute unless score <target> <targetObjective> matches <range>
  • /execute unless score <target> <targetObjective> matches <range> …
  • /execute unless slots block <source> <slots>
  • /execute unless slots block <source> <slots> …
  • /execute unless slots entity <source> <slots>
  • /execute unless slots entity <source> <slots> …
  • /execute unless stopwatch <id> <range>
  • /execute unless stopwatch <id> <range> …
/execute align
/execute align <axes> …
ArgumentExpectsWhat it does
axesAxes (xyz)Axes rounded down to whole blocks, in any order: x, xz or xyz.
/execute anchored
/execute anchored <anchor> …
ArgumentExpectsWhat it does
anchoreyes / feeteyes or feet: the point that local coordinates ^ ^ ^ and facing start from.
/execute as
/execute as <targets> …
ArgumentExpectsWhat it does
targetsEntity selectorone or severalEntities that become the executor (@s). The rest of the chain runs once per entity.
/execute at
/execute at <targets> …
ArgumentExpectsWhat it does
targetsEntity selectorone or severalEntities whose position, rotation and dimension are used. The executor does not change.
/execute facing
/execute facing (entity|<pos>)
ArgumentExpectsWhat it does
targetsEntity selectorone or severalEntity to face; the anchor that follows picks its eyes or its feet.
anchoreyes / feeteyes or feet: the point that local coordinates ^ ^ ^ and facing start from.
posPosition (x y z)Coordinates, absolute (0 64 0), relative (~ ~1 ~) or local (^ ^ ^2).
All 2 forms
  • /execute facing entity <targets> <anchor> …
  • /execute facing <pos> …
/execute if
/execute if (biome|block|blocks|data|dimension|entity|function|items|loaded|predicate|score|slots|stopwatch)
ArgumentExpectsWhat it does
posBlock coordinates (x y z)Block coordinates to test, for example ~ ~-1 ~ for the block under the executor.
biomeID or #tag · biomeBiome ID or biome tag to test, for example minecraft:plains or #minecraft:is_ocean.
blockBlock testBlock to look for, with optional states or a tag, for example minecraft:chest or #minecraft:logs.
startBlock coordinates (x y z)First corner of the area that is compared.
endBlock coordinates (x y z)Opposite corner of the area that is compared.
destinationBlock coordinates (x y z)Lower north-west corner of the second area, the one it is compared with.
sourceBlock coordinates (x y z)What to read: block coordinates, an entity, a storage ID or a score holder, depending on the keyword before it.
pathNBT pathNBT path to test, such as Inventory[0] or Health. The test passes if the path exists.
dimensionDimensionDimension ID: minecraft:overworld, minecraft:the_nether or minecraft:the_end.
entitiesEntity selectorone or severalSelector to test. The check passes if at least one entity matches.
nameFunctionFunction or function tag to run. The test passes if it returns a value other than 0.
slotsSlotsSlot or range of slots, for example weapon.mainhand, armor.head or container.*.
item_predicateItem testItem to look for: an ID, a tag, * for any item, or an ID with component checks.
predicatePredicateID of a predicate file from a data pack, for example mypack:is_night.
targetScore holderoneScore holder whose score is tested: @s, a player name or a fake name.
targetObjectiveScoreboard objectiveObjective that holds the score being tested.
sourceObjectiveScoreboard objectiveObjective of the score it is compared with.
rangeRange (1..5)Accepted values: 5 exactly, 1..10 between, 10.. at least, ..3 at most. For stopwatches, in seconds.
idResource IDID of the stopwatch to test, created with /stopwatch create.
All 45 forms
  • /execute if biome <pos> <biome>
  • /execute if biome <pos> <biome> …
  • /execute if block <pos> <block>
  • /execute if block <pos> <block> …
  • /execute if blocks <start> <end> <destination> all
  • /execute if blocks <start> <end> <destination> all …
  • /execute if blocks <start> <end> <destination> masked
  • /execute if blocks <start> <end> <destination> masked …
  • /execute if data block <source> <path>
  • /execute if data block <source> <path> …
  • /execute if data entity <source> <path>
  • /execute if data entity <source> <path> …
  • /execute if data storage <source> <path>
  • /execute if data storage <source> <path> …
  • /execute if dimension <dimension>
  • /execute if dimension <dimension> …
  • /execute if entity <entities>
  • /execute if entity <entities> …
  • /execute if function <name> …
  • /execute if items block <source> <slots> <item_predicate>
  • /execute if items block <source> <slots> <item_predicate> …
  • /execute if items entity <source> <slots> <item_predicate>
  • /execute if items entity <source> <slots> <item_predicate> …
  • /execute if loaded <pos>
  • /execute if loaded <pos> …
  • /execute if predicate <predicate>
  • /execute if predicate <predicate> …
  • /execute if score <target> <targetObjective> < <source> <sourceObjective>
  • /execute if score <target> <targetObjective> < <source> <sourceObjective> …
  • /execute if score <target> <targetObjective> <= <source> <sourceObjective>
  • /execute if score <target> <targetObjective> <= <source> <sourceObjective> …
  • /execute if score <target> <targetObjective> = <source> <sourceObjective>
  • /execute if score <target> <targetObjective> = <source> <sourceObjective> …
  • /execute if score <target> <targetObjective> > <source> <sourceObjective>
  • /execute if score <target> <targetObjective> > <source> <sourceObjective> …
  • /execute if score <target> <targetObjective> >= <source> <sourceObjective>
  • /execute if score <target> <targetObjective> >= <source> <sourceObjective> …
  • /execute if score <target> <targetObjective> matches <range>
  • /execute if score <target> <targetObjective> matches <range> …
  • /execute if slots block <source> <slots>
  • /execute if slots block <source> <slots> …
  • /execute if slots entity <source> <slots>
  • /execute if slots entity <source> <slots> …
  • /execute if stopwatch <id> <range>
  • /execute if stopwatch <id> <range> …
/execute in
/execute in <dimension> …
ArgumentExpectsWhat it does
dimensionDimensionDimension ID: minecraft:overworld, minecraft:the_nether or minecraft:the_end.
/execute onAdded in 1.19.4
/execute on (attacker|controller|leasher|origin|owner|passengers|target|vehicle)
All 8 forms
  • /execute on attacker …
  • /execute on controller …
  • /execute on leasher …
  • /execute on origin …
  • /execute on owner …
  • /execute on passengers …
  • /execute on target …
  • /execute on vehicle …
/execute positioned
/execute positioned (as|over|<pos>)
ArgumentExpectsWhat it does
targetsEntity selectorone or severalEntity whose position is used, without its rotation or its dimension.
heightmapHeightmapHeightmap that sets the height: world_surface, motion_blocking, motion_blocking_no_leaves or ocean_floor.
posPosition (x y z)Coordinates, absolute (0 64 0), relative (~ ~1 ~) or local (^ ^ ^2).
All 3 forms
  • /execute positioned as <targets> …
  • /execute positioned over <heightmap> …
  • /execute positioned <pos> …
/execute rotated
/execute rotated (as|<rot>)
ArgumentExpectsWhat it does
targetsEntity selectorone or severalEntity whose rotation is used, without moving the current position.
rotRotation (yaw pitch)Rotation as yaw and pitch, for example 90 0, or ~ ~ for relative values.
All 2 forms
  • /execute rotated as <targets> …
  • /execute rotated <rot> …
/execute run
/execute run …
/execute store
/execute store (result|success)
ArgumentExpectsWhat it does
targetBlock coordinates (x y z)Where the value goes: block coordinates, an entity or a storage ID, depending on the keyword.
pathNBT pathNBT path that receives the value, followed by its type: byte, short, int, long, float or double.
scaleNumberMultiplier applied before the value is stored, for example 0.01 or 100.
idResource IDID of the bossbar whose value or max receives the result.
targetsScore holderone or severalScore holders that receive the value: @s, @a, a player name or a fake name.
objectiveScoreboard objectiveObjective that receives the stored value.
All 42 forms
  • /execute store result block <target> <path> byte <scale> …
  • /execute store result block <target> <path> double <scale> …
  • /execute store result block <target> <path> float <scale> …
  • /execute store result block <target> <path> int <scale> …
  • /execute store result block <target> <path> long <scale> …
  • /execute store result block <target> <path> short <scale> …
  • /execute store result bossbar <id> max …
  • /execute store result bossbar <id> value …
  • /execute store result entity <target> <path> byte <scale> …
  • /execute store result entity <target> <path> double <scale> …
  • /execute store result entity <target> <path> float <scale> …
  • /execute store result entity <target> <path> int <scale> …
  • /execute store result entity <target> <path> long <scale> …
  • /execute store result entity <target> <path> short <scale> …
  • /execute store result score <targets> <objective> …
  • /execute store result storage <target> <path> byte <scale> …
  • /execute store result storage <target> <path> double <scale> …
  • /execute store result storage <target> <path> float <scale> …
  • /execute store result storage <target> <path> int <scale> …
  • /execute store result storage <target> <path> long <scale> …
  • /execute store result storage <target> <path> short <scale> …
  • /execute store success block <target> <path> byte <scale> …
  • /execute store success block <target> <path> double <scale> …
  • /execute store success block <target> <path> float <scale> …
  • /execute store success block <target> <path> int <scale> …
  • /execute store success block <target> <path> long <scale> …
  • /execute store success block <target> <path> short <scale> …
  • /execute store success bossbar <id> max …
  • /execute store success bossbar <id> value …
  • /execute store success entity <target> <path> byte <scale> …
  • /execute store success entity <target> <path> double <scale> …
  • /execute store success entity <target> <path> float <scale> …
  • /execute store success entity <target> <path> int <scale> …
  • /execute store success entity <target> <path> long <scale> …
  • /execute store success entity <target> <path> short <scale> …
  • /execute store success score <targets> <objective> …
  • /execute store success storage <target> <path> byte <scale> …
  • /execute store success storage <target> <path> double <scale> …
  • /execute store success storage <target> <path> float <scale> …
  • /execute store success storage <target> <path> int <scale> …
  • /execute store success storage <target> <path> long <scale> …
  • /execute store success storage <target> <path> short <scale> …
/execute summonAdded in 1.19.4
/execute summon <entity> …
ArgumentExpectsWhat it does
entityID · entity_typeEntity type to summon, for example minecraft:armor_stand or minecraft:marker.
/execute unless
/execute unless (biome|block|blocks|data|dimension|entity|function|items|loaded|predicate|score|slots|stopwatch)
ArgumentExpectsWhat it does
posBlock coordinates (x y z)Block coordinates to test, for example ~ ~-1 ~ for the block under the executor.
biomeID or #tag · biomeBiome ID or biome tag to test, for example minecraft:plains or #minecraft:is_ocean.
blockBlock testBlock to look for, with optional states or a tag, for example minecraft:chest or #minecraft:logs.
startBlock coordinates (x y z)First corner of the area that is compared.
endBlock coordinates (x y z)Opposite corner of the area that is compared.
destinationBlock coordinates (x y z)Lower north-west corner of the second area, the one it is compared with.
sourceBlock coordinates (x y z)What to read: block coordinates, an entity, a storage ID or a score holder, depending on the keyword before it.
pathNBT pathNBT path to test, such as Inventory[0] or Health. The test passes if the path exists.
dimensionDimensionDimension ID: minecraft:overworld, minecraft:the_nether or minecraft:the_end.
entitiesEntity selectorone or severalSelector to test. The check passes if at least one entity matches.
nameFunctionFunction or function tag to run. The test passes if it returns a value other than 0.
slotsSlotsSlot or range of slots, for example weapon.mainhand, armor.head or container.*.
item_predicateItem testItem to look for: an ID, a tag, * for any item, or an ID with component checks.
predicatePredicateID of a predicate file from a data pack, for example mypack:is_night.
targetScore holderoneScore holder whose score is tested: @s, a player name or a fake name.
targetObjectiveScoreboard objectiveObjective that holds the score being tested.
sourceObjectiveScoreboard objectiveObjective of the score it is compared with.
rangeRange (1..5)Accepted values: 5 exactly, 1..10 between, 10.. at least, ..3 at most. For stopwatches, in seconds.
idResource IDID of the stopwatch to test, created with /stopwatch create.
All 45 forms
  • /execute unless biome <pos> <biome>
  • /execute unless biome <pos> <biome> …
  • /execute unless block <pos> <block>
  • /execute unless block <pos> <block> …
  • /execute unless blocks <start> <end> <destination> all
  • /execute unless blocks <start> <end> <destination> all …
  • /execute unless blocks <start> <end> <destination> masked
  • /execute unless blocks <start> <end> <destination> masked …
  • /execute unless data block <source> <path>
  • /execute unless data block <source> <path> …
  • /execute unless data entity <source> <path>
  • /execute unless data entity <source> <path> …
  • /execute unless data storage <source> <path>
  • /execute unless data storage <source> <path> …
  • /execute unless dimension <dimension>
  • /execute unless dimension <dimension> …
  • /execute unless entity <entities>
  • /execute unless entity <entities> …
  • /execute unless function <name> …
  • /execute unless items block <source> <slots> <item_predicate>
  • /execute unless items block <source> <slots> <item_predicate> …
  • /execute unless items entity <source> <slots> <item_predicate>
  • /execute unless items entity <source> <slots> <item_predicate> …
  • /execute unless loaded <pos>
  • /execute unless loaded <pos> …
  • /execute unless predicate <predicate>
  • /execute unless predicate <predicate> …
  • /execute unless score <target> <targetObjective> < <source> <sourceObjective>
  • /execute unless score <target> <targetObjective> < <source> <sourceObjective> …
  • /execute unless score <target> <targetObjective> <= <source> <sourceObjective>
  • /execute unless score <target> <targetObjective> <= <source> <sourceObjective> …
  • /execute unless score <target> <targetObjective> = <source> <sourceObjective>
  • /execute unless score <target> <targetObjective> = <source> <sourceObjective> …
  • /execute unless score <target> <targetObjective> > <source> <sourceObjective>
  • /execute unless score <target> <targetObjective> > <source> <sourceObjective> …
  • /execute unless score <target> <targetObjective> >= <source> <sourceObjective>
  • /execute unless score <target> <targetObjective> >= <source> <sourceObjective> …
  • /execute unless score <target> <targetObjective> matches <range>
  • /execute unless score <target> <targetObjective> matches <range> …
  • /execute unless slots block <source> <slots>
  • /execute unless slots block <source> <slots> …
  • /execute unless slots entity <source> <slots>
  • /execute unless slots entity <source> <slots> …
  • /execute unless stopwatch <id> <range>
  • /execute unless stopwatch <id> <range> …

Examples

Speed boost on gold blocks

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

Every player standing on a Block of Gold gets Speed II for 5 seconds, without particles. Put it in a repeating command block.

Java 26.3

Warn players about nearby zombies

/execute as @a at @s if entity @e[type=minecraft:zombie,distance=..8] run title @s actionbar {"text":"Zombie nearby!","color":"red"}

Each player with a zombie within 8 blocks sees a red warning above the hotbar.

Java 26.3

Tag players with 10 kills

/execute as @a if score @s kills matches 10.. run tag @s add veteran

Adds the veteran tag to every player whose kills score is 10 or more.

Java 26.3

Give a compass to those without one

/execute as @a[gamemode=adventure] unless items entity @s container.* minecraft:compass run give @s minecraft:compass

Players in Adventure mode who carry no compass in their inventory receive one.

Java 26.3

Save a player's height in a score

/execute as @p store result score @s y_pos run data get entity @s Pos[1]

Copies the Y coordinate of the nearest player into the y_pos score as a whole number. The objective must exist.

Java 26.3

Count all loaded zombies

/execute store result score zombie_count stats if entity @e[type=minecraft:zombie]

Stores the number of zombies in loaded chunks in the fake holder zombie_count of the stats objective.

Java 26.3

Particle five blocks ahead

/execute as @p at @s anchored eyes positioned ^ ^ ^5 run particle minecraft:flame ~ ~ ~

Shows a flame 5 blocks in front of the nearest player's eyes, in the direction they are looking.

Java 26.3

Teleport into the Nether

/execute in minecraft:the_nether run teleport @s 0 100 0

Sends you to X 0, Y 100, Z 0 in the Nether. Check the spot first: you may land inside netherrack.

Java 26.3
Build your command

Fill in the fields, then copy the command.

Command generator

How the chain works

/execute reads its subcommands from left to right, and each one changes the context for everything that follows. run always comes last and is followed by an ordinary command without a slash. as changes the executor, so @s now points to that entity, but the position stays where it was. at takes the position, rotation and dimension of the entity without changing the executor. That is why execute as @a at @s is the usual opening: each player runs the command at their own feet. positioned, rotated, facing, anchored, align and in fine-tune the context. When a selector finds several entities, the rest of the chain runs once for each of them.

Conditions and stored results

if and unless stop the branch when the test fails. They can check blocks, entities, scores, NBT data, items, biomes, dimensions, predicates, functions and stopwatches. Without run, the command only reports "Test passed" or "Test failed", with a count for entities. store result and store success write the outcome of the final command into a /scoreboard score, entity or block NBT, a storage or a bossbar. Combine it with /data to turn NBT values into scores.

Tips

  • summon creates an entity and makes it the executor at once; on owner, on vehicle or on attacker jump to a related entity.
  • In a Repeating Command Block or a tick function, narrow selectors such as @e[type=zombie,distance=..10] to keep the game fast.
  • Long chains are easier to read in a /function file.

✓ Checked in Java Edition 26.3 · updated 2 November 2026

/execute: FAQ

Why does /execute as @a not use the player's position?

as only changes who runs the command. Add at @s right after it so the position moves to each player too.

Can /execute run several commands at once?

No, run accepts a single command. Put the commands in a function and use run function: it keeps the executor and the position.

How do I use /execute?

Type it in the chat with cheats on: /execute align <axes> ….

Who can use /execute?

Cheats on, or operator level 2.

Related commands