<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.sasgaming.net/index.php?action=history&amp;feed=atom&amp;title=Minecraft%3ACommand_context</id>
	<title>Minecraft:Command context - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.sasgaming.net/index.php?action=history&amp;feed=atom&amp;title=Minecraft%3ACommand_context"/>
	<link rel="alternate" type="text/html" href="https://wiki.sasgaming.net/index.php?title=Minecraft:Command_context&amp;action=history"/>
	<updated>2026-04-09T13:23:10Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://wiki.sasgaming.net/index.php?title=Minecraft:Command_context&amp;diff=49548&amp;oldid=prev</id>
		<title>imported&gt;Wplx23333 at 14:07, 2 April 2026</title>
		<link rel="alternate" type="text/html" href="https://wiki.sasgaming.net/index.php?title=Minecraft:Command_context&amp;diff=49548&amp;oldid=prev"/>
		<updated>2026-04-02T14:07:44Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Command context&amp;#039;&amp;#039;&amp;#039; (also know as &amp;#039;&amp;#039;&amp;#039;execution context&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;command origin&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;command source stack&amp;#039;&amp;#039;&amp;#039;) is a set of parameters like the executor and execution environment. It is used to provide context for [[Minecraft:command]] execution or [[Minecraft:raw JSON text]] resolution.&lt;br /&gt;
&lt;br /&gt;
== Behaviors ==&lt;br /&gt;
There are mainly 8{{only|java|short=1}}/7{{only|bedrock|short=1}} parameters in command context:&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;[[#Execution Permission Level|Execution Permission Level]]&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Executor Parameters, including:&lt;br /&gt;
** &amp;#039;&amp;#039;&amp;#039;[[#Executor Parameters|Executor Name]]&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
** &amp;#039;&amp;#039;&amp;#039;[[#Executor Parameters|Executor Entity]]&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* Execution Environment Parameters, including:&lt;br /&gt;
** &amp;#039;&amp;#039;&amp;#039;[[#Execution Dimension|Execution Dimension]]&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
** &amp;#039;&amp;#039;&amp;#039;[[#Execution Position|Execution Position]]&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
** &amp;#039;&amp;#039;&amp;#039;[[#Execution Rotation|Execution Rotation]]&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
** &amp;#039;&amp;#039;&amp;#039;[[#Execution Anchor|Execution Anchor]]&amp;#039;&amp;#039;&amp;#039;{{only|java}}&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;[[#Execution Output Callback|Execution Output Callback]]&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
When [[Minecraft:command]]s are executed or [[Minecraft:raw JSON text]]s are resolved in different scenarios, corresponding contexts are provided, to allow them to work in different scenarios.&lt;br /&gt;
&lt;br /&gt;
When running a function with the {{cmd|function}} command, the context for commands inside the function inherits the Executor Parameters, Execution Environment Parameters, and Execution Permission Level from the context of {{cmd|function}} command, while the Execution Output Callback is not inherited. {{IN|java}}, the Execution Permission Level of commands in a function is limited to 2 or below, so, if the {{cmd|function}} command is executed with 2 or higher Execution Permission Level, the command inside the function is executed with Execution Permission Level being 2.&lt;br /&gt;
&lt;br /&gt;
{{IN|bedrock}}, the context for commands in functions scheduled by {{cmd|schedule}} command also inherits the Executor Parameters, Execution Environment Parameters, and Execution Permission Level from the context of {{cmd|schedule}} command.&lt;br /&gt;
&lt;br /&gt;
=== Static values and Dynamic values ===&lt;br /&gt;
{{IN|java}}, the Executor Name and each Execution Environment Parameters in a context are &amp;#039;&amp;#039;&amp;#039;static&amp;#039;&amp;#039;&amp;#039;, and each of them exists independently. In other words, if these parameters are not modified with {{cmd|execute}}, they do not change during the command execution, or during the execution of each command in a function. For example, even if the name of the Executor Entity is modified in a function, it does not change the Executor Name in the context of subsequent commands in the function; For another example, for {{cmd|1=execute at @n[type=sheep] run function test}}, even if a {{cmd|tp}} command in a function {{cd|test}} changes the position, rotation, or dimension of the sheep entity, it does not affect the Execution Position, Execution Rotation, and Execution Dimension in the context of subsequent commands in the function, since the values of all these parameters are static after being modified by the {{cd|at}} subcommand and they are no longer related to the sheep entity itself.&lt;br /&gt;
&lt;br /&gt;
{{IN|bedrock}} parameter values are static in some cases but &amp;#039;&amp;#039;&amp;#039;dynamic&amp;#039;&amp;#039;&amp;#039; in other cases. When dynamic, the value of a parameter does not exist independently, but rather it is a reference to an entity and fetches values from the entity in real time. For example, when an Execution Position is dynamic, it depends on an entity and obtains its position in real time, i.e., if the entity is moved in a function, the Execution Position in the context of subsequent commands in the function is the position of the entity after the move.&amp;lt;ref&amp;gt;{{bug|MCPE-179363}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Specifically, dynamic values exist in the following cases:&lt;br /&gt;
* When the player executes a command in the chat bar, or a command is requested through a WebSocket server connected with the client, the Execution Position, Execution Rotation, and Execution Dimension are dynamic and referring to the player entity.&lt;br /&gt;
* When a command block minecart executes the command in it, the Execution Position and Execution Rotation are dynamic, referring to this minecart entity.&lt;br /&gt;
* When an entity event response defined in a behavior pack executes a command, or a script executes a command with entity class, or an animation controller in a behavior pack executes a command, or an NPC executes a command, the Executor Name, Execution Position, Execution Rotation, and Execution Dimension are dynamic and referring to the entity.&lt;br /&gt;
* {{cmd|execute}} command converts the Executor Name to a dynamic value referring to the Executor Entity. That is, when a command is executed in a {{cmd|execute}} command, the Executor Name of it is always dynamic, fetched from the Executor Entity in real time, regardless of whether there is a static Executor Name in the context of the {{cmd|execute}}.&lt;br /&gt;
* {{cd|at ...}} and {{cd|positioned as ...}} subcommands in {{cmd|execute}} set the Execution Position to a dynamic value, referring to the specified entity.&lt;br /&gt;
* {{cd|at ...}} and {{cd|rotated as ...}}  subcommands in {{cmd|execute}} set the Execution Rotation to a dynamic value, referring to the specified entity.&lt;br /&gt;
&lt;br /&gt;
If the Execution Position is dynamic, it fetches the position from an entity in real time. But, if this entity is [[Minecraft:riding]] on another entity, there is a special treatment:&lt;br /&gt;
* If the hitbox bottom of this entity is lower than the hitbox bottom of the mount, the mount&amp;#039;s hitbox bottom is used as the Y coordinate of the Execution Position.&lt;br /&gt;
** For example, if a player is riding on a minecart, the player&amp;#039;s X and Z coordinates and the minecart&amp;#039;s Y coordinate are used as the Execution Position.&lt;br /&gt;
&lt;br /&gt;
If the entity which a dynamic value refers to has been removed from the world (e.g., an armor stand is killed, or a sheep finishes its death animation), the dynamic value cannot be fetched. In this case, default values of parameters are used:&lt;br /&gt;
* Executor Name defaults to an empty string&lt;br /&gt;
* Execution Dimension defaults to empty&lt;br /&gt;
* Execution Position defaults to &amp;lt;code&amp;gt;(0, 0, 0)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Execution Rotation defaults to &amp;lt;code&amp;gt;(0, 0)&amp;lt;/code&amp;gt;&lt;br /&gt;
For example, when {{cmd|execute run say hi}} is executed in the command block, as mentioned above, the Executor Name converts to a dynamic value by the {{cmd|execute}} command, referring to the Executor Entity. Since there is no Executor Entity in the context, the Executor Name of {{cmd|say hi}} is an empty string.&lt;br /&gt;
&lt;br /&gt;
For another example, if the Executor Entity is removed before a function schedule (scheduled by {{cmd|schedule}}) is executed, the schedule cannot be executed because the Execution Dimension is missing in the context.&lt;br /&gt;
&lt;br /&gt;
A dynamic value is converted to a static value in the following cases:&lt;br /&gt;
* {{cmd|execute}} command converts the Execution Dimension to a static value.&lt;br /&gt;
* {{cmd|execute}} command converts the Execution Rotation to a static value.&lt;br /&gt;
* {{cd|align ...}} subcommand in {{cmd|execute}} converts the Execution Position to a static value.&lt;br /&gt;
* {{cd|in ...}} subcommand in {{cmd|execute}} converts the Execution Position to a static value.&lt;br /&gt;
* {{cd|positioned &amp;lt;&amp;#039;&amp;#039;coordinates&amp;#039;&amp;#039;&amp;gt;}} subcommand in {{cmd|execute}} converts the Execution Position to a static value.&lt;br /&gt;
* {{cd|facing ...}} subcommand in {{cmd|execute}} converts the Execution Rotation to a static value.&lt;br /&gt;
* {{cd|rotated &amp;lt;&amp;#039;&amp;#039;angles&amp;#039;&amp;#039;&amp;gt;}} subcommand in {{cmd|execute}} converts the Execution Rotation to a static value.&lt;br /&gt;
* If the Execution Position is a dynamic value, then {{cd|anchored ...}} subcommand in {{cmd|execute}} converts the Execution Position to a static value, being the position at the referred entity&amp;#039;s feet or eyes; If the Execution Position is a static value, {{cd|anchored ...}} subcommand does not take any effect.&amp;lt;ref&amp;gt;{{bug|MCPE-162681}} and {{bug|MCPE-165051}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
* When a player executes {{cmd|function ...}} in the chat bar, the Execution Position, Execution Rotation and Execution Dimension of commands in the function are dynamic, referring to the player.&lt;br /&gt;
* When a player executes {{cmd|execute run &amp;lt;&amp;#039;&amp;#039;command&amp;#039;&amp;#039;&amp;gt;}} in the chat bar, the Execution Position of the {{cd|&amp;lt;&amp;#039;&amp;#039;command&amp;#039;&amp;#039;&amp;gt;}} is dynamic, while the Execution Rotation and Execution Dimension are static.&lt;br /&gt;
* When a player executes {{cmd|execute at @s run &amp;lt;&amp;#039;&amp;#039;command&amp;#039;&amp;#039;&amp;gt;}} in the chat bar, the Execution Position and Execution Rotation of the {{cd|&amp;lt;&amp;#039;&amp;#039;command&amp;#039;&amp;#039;&amp;gt;}}} are dynamic, while the Execution Dimension is static.&lt;br /&gt;
* When a player executes {{cmd|execute at @s rotated ~ ~ run &amp;lt;&amp;#039;&amp;#039;command&amp;#039;&amp;#039;&amp;gt;}} in the chat bar, the Execution Position of the {{cd|&amp;lt;&amp;#039;&amp;#039;command&amp;#039;&amp;#039;&amp;gt;}} is dynamic, while the Execution Rotation and Execution Dimension are static.&lt;br /&gt;
* When a player executes {{cmd|execute at @s rotated ~ ~ positioned ~ ~ ~ run &amp;lt;&amp;#039;&amp;#039;command&amp;#039;&amp;#039;&amp;gt;}} in the chat bar, the Execution Position, Execution Rotation and Execution Dimension of the {{cd|&amp;lt;&amp;#039;&amp;#039;command&amp;#039;&amp;#039;&amp;gt;}} are all static.&lt;br /&gt;
* When a player executes {{cmd|execute positioned ~ ~ ~ run &amp;lt;&amp;#039;&amp;#039;command&amp;#039;&amp;#039;&amp;gt;}} in the chat bar, the Execution Position, Execution Rotation and Execution Dimension of the {{cd|&amp;lt;&amp;#039;&amp;#039;command&amp;#039;&amp;#039;&amp;gt;}} are all static.&lt;br /&gt;
* If there are at least three entities in a dimension, and a player in the dimension executes {{cmd|1=execute rotated as @e[c=3] run tp @s ~ ~1 ~}} in the chat bar, the player is teleported to 3 blocks above its original position.&lt;br /&gt;
&lt;br /&gt;
== Parameters ==&lt;br /&gt;
=== Execution Permission Level ===&lt;br /&gt;
{{main|Permission level}}&lt;br /&gt;
The Execution Permission Level cannot be modified by {{cmd|execute}} command.&lt;br /&gt;
&lt;br /&gt;
{{IN|java}}, in the context of commands in a function called by a {{cmd|function}} command, the Execution Permission Level is limited to 2 or less. If the Execution Permission Level of the {{cmd|function}} command is greater than 2, the commands in the function is executed with Execution Permission Level of 2.&lt;br /&gt;
&lt;br /&gt;
=== Executor Parameters ===&lt;br /&gt;
There are two Executor Parameters, Executor Name and Executor Entity, where the Executor Entity parameter may be empty (e.g. when a command is executed by a command block). Executor parameters are used in the following scenarios:&lt;br /&gt;
* When sending a message using commands such as {{cmd|tell}} or {{cmd|say}}, the Executor Name is used as the sender name of the message.&lt;br /&gt;
* &amp;lt;code&amp;gt;@s&amp;lt;/code&amp;gt; [[Minecraft:target selector]] directly selects the Executor Entity.&lt;br /&gt;
* By default, the target of commands such as {{cmd|tp}} and {{cmd|kill}} is the Executor Entity.&lt;br /&gt;
* By default, the target player of commands such as {{cmd|clear}}, {{cmd|gamemode}}, and {{cmd|playsound}} is the Executor Entity, if it is a player entity.&lt;br /&gt;
* {{IN|je}}, commands such as {{cmd|trigger}} and {{cmd|teammsg}} take effect on the Executor Entity, if the Executor Entity is a player.&lt;br /&gt;
* {{IN|je}}, [[#Execution Anchor|Execution Anchor]] modifies the Y coordinate based on the eye height of the Executor Entity.&lt;br /&gt;
&lt;br /&gt;
They can be modified using {{cd|as}}, {{cd|on}}, and {{cd|summon}} subcommands in {{cmd|execute}} command. {{IN|je}}, the Executor Name and Executor Entity are always modified at the same time. {{IN|be}}, only the Executor Entity is modified, and as mentioned above, the Executor Name remains a dynamic value referring to the Executor Entity.&lt;br /&gt;
&lt;br /&gt;
=== Execution Dimension ===&lt;br /&gt;
Execution Dimension is the [[Minecraft:dimension]] in which the command takes effect. Execution Dimension is used in the following scenarios:&lt;br /&gt;
* Whenever [[Minecraft:coordinates]] are specified, the coordinates are specified within the Execution Dimension.&lt;br /&gt;
* [[Minecraft:Target selector]]s with &amp;lt;code&amp;gt;distance&amp;lt;/code&amp;gt;{{only|je|short=1}}, &amp;lt;code&amp;gt;r&amp;lt;/code&amp;gt;{{only|be|short=1}}, &amp;lt;code&amp;gt;rm&amp;lt;/code&amp;gt;{{only|be|short=1}}, &amp;lt;code&amp;gt;dx&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dy&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;dz&amp;lt;/code&amp;gt; being specified, only entities in the Execution Dimension are selected.&lt;br /&gt;
* {{IN|java}}, [[Minecraft:target selector]]s with &amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;z&amp;lt;/code&amp;gt; being specified, only entities in the Execution Dimension are selected, too.&lt;br /&gt;
* Commands such as {{cmd|locate}} works within the Execution Dimension.&lt;br /&gt;
&lt;br /&gt;
Execution Dimension can be modified using {{cd|at}} and {{cd|in}} subcommands in the {{cmd|execute}} command. {{IN|bedrock}}, the {{cmd|execute}} command itself converts the Execution Dimension to a static value.&lt;br /&gt;
&lt;br /&gt;
=== Execution Position ===&lt;br /&gt;
Execution Position is the [[Minecraft:coordinates]] that the command takes effect from. Execution Position is used in the following scenarios:&lt;br /&gt;
* [[Minecraft:Coordinates#Commands|Relative coordinates]] are relative to the Execution Position.&lt;br /&gt;
* {{IN|java}}, the origin of [[Minecraft:Coordinates#Commands|local coordinates]] is based on the Execution Position and affected by the Executor Anchor.&lt;br /&gt;
* {{IN|bedrock}}, the origin of [[Minecraft:Coordinates#Commands|local coordinates]] is the Execution Position.&lt;br /&gt;
* {{IN|java}}, the start point of {{cmd|execute facing ...}} and {{cmd|tp ... facing ...}} is based on the Execution Position and affected by the Executor Anchor.&lt;br /&gt;
* {{IN|bedrock}}, the start point of {{cmd|execute facing ...}} and {{cmd|tp ... facing ...}} is the Execution Position.&lt;br /&gt;
* Commands such as {{cmd|locate}} use the Execution Position as its start point.&lt;br /&gt;
* By default, the target position of commands such as {{cmd|locate}} is the Execution Position.&lt;br /&gt;
&lt;br /&gt;
Execution Position can be modified using {{cd|align}}, {{cd|at}}, {{cd|positioned}} subcommands in {{cmd|execute}} command, and {{cd|in}} subcommand also affects the Execution Position. {{IN|be}}, {{cd|at}} and {{cd|positioned as}} subcommands set the Execution Position to a dynamic value referring to the specified entity. {{IN|bedrock}}, {{cd|align}}, {{cd|anchored}}, {{cd|in}}, and {{cd|positioned &amp;lt;&amp;#039;&amp;#039;coordinates&amp;#039;&amp;#039;&amp;gt;}} subcommands convert the Execution Position to a static value.&lt;br /&gt;
&lt;br /&gt;
=== Execution Rotation ===&lt;br /&gt;
Execution Rotation is the rotation that the command is executed with. Execution Rotation is used in the following scenarios:&lt;br /&gt;
* The coordinate system of [[Minecraft:Coordinates#Commands|local Coordinates]] is based on the Execution Rotation.&lt;br /&gt;
* Relative rotation specified with a tilde ({{cd|~}}) in commands such as {{cmd|tp}} and {{cmd|spawnpoint}} is relative to the Execution Rotation.&lt;br /&gt;
&lt;br /&gt;
Execution Rotation can be modified using {{cd|at}}, {{cd|facing}}, and {{cd|rotated}} subcommands in the {{cmd|execute}} command. {{IN|be}}, {{cd|as}} and {{cd|rotated as}} subcommands set the Execution Rotation to a dynamic value referring to the specified entity. {{IN|bedrock}}, {{cmd|execute}} command itself and its {{cd|facing}}, {{cd|rotated &amp;lt;&amp;#039;&amp;#039;angle&amp;#039;&amp;#039;&amp;gt;}} subcommands converts the Execution Rotation to a static value.&lt;br /&gt;
&lt;br /&gt;
=== Execute Anchor ===&lt;br /&gt;
{{exclusive|java|section=1}}&lt;br /&gt;
Execute Anchor determines whether the position of eyes or feet of the Executor Entity is used as the origin of [[Minecraft:local coordinates]], and the start point of {{cd|facing}} in {{cmd|teleport}} and of {{cd|facing}} subcommand in {{cmd|execute}}.&lt;br /&gt;
* If it is foot, uses the Execution Position directly.&lt;br /&gt;
* If it is eyes, based on the Execution Position, the eye height of the Executor Entity is added into the Y coordinate.&lt;br /&gt;
&lt;br /&gt;
Execution Anchor are used only in the following scenarios:&lt;br /&gt;
* [[Minecraft:Local coordinates]].&lt;br /&gt;
* The start point of {{cd|facing ...}} subcommand in {{cmd|execute}}.&lt;br /&gt;
* The start point of {{cmd|tp ... facing ...}}.&lt;br /&gt;
&lt;br /&gt;
Execute Anchor can be modified using {{cd|anchored}} subcommand in {{cmd|execute}} command.&lt;br /&gt;
&lt;br /&gt;
Executor Anchor parameter does not exist {{in|be}}. Instead, {{in|be}}, the {{cd|anchored}} subcommand in {{cmd|execute}} directly modifies the Execution Position. If the Execution Position is originally dynamic, the {{cd|anchored}} subcommand converts it to a static value, being the position of feet or eyes of the entity being referred by the dynamic value; If the Execution Position is static, {{cd|anchored}} subcommand does not have any effect at all.&lt;br /&gt;
&lt;br /&gt;
=== Execution Output Callback ===&lt;br /&gt;
Execution Output Callbacks are used to receive [[Minecraft:Commands#Output|output values]] of a command.&lt;br /&gt;
&lt;br /&gt;
A command executed in a [[Minecraft:command block]], a [[Minecraft:minecart with command block]], or a script{{only|be}} has a callback that sends the success count to the command block or minecart.&lt;br /&gt;
&lt;br /&gt;
{{IN|java}}, {{cd|store}} subcommand in {{cmd|execute}} command can be used to add a new callback while the existing callbacks are retained. Existing callbacks cannot be cleared by {{cmd|execute}} command.&lt;br /&gt;
&lt;br /&gt;
The context of commands in a function called by a {{cmd|function}} or {{cmd|schedule}} does not inherit the Execution Output Callbacks of the {{cmd|function}} or {{cmd|schedule}} command.&lt;br /&gt;
&lt;br /&gt;
== Contexts in various scenarios ==&lt;br /&gt;
=== Command execution ===&lt;br /&gt;
==== Server console ====&lt;br /&gt;
The context of commands entered in the server console is:&lt;br /&gt;
* Execution Permission Level: 4&lt;br /&gt;
* Executor Name: &amp;lt;code&amp;gt;Server&amp;lt;/code&amp;gt;&lt;br /&gt;
* Executor Entity: None&lt;br /&gt;
* Execution Dimension: Overworld&lt;br /&gt;
* Execution Position:  Bottom northwest corner of the block at the [[Minecraft:world spawn]]{{only|java}}/&amp;lt;code&amp;gt;(0, 0, 0)&amp;lt;/code&amp;gt;{{only|bedrock}}&lt;br /&gt;
* Execution Rotation: &amp;lt;code&amp;gt;(0, 0)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Execution Anchor{{only|je|short=1}}: Feet&lt;br /&gt;
* Execution Output Callback: None&lt;br /&gt;
&lt;br /&gt;
==== Functions executed by the server-side ====&lt;br /&gt;
A [[Minecraft:function]] is executed by the server-side when:&lt;br /&gt;
* {{IN|je}}, the function is called via &amp;lt;code&amp;gt;load&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;tick&amp;lt;/code&amp;gt; tags.&lt;br /&gt;
* {{IN|be}}, the function is called via &amp;lt;code&amp;gt;load.json&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;tick.json&amp;lt;/code&amp;gt;.&lt;br /&gt;
* {{IN|je}}, the function is scheduled by {{cmd|schedule}} command.&lt;br /&gt;
&lt;br /&gt;
The context of commands in a function executed by the server-side is:&lt;br /&gt;
* Execution Permission Level: 2{{only|java}}/1{{only|bedrock}}&lt;br /&gt;
* Executor Name: &amp;lt;code&amp;gt;Server&amp;lt;/code&amp;gt;&lt;br /&gt;
* Executor Entity: None&lt;br /&gt;
* Execution Dimension: Overworld&lt;br /&gt;
* Execution Position:  Bottom northwest corner of the block at the [[Minecraft:world spawn]]{{only|java}}/&amp;lt;code&amp;gt;(0, 0, 0)&amp;lt;/code&amp;gt;{{only|bedrock}}&lt;br /&gt;
* Execution Rotation: &amp;lt;code&amp;gt;(0, 0)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Execution Anchor{{only|je|short=1}}: Feet&lt;br /&gt;
* Execution Output Callback: None&lt;br /&gt;
&lt;br /&gt;
==== Player ====&lt;br /&gt;
The context of commands that are entered in the chat bar, or requested via a WebSocket server connected with the client {{in|be}}, is:&lt;br /&gt;
* Execution Permission Level: The permission level of the player&lt;br /&gt;
* Executor Name: The name of the player; or &amp;lt;code&amp;gt;External&amp;lt;/code&amp;gt; for commands requested by a WebSocket {{in|be}}&lt;br /&gt;
* Executor Entity: The player&lt;br /&gt;
* Execution Dimension: The dimension the player is in (Dynamic value {{in|bedrock}})&lt;br /&gt;
* Execution Position: The position of the player (Dynamic value {{in|bedrock}})&lt;br /&gt;
* Execution Rotation: The rotation of the player (Dynamic value {{in|bedrock}})&lt;br /&gt;
* Execution Anchor{{only|je|short=1}}: Feet&lt;br /&gt;
* Execution Output Callback: None&lt;br /&gt;
&lt;br /&gt;
==== Command block ====&lt;br /&gt;
The context of commands that are executed in a [[Minecraft:command block]] is:&lt;br /&gt;
* Execution Permission Level: 2{{only|java}}/1{{only|bedrock}}&lt;br /&gt;
* Executor Name: The custom name of the command block. If it has no custom name, defaults to &amp;lt;code&amp;gt;@&amp;lt;/code&amp;gt;{{only|java}}/&amp;lt;code&amp;gt;!&amp;lt;/code&amp;gt;{{only|bedrock}}.&lt;br /&gt;
* Executor Entity: None&lt;br /&gt;
* Execution Dimension: The dimension the command block is in&lt;br /&gt;
* Execution Position: The center of the command block&lt;br /&gt;
* Execution Rotation: The rotation of the command block{{only|java}}/&amp;lt;code&amp;gt;(0, 0)&amp;lt;/code&amp;gt;{{only|bedrock}}&lt;br /&gt;
* Execution Anchor{{only|je|short=1}}: Feet&lt;br /&gt;
* Execution Output Callback: Sends the success count to the command block&lt;br /&gt;
&lt;br /&gt;
==== Minecart with command block ====&lt;br /&gt;
The context of commands that are executed in a [[Minecraft:minecart with command block]] is:&lt;br /&gt;
* Execution Permission Level: 2{{only|java}}/1{{only|bedrock}}&lt;br /&gt;
* Executor Name: The custom name of the minecart. If it has no custom name, defaults to &amp;lt;code&amp;gt;@&amp;lt;/code&amp;gt;{{only|java}}/&amp;lt;code&amp;gt;!&amp;lt;/code&amp;gt;{{only|bedrock}}.&lt;br /&gt;
* Executor Entity: The minecart with command block&lt;br /&gt;
* Execution Dimension: The dimension the minecart is in&lt;br /&gt;
* Execution Position: The position of the minecart (Dynamic value {{in|bedrock}})&lt;br /&gt;
* Execution Rotation: The rotation of the minecart (Dynamic value {{in|bedrock}})&lt;br /&gt;
* Execution Anchor{{only|je|short=1}}: Feet&lt;br /&gt;
* Execution Output Callback: Sends the success count to the command block&lt;br /&gt;
&lt;br /&gt;
==== Sign ====&lt;br /&gt;
{{exclusive|java|section=1}}&lt;br /&gt;
The context of commands executed when a player clicks a [[Minecraft:sign]] block is:&lt;br /&gt;
* Execution Permission Level: 2&lt;br /&gt;
* Executor Name: The name of the player&lt;br /&gt;
* Executor Entity: The player&lt;br /&gt;
* Execution Dimension: The dimension the sign block is in&lt;br /&gt;
* Execution Position: The center of the block the sign is in&lt;br /&gt;
* Execution Rotation: &amp;lt;code&amp;gt;(0, 0)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Execution Anchor: Feet&lt;br /&gt;
* Execution Output Callback: None&lt;br /&gt;
&lt;br /&gt;
==== Advancement reward ====&lt;br /&gt;
{{exclusive|java|section=1}}&lt;br /&gt;
The context of commands in the [[Minecraft:function (Java Edition)|function]] called by a {{nbt|string|function}} reward in a [[Minecraft:Advancement definition|custom advancement]] is: &lt;br /&gt;
* Execution Permission Level: 2&lt;br /&gt;
* Executor Name: The name of the player that gets the advancement&lt;br /&gt;
* Executor Entity: The player that gets the advancement&lt;br /&gt;
* Execution Dimension: The dimension the player is in&lt;br /&gt;
* Execution Position: The position of the player&lt;br /&gt;
* Execution Rotation: The rotation of the player&lt;br /&gt;
* Execution Anchor: Feet&lt;br /&gt;
* Execution Output Callback: None&lt;br /&gt;
&lt;br /&gt;
==== Enchantment effect ====&lt;br /&gt;
{{exclusive|java|section=1}}&lt;br /&gt;
The context of commands in the [[Minecraft:function (Java Edition)|function]] called by a &amp;lt;code&amp;gt;run_function&amp;lt;/code&amp;gt; [[Minecraft:Enchantment definition#run_function|enchantment effect]] is:&lt;br /&gt;
* Execution Permission Level: 2&lt;br /&gt;
* Executor Name: The name of the affected entity of the enchantment effect&lt;br /&gt;
* Executor Entity: The affected entity of the enchantment effect&lt;br /&gt;
* Execution Dimension: The dimension the enchantment takes effects in&lt;br /&gt;
* Execution Position: The position the enchantment takes effects at&lt;br /&gt;
* Execution Rotation: The rotation of the affected entity of the enchantment effect&lt;br /&gt;
* Execution Anchor: Feet&lt;br /&gt;
* Execution Output Callback: None&lt;br /&gt;
&lt;br /&gt;
==== Entity in behavior packs ====&lt;br /&gt;
{{exclusive|bedrock|section=1}}&lt;br /&gt;
&lt;br /&gt;
The context of commands executed via an entity event response defined in a behavior pack, or via entity class in a script, or an animation controller in a behavior pack, or a dialogue of an [[Minecraft:NPC]] entity is:&lt;br /&gt;
* Execution Permission Level: 1&lt;br /&gt;
* Executor Name: The name of the entity (Dynamic value {{in|bedrock}})&lt;br /&gt;
* Executor Entity: The entity&lt;br /&gt;
* Execution Dimension: The dimension the entity is in (Dynamic value {{in|bedrock}})&lt;br /&gt;
* Execution Position: The position of the entity (Dynamic value {{in|bedrock}})&lt;br /&gt;
* Execution Rotation: The rotation of the rotation (Dynamic value {{in|bedrock}})&lt;br /&gt;
* Execution Output Callback: If via entity class in a script, returns the success count&lt;br /&gt;
&lt;br /&gt;
==== Dimension in scripts ====&lt;br /&gt;
{{exclusive|bedrock|section=1}}&lt;br /&gt;
The context of commands executed via Dimension class in a script: &lt;br /&gt;
* Execution Permission Level: 1&lt;br /&gt;
* Executor Name: Script Engine&lt;br /&gt;
* Executor Entity: None&lt;br /&gt;
* Execution Dimension: The dimension&lt;br /&gt;
* Execution Position: &amp;lt;code&amp;gt;(0, 0, 0)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Execution Rotation: &amp;lt;code&amp;gt;(0, 0)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Execution Output Callback: Returns the success count&lt;br /&gt;
&lt;br /&gt;
=== Raw JSON text resolution ===&lt;br /&gt;
When resolving a [[Minecraft:raw JSON text]], relative coordinates, local coordinates, and target selectors in it are resolved based on a command context. The Execution Output Callback parameter in the command context is not used by raw JSON text.&lt;br /&gt;
&lt;br /&gt;
Note that if the {{nbt|string|name}} field is &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; in a &amp;lt;code&amp;gt;score&amp;lt;/code&amp;gt; type text, the reader&amp;#039;s own score is displayed. In addition to the command context, the readers of the raw JSON text are also listed below.&lt;br /&gt;
&lt;br /&gt;
==== Called by a command ====&lt;br /&gt;
A [[Minecraft:raw JSON text]] called by a command inherits the context of the command. Including:&lt;br /&gt;
* {{cmd|bossbar}}{{only|je}}&lt;br /&gt;
** Reader: None&lt;br /&gt;
* {{cmd|tellraw}}&lt;br /&gt;
** Reader: Each player that receives the message&lt;br /&gt;
* {{cmd|title}}&lt;br /&gt;
** Reader: Each player that receives the title&lt;br /&gt;
&lt;br /&gt;
==== Written book being opened by a player ====&lt;br /&gt;
{{exclusive|java|section=1}}&lt;br /&gt;
The context when a [[Minecraft:written book]] is being opened by a player is:&lt;br /&gt;
* Execution Permission Level: The permission level of the player&lt;br /&gt;
* Executor Name: The name of the player&lt;br /&gt;
* Executor Entity: The player&lt;br /&gt;
* Execution Dimension: The dimension the player is in&lt;br /&gt;
* Execution Position: The position of the player&lt;br /&gt;
* Execution Rotation: The rotation of the player&lt;br /&gt;
* Execution Anchor: Feet&lt;br /&gt;
* Reader: The player&lt;br /&gt;
&lt;br /&gt;
==== Written book being placed on a lectern ====&lt;br /&gt;
{{exclusive|java|section=1}}&lt;br /&gt;
The context when a written book is being placed on a [[Minecraft:lectern]] is:&lt;br /&gt;
* Execution Permission Level: 2&lt;br /&gt;
* Executor Name: &amp;lt;code&amp;gt;Lectern&amp;lt;/code&amp;gt;&lt;br /&gt;
* Executor Entity: None&lt;br /&gt;
* Execution Dimension: The dimension the lectern is in&lt;br /&gt;
* Execution Position: The center of the block the lectern is in&lt;br /&gt;
* Execution Rotation: &amp;lt;code&amp;gt;(0, 0)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Execution Anchor: Feet&lt;br /&gt;
* Reader: None&lt;br /&gt;
&lt;br /&gt;
==== Sign ====&lt;br /&gt;
{{exclusive|java|section=1}}&lt;br /&gt;
The context when the text in a [[Minecraft:sign]] block is being changed via NBT is:&lt;br /&gt;
* Execution Permission Level: 2&lt;br /&gt;
* Executor Name: &amp;lt;code&amp;gt;Sign&amp;lt;/code&amp;gt;&lt;br /&gt;
* Executor Entity: None&lt;br /&gt;
* Execution Dimension: The dimension the sign is in&lt;br /&gt;
* Execution Position: The center of the block the sign is in&lt;br /&gt;
* Execution Rotation: &amp;lt;code&amp;gt;(0, 0)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Execution Anchor: Feet&lt;br /&gt;
* Reader: None&lt;br /&gt;
&lt;br /&gt;
==== Text display entity ====&lt;br /&gt;
{{exclusive|java|section=1}}&lt;br /&gt;
The context when the text in a [[Minecraft:text display]] entity is being changed &lt;br /&gt;
* Execution Permission Level: 2&lt;br /&gt;
* Executor Name: The name of the text display entity&lt;br /&gt;
* Executor Entity: The text display entity&lt;br /&gt;
* Execution Dimension: The dimension the text display entity is in&lt;br /&gt;
* Execution Position: The position of the text display entity&lt;br /&gt;
* Execution Rotation: The rotation of the text display entity&lt;br /&gt;
* Execution Anchor: Feet&lt;br /&gt;
* Reader: The text display entity&lt;br /&gt;
&lt;br /&gt;
==== Item modifier ====&lt;br /&gt;
{{exclusive|java|section=1}}&lt;br /&gt;
In [[Minecraft:item modifier]], &amp;lt;code&amp;gt;set_name&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;set_lore&amp;lt;/code&amp;gt; functions resolve the raw JSON text only if the entity specified with {{nbt|string|entity}} does exist, with the following context:&lt;br /&gt;
* Execution Permission Level: 2&lt;br /&gt;
* Executor Name: The name of the entity specified with {{nbt|string|entity}}&lt;br /&gt;
* Executor Entity: The entity specified with {{nbt|string|entity}}&lt;br /&gt;
* Execution Dimension: The dimension that the entity specified with {{nbt|string|entity}} is in&lt;br /&gt;
* Execution Position: The position of the entity specified with {{nbt|string|entity}}&lt;br /&gt;
* Execution Rotation: The rotation of the entity specified with {{nbt|string|entity}}&lt;br /&gt;
* Execution Anchor: Feet&lt;br /&gt;
* Reader: The entity specified with {{nbt|string|entity}}&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
{{HistoryTable&lt;br /&gt;
|{{HistoryLine|java}}&lt;br /&gt;
|{{HistoryLine||1.13|dev=17w45a|Reworked {{cmd|execute}} command. Now can modify each context parameter independently.&lt;br /&gt;
|Removed the [[Minecraft:Commands/stats|command stat]] callback in command context.&lt;br /&gt;
|Added {{cmd|execute store ...}}, allowing to add custom output callbacks into the command context.}}&lt;br /&gt;
|{{HistoryLine|||dev=18w02a|Added Execution Anchor parameter.&lt;br /&gt;
|Added {{cmd|execute anchored ...}}, which can modify the execution anchor.}}&lt;br /&gt;
|{{HistoryLine||1.20|dev=23w16a|Now {{cmd|return}} command sets the return values of a [[Minecraft:function]] via command context.}}&lt;br /&gt;
|{{HistoryLine||1.20.3|dev=23w41a|Now functions called by a {{cmd|function}} command no longer inherit its output callbacks.}}&lt;br /&gt;
|{{HistoryLine|||dev=23w44a|Now {{cmd|return}} command sets the return values of a [[Minecraft:function]] via new function system, instead of via command context.}}&lt;br /&gt;
&lt;br /&gt;
|{{HistoryLine|bedrock}}&lt;br /&gt;
|{{HistoryLine||1.9.0|dev=beta 1.9.0.2|Commands from command blocks no longer extend to other dimensions.&amp;lt;ref&amp;gt;{{bug|MCPE-33892|||fixed}}&amp;lt;/ref&amp;gt;}}&lt;br /&gt;
|{{HistoryLine||1.13.0|dev=beta 1.13.0.1|Now {{cd|detect}} option in {{cd|/execute}} uses the position and rotation of the executor entity.&amp;lt;ref&amp;gt;{{bug|MCPE-29942|||fixed}}&amp;lt;/ref&amp;gt;}}&lt;br /&gt;
|{{HistoryLine||1.16.220|dev=beta 1.16.220.50|Using {{cmd|teleport}} with {{cd|/execute}} command now uses the dimension of the executor entity&amp;lt;ref&amp;gt;{{bug|MCPE-44104|||fixed}}&amp;lt;/ref&amp;gt;}}&lt;br /&gt;
|{{HistoryLine||1.19.10|exp=Upcoming Creator Features|dev=Preview 1.19.10.20|Added new {{cmd|execute|link=None}} syntax, which can modify each context parameter independently.}}&lt;br /&gt;
|{{HistoryLine||1.19.50|dev=Preview 1.19.50.23|The new {{cmd|execute|link=none}} syntax is no longer behind the &amp;quot;Upcoming Creator Features&amp;quot; experimental toggle.&lt;br /&gt;
|Running {{cmd|execute as}} from Command Blocks no longer inherits rotation from the entity.&amp;lt;ref&amp;gt;{{bug|MCPE-162680|||fixed}}&amp;lt;/ref&amp;gt;}}&lt;br /&gt;
|{{HistoryLine||1.19.70|dev=beta 1.19.70.20|&lt;br /&gt;
Rotation in the {{cmd|teleport}} command is now relative to the execution rotation instead of the rotation of the target entity.}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Navigation ==&lt;br /&gt;
{{Navbox Java Edition}}&lt;br /&gt;
{{Navbox Bedrock Edition}}&lt;br /&gt;
&lt;br /&gt;
[[Minecraft:ja:コマンド文脈]]&lt;br /&gt;
[[Minecraft:zh:命令上下文]]&lt;/div&gt;</summary>
		<author><name>imported&gt;Wplx23333</name></author>
	</entry>
</feed>