{{indexmenu_n>1}} ====== Action Contexts ====== Actions have a certain context that they use for passing the requirements and executing the actions themselves. Where appropriate, this context is denoted in a table with types with a description for each type. An example of such table is shown below. Some types have an additional [[#parameters|parameter]] attached, as they may require multiple entries. These are all the possible types: ^ World | The world the action is executing in. | ^ Entity | The entities that are used for executing an action. Has a parameter. | ^ Position | The positions in the world that are used for executing an action. Has a parameter. Note that if an invalid position is used, the world spawn is used instead. | ^ Side | The side of a block the action is executed on. Note that this value may not always be present, in which case it defaults to ''up''. | ^ Item Stack | The item stack used. Note that modifying or setting a new item stack does not overwrite the item stack in the context. This means you still have access to the original item stack, even if it was changed. | ===== Example ===== | ^ Parameter ^ Description ^ ^ Entity | ''this'' | The player using the item stack. | ^ ::: | ''target'' | The entity the player used the item stack on. | ^ Position | ''this'' | The position of the player. | ^ ::: | ''target'' | The position of the target entity. | ^ Item Stack | | The item stack used by the player. | ===== Parameters ===== Sometimes a singular entry is not enough. This is what parameters are useful for. They allow you to refer to some other entry in the action context, rather than just the executing entry. In an action context, the parameters should be inferred by their usage. For example, a player using an item stack has no ''target'' entity, but using an item stack on another entity does. On the other hand, a [[mc>Dispenser]] dispensing an item has no entity at all. Note that an entry that is not present may cause the action to fail, or may cause unintended behavior. ==== Values ==== ^ Name ^ Applies to ^ | ''this'' | The original executing type. | | ''target'' | The targeted type, usually a direct target from the original executing type. | ===== Parameter Sets ===== These parameters are sometimes defined in a set, usually when they are converted to some other context, such as a [[mc>Function_(Java_Edition)#Behaviors|function context]] or a [[mc>Loot_context|loot context]]. It has fields for all types with parameters in the action context. ==== Fields ==== ^ Name ^ Description ^ Type ^ Default Value ^ | ''entity'' | The entity to pick from the context. | An [[#parameters|action context parameter]] | | | ''position'' | The position to pick from the context. | An [[#parameters|action context parameter]] | | ===== Example ===== { "entity": "this", "position": "target" }