This tutorial is set by the author's setting without permission.
/Execute is a collection of sub -commands of different functions. It is used to change the command to execute the context (modifier command), execute logic judgments (conditional commands) and manage and store command return values (storage submissions), and on this basisExecute any target command.
——Lorian wiki
Foreword
This tutorial is very long, and some information comes from Wiki, which is difficult. It is not recommended to instruction for novice to learn.
Take the threshold:
At least you can distinguish the coordinates, executors and execution directions;
Will use simple instructions such as/tp;
Will use the target selector;
You can use absolute coordinates, relative coordinates and local coordinates.
Overview
Execute instructions can be said to be the most powerful instructions in the original MC (without one). It helped the MC "order party" players solved a lot of problems (such as stepping on the square and obtained effect, etc.), and it is also the most commonly used in decrypted maps today.A instruction; when making a packet, we can often see its figure ... The such powerful instructions, but many players do not understand and do not use it. Then Baihe here will take everyone to know firstKnow it.
The purpose of the Execute instruction
The Execute instructions are mostly used to detect whether the entity enters a specific area, whether it is stepped on a specific block, etc. Many players use the Execute instruction to do the operations between the coordinates.Some cool special effects and the like.For example, me
The development and climax of the Execute instruction
When it comes to instructions, we have to understand the climax of its history and development, so that we can explain slowly later.
In the official version 1.8 issued by the official in 2014, the Execute instruction was successfully added to the game. Since thenThe output increased rapidly, such as the more popular map "Look UP" trilogy at the time, which used a large number of Execute instructions.
The Execute instruction was then put on the "Box Box" after version 1.8.Great tragedy
Later, in the 1.13 snapshot version released by the official in 2018, a major decision -flattened, which made many instructions before 1.13 unable to "inherit" 1.13 and it later, which gave many "ordering the party to the party"The player came with a" fatal "blow, because many of the newly made maps could not run in the new version, but this exactly gave the Execute instruction a" progressive space ".
1.13 Flatming the instructions such as Testform/Testforblock/TestforBlocks and other instructions to Execute.The unknown small corner is waiting for being discovered.
The words are homely, and in the flatization of 1.13, the Execute instruction has added a lot of prepositions and conjunctions, such as: as, at, if, etc.
Players usually feel tedious and boring about the addition of these prepositions, but this actually greatly improves the frequency of use instructions in the subsequent version. Because of the addition of prepositions, their syntax is split, and the Execute instructions can now become even more become moreDiversification and comprehensiveness. Now it can be said that Execute instructions are almost the highest frequency and most powerful instruction in the map.
Instruction
1.13 below
The command format of Execute in version 1.13 is:
/executeDETECT
/executeEXECUTE ...
/execute
Because today's focus is not the Execute instruction below 1.13, so I do n’t introduce it here. Let ’s take a brief example:
/execute @P ~ ~ ~ ~ ~ ~ 1 ~ 1 ~Minecraft: Wool 0 Effect @P Minecraft: Speed 10 5
The use of this instruction is that when the player stepped on the white wool, it was given a speed effect of 11 and lasting for 5 seconds.
1.13 version and above
This is the point, I hope readers can take notes.
1.13 adds many modifier commands (commonly known as prepositions), conditional commands (commonly known as conjunction), storage sub -commands, and Run sub -commands for the Execute instructions. As of recent updates, 1.19.4 has a total of 14: A total of 14:
Modifying the sub -command: Align, Anchored, As, AT, Facing, on, in, Positiond, Rotated, Summon;
Conditional command: if, unless;
Storage submissions: Store;
Executive sub -command: RUN
Execute command allows arbitrary commands to connect together.The sub -commands except the Run sub -command can be arranged or reused multiple times at will, and the Run sub -command can only be used once and can only be at the end of the command.The command must end at the condition of the conditioner or the Run sub -command, otherwise there is no actual effect.For multiple sub -commands, the system will be processed in order in order in order. For example, the following commands are different:
All the entities move in the direction of their respective dynasty:
Execute as @e at @S Run TP^^^1
All entities move to the leader of the executor:
Execute at @S AS @E Run TP^^^1
The game will process other sub -commands before handling the Run sub -command and storage submissions, so the Run sub -command and storage submissions cannot affect other sub -commands.Run sub -commands and storage submissions cannot affect each other.In some cases, the command will be suspended.
If the command is executed without stopping, the number of successful times and a result will be returned. Both values come from the conditioner command or the Run sub -command at the end.Note that the return value of the command must be an integer.The number of successful times is usually 0 or 1.But if this command is separated many times (such as through AT @a), the number of success can be greater than 1.When the command is not executed successfully, the two return values are 0.When the ending conditions or the RUN sub -command are executed multiple times, only the last execution value is returned.These two values can be stored by the storage sub -command.
When the command block is used to execute the command, they will return them to the command block. This can be used to detect whether the command block of the conditional constraint is successful. You can also use the redstone comparator to read the number of successful times.
Modifier command
Modify the command to modify the command variable and change the command execution method, so as to use specific executors, execution positions, execution dimensions, and execution to execute the follow -up subsequent subsequent subsequent subsequent subsequent subsequent subsequent subsequent subsequent subsequent subsequent subsections.
align
Uses: Convert the execution position to a square coordinate (take it down)
Format: Align
Parameter:
Effect: Change the execution position of the command
Error: When the parameters are not x, y, z Times wrong
explain:
/execute align xyz run tp @s ~ ~ ~ ~
This instruction is to transmit themselves to X coordinates, Y coordinates, and Z coordinates to be taken downwards. Assume that the player's position is x = 2.2, y = 5.6, z = 10.5.To x = 2, y = 5, z = 10.Of course, there are more advanced usage, we can pick out a certain coordinates separately for execution:
/Execute Align y run tp @s ~ ~ ~ ~Then if the player's position is still x = 2.2, y = 5.6, z = 10.5, then the command executes after executionThe position was moved to x = 2.2, y = 5, z = 10.5, and so on. If you want to take the Z coordinate down, write Z behind Align. Of courseJust write XZ later.
anchored
Uses: Use this command to switch the benchmark point to the position of the physical foot or eyes, and the default is the foot (such as when using a relative coordinate or facing)
Format: ANCHORD
Parameter: The benchmark is the location of the eye (EYES) or the position of the feet (feet)
Effect: ^ ^ The positioning of the benchmark is the benchmark as the eyes or feet
Error: When the parameters are incorrect, the error is reported.
explain:
You can use the/TP instruction to intuitively feel the effect of this submissive command:
/Execute Anchored Eyes Run TP @s^^^^
After executing, the legs of the commander will be moved to the eye position of the commander of the commander. After^, you can also add numbers:
/Execute Anchored Eyes Run TP @S^^^2
After the execution, the player's leg will be transmitted to the position of 2 cells in front of the eye. If the player's perspective is facing the square, then it will also be transmitted directly to the square.You only need to add numerical values to the corresponding position. Here are two examples (the former is transmitted to the 2 -grid position above the eyes, and the latter is transmitted to the 5 -square position to the right):
/Execute Anchored Eyes Run TP @S^^2^
/execute anchored eyes run TP @S^-5^^
This^symbol and ~ symbols must be distinguished.^Is the coordinate of the perspective, ~ it is the player's position, which means that when your screen is 90 degrees below,^^^2 is actually the one under your feet.Block (the legs also occupy 1 square block); and ~ no matter which direction you faces, ~ ~ 2 will always be the coordinate position of your Z axis plus 2.
AS
Uses: The executor who changes the command, but does not change the execution position or the execution direction, etc.
Format: AS
Parameter:
Error: When the parameters are incorrect, the error is reported.
explain:
This sub -command is common, especially the speakers in some dialogues, etc., let's take an example:
/execute as @e [name = "Rebirth is hope"] Run Say everyone, I am a meow machine!
After running this series of instructions, you will see all the entities (including armor frames, fireballs and other non -biological entities such as armor frames, fireballs and other non -biological entities) in the chat bar in the chat bar."" ""
Of course, the AS sub -command not only has the role of dialogue: there is a @S (command executing entity) in the entity selector, and the AS submissions will turn the rear execution entities at the run into the entity provided by the
/execute as @e [name = "Rebirth is hope"] Run TP @S 0 0 0
If you run this instruction, you will find that what you are transmitted is not your premise that you do not call for rebirth, but all entities named "Rebirth is Hope" are transmitted to x = 0, y = 0, z = 0 positions.In fact, the above is just an example. This instruction can be simplified to:
/tp @e [name = "Rebirth is hope"] 0 0 0
The AS -order command is not recommended to use players who do not fully understand the Execute instruction, because its execution coordinates and execution directions will not change, which means that if the player uses ~ or^to modify the coordinates, there are often some problems.Suppose we enter this string of instructions and execute it in the command block (our idea is to transmit all the entity named "Daxuan" upward 3 grids):
/execute as @e [name = "Daxuan"] Run TP @S ~ ~ 3 ~
However, when the command executes, "Daxuan" did not transfer to the position of the 3 block above, but instead transmitted to the 3 cell above the command block!Why is this? This is because the AS sub -command does not change the execution coordinates of the command.Talking about this problem solution: AT sub -command.
AT
Uses: Change the execution position of the command, the orientation and execution dimension to specify the coordinates, orientation, and dimensions of the specified entity, and do not change the commander of the command.
Format: AT
Parameter:
Effect: Location, orientation and dimension update as the target entity (influence ~ ~ ~ and ^ ^ ^ positioning)
Error: When the parameters are incorrect, the error is reported.
explain:
The AT sub -commands are the same as the AS -submissive command. It is not difficult to see that AS is the executor, and AT is the position of changes to the execution. Then the two combinations can achieve both the executor of the command, and alsoYou can change the effect of the command execution position, or the example of the "Daxuan" above, we change it slightly:
/execute as @e [name = "Daxuan"] at @S Run TP @S ~ ~ 3 ~
After running, we can see that "Daxuan" was rumored to be sent to the position above 3, but this is a bit troublesome, because in this instruction, we pay attention to the execution of the coordinates instead of the executor, so we only onlyYou need to keep AT:
/execute at @e [name = "Daxuan"] Run tp @e [name = "Daxuan", limit = 1, sort = nearest] ~ 3 ~
The TP behind this instruction cannot be used @S, because there is no declaration of command executors in front, so I need to write it again @e [name = "Daxuan"], and in order to prevent "Daxuan" from being transmitted to other "Da Da Da Da Da Da Da Da Da Da Da Da Da Da Da Da" Da Xuan "On the Xuan ", we must limit its conveyor, not all" Daxuan ", but the closest" Daxuan "closest to this" Daxuan "can be transmitted.The "Daxuan" recent "Daxuan" is actually himself.
Many instructions can easily make mistakes in AS and AT sub -commands, because they do not know where to use AS or AT, and it is easy to mix the target selectioner, so there will be similar errors below:
/execute as @e [name = "Daxuan"] at @S Run TP @e [name = "Daxuan"] ~ 3 ~
This instruction seems to have no problem, but when the executors appear multiple, the loopholes are full, because in the TP instructions in the back, @E is transmitted to all the "Daxuan" to the position of the "Daxuan".There are so many "Daxuan", and the system does not know which "Daxuan" you will be transmitted, so at this time the instructions will be transmitted in order in the order of traversal.The first "Daxuan" traversed above, and because each "Daxuan" executed once, in fact, the "Daxuan" was transmitted to the number of "Daxuan" on the field, so it transmitted upwardThe length is equal to the number of 3 × "Daxuan".The AT sub -command will also be positioned to the dimension, which means that this instruction can be executed across the dimension. For example, assuming that the smart bear is in the lower bound, I enter this series of instructions in the main world:
/execute at @e [name = "Smart Bear"] Run TP @S ~ ~ 3 ~
After the command is executed, I will be transmitted to the lower bound.
faciling
Uses: Change the execution of the command to the designated coordinates or a certain entity, without changing the commander and execution position of the command.
Format: FACING
Parameters:
Effect: Change towards the designated coordinates or target entities
Error: When the parameters are incorrect, the error is reported.
explain:
Facing sub -commands are more complicated. It not only allows coordinates, but also allows the entity, but has in common with the AT and AS sub -commands. Since this order command is not commonly used, there are a few examples here:
/execute as @e [name = "Smart Bear"] at @s Facing 0 0 0 0 Run TP @S^^^1
After the execution, all entities named "Smart Bear" will move to X = 0, Y = 0, Z = 0. This command can be used to calculate the pyrothebroken theorem, manufacture attraction, and so on.
/execute as @e [name = "Smart Bear"] at @s Facing Entity @e [name = "Little Le", sort = Next, Limit = 1] Feet Run TP^^^0.5
After the execution of this instruction, all the "smart bears" will move 0.5 grids to the nearest "small music" legs. This instruction is usually used to customize the AI capture system.
/execute as @e [type = "smart bear"] at @s faciling entity @p free run tp @S ~ ~ ~ ~ ~
Let all "smart bears" look at the nearest players.
in
Uses: set the command execution dimension as a specific dimension, the command will be executed in the specified dimension
Format: in
Parameters:
Effect: Update execution dimension
Error: Metropolitan errors or no time to report errors
explain:
This instruction is very simple. I believe everyone understands a few examples. The position of the player to the lower bound x = 0, y = 0, z = 0:: The_Nether Run TP @S 0 0 0
This instruction focuses on coordinates and is usually not used with AS. If you use the Facing sub -command to make the execution direction facing different dimensions, it will be invalid.
When the executor commands have a relative coordinate (~) or a local coordinate (^), pay attention to the coordinate mapping ratio of the target dimension position and the current dimension position (the mapping ratio of the following boundary and the main world is 1: 8).
on
The ON sub -command is a new sub -command in 1.19.4, which is powerful and comparable to as, at.
Uses: Set the performer as an entity with a specified relationship with the current executor.
Format: ON
Parameters:
Attacker: The final entity that hurts the current executors in the last 5 seconds.
Controller: Control the entity of the current executor.
Leasher: Use tie rope to traction the entity of the current executor.
Origin: The source of the current executor:
If the current executor is a ejaculation, it is the launch.
If the current executor is an item, it is the throw.
If the current executor is a regional effect cloud, it is the source.
If the current executor is the activated TNT, it is ignited.
If the current executor is the tip of the demon or the ghost, it is the summoner.
Owner: The current executor is the owner of this entity when it is tame creature.
Passengers: Directly ride in the entity of the current executor.
Target: Attack target of the current executor.If the current executor is an interactive entity, it is the player who interacts with him.
VEHICLE: The entity that is riding by the current executor.
Effect:
If the specified relationship is not suitable for the current execution entity, or if there is no matching entity in this relationship, 0 elements are returned.
When the parameters are incorrect, it is deemed to be grammatical errors.
If this parameter cannot be parsed as one or more effective entities (designated players must be online), the command is terminated to terminate the execution.
Explanation: This sub -command can well control the entity of the active relationship with the commander of the commander. It should be noted that if the entity you want to control is not your own, then you need to add the AS submissive command to change the command executor.Example:
/execute as @e [name = "white crane"] on attacker run kill @s
Within 5 seconds of killing, all the last entities that launch an attack movement that can be tested nearby can initiate the attack action.
positioned
Uses: At the specified coordinate execution command, change the execution position, but does not change the executor and the execution direction
Format: POSITIONED
Parameters:
Effect: Change the execution position of the command
Error: When the parameters are incorrect, the error is reported.
explain:
The PositionEd and AT sub -commands have in common. Their role is to change the execution position of the command, but the difference is that AT is aimed at physical coordinates.The
/Execute PositationEd 0 0 0 0 RUN GIVE @P Minecraft: Diamond 5
After executing the command, the system will give the distance x = 0, y = 0, z = 0 recently given 5 diamonds, and the same is true of the same entity:
/Execute PositationEd as @e [name = "Little Le"] Run Give @P Minecraft: DIRT 64Give 64 dirt.
rotated
Uses: Set the execution of the command as a specific direction, or to the orientation of the specified entity, change the execution of the orientation, and not change the executioner and the execution position
Format: rotated
Parameters:
Effect: Change and detect direction angle
Error: When the parameters are incorrect, the error is reported.
Explanation: It is the same as the Facing sub -command, but this is to set the execution of the commander to set the orientation of the specified entity. Because it is not commonly used, there are a few examples here:
/execute as @e [name = "small music"] at @s rotated as @p run tp @s^^^1
Let all the "little music" move towards the direction of its recent players.
/execute as @e [name = "small music"] at @s rotated as @p run tp @s ~ ~ ~ ~ ~ ~
Let all "little music" face the direction of the recent players.
summon
Uses: Immediately generate a specified entity, and set the command executor to this entity
Format: Summon Parameters: Effect: Summon entity, and set it as the command executor (equivalent to/summon after use/execute as) Error: When the parameters are incorrect, the error is reported. Explanation: The Summon sub -command is equivalent to/summon and uses AS submissions after using the AS sub -command.Flexible instructions (you can choose to use AT or Positiveite sub -commands in front of the Summon sub -command to modify the physical generation position of the entity), and you can directly control the specified entity when making a data packet or writing a command block instruction without changing the entity TAG tags without changing the physical TAG tags.Essence Examples provided by wiki:/Execute Summon Villager Run Damage @E [Type = IRON_GOLEM, SORT = Nearest, Limit = 1] 1 GENERIC BY
Generate a villager in the player's location and let it cause 1 point to the nearest iron puppet () ordinary damage.
Conditional command
Conditional command IF and Unless are used to limit commands and only execute under specified conditions.If if ..., unless is unless ... otherwise.In addition, both have the same parameter structure.
If the conditions of the conditioner are executed separately without using the storage submissions command and the RUN sub -command, the Execute command will report whether to match the successful number of the command, and the number of successful matching is used as the return value.There are several different types of conditions:
(IF | Unless) Biome -detecting the biological group department at the specific block
(If | Unless) Block -detect a single specific block
(IF | Unless) Blocks -detects the matching situation of the blocks in the two rectangular areas
(IF | Unless) Data -Data for detecting blocks, entities or storage
(if | unless) Entity -test whether the specified entity exists
(if | unless) Predicate -specify whether the predicate passes
(IF | Unless) score-score of detection target
Effect:
At the end of the Execute command: For if, if the condition is established, the command is successful, otherwise it fails.For Unless, if the conditions are not established, the command is successful, otherwise it will fail.
In the middle of the Execute command: For if, if the conditions continue to execute the follow -up sub -command, the execution will be terminated.For Unless, if the conditions are not established, continue to execute the follow -up sub -order, otherwise the execution will be terminated.
biome
Used to compare whether the biological group on the positioning is in line with the given biological group ID or biological group label
Format: IF/Unless Biome
explain:
Biome parameters can be used to detect whether specific coordinates are a biological group, but usually coordinates are not a constant, but are used with AT parameters:
/execute as @e [name = "pineapple"] at @s if biome ~ ~ ~ minecraft: forest run effect give @s mincraft: Speed 0 1
This series of instructions will do this during the runtime: If the "pineapple" will give the "pineapple" a level of 1 and 1 second of speed in the biological group "forest".
block
Whether the block for a given position is a given square ID
Format: IF/Unless Block
explain:
The Block parameter is equivalent to the role of the testforBlock instruction before 1.13. It can detect whether the specific coordinates are a block (can be attached with a NBT tag):
/execute as @a at @s if block ~ ~ -1 ~ Minecraft: Glass Run SetBlock ~ ~ -1 ~ Minecraft: Air
The instructions will be made when running: When the player's feet are glass, it will be replaced with air.
blocks
Used to compare the two cubes of the two rectangular areas that compare the same size
Format: IF/Unless Blocks
explain:
The Blocks parameter is equivalent to the TestforBlocks instruction before 1.13. It can be used for whether the blocks in the larger range (can be added with NBT tags), and the comparison mode can be ALL (compared with all blocks) or Masked (ignore air block). Because this parameter is more relativelyFlexible, I do n’t write an example here.
Data
Used to check whether the target block, entity or storage NBT have a given NBT tag
Format: IF/Unless Data Block
The usage is more complicated. It is recommended to study it by yourself after being familiar with the NBT label. I will not introduce too much here.
DIMENSION
Detect whether the dimension when the command is executed is a specific dimension
Format: IF/UNLESS DIMENSION
explain:
Dimension is not difficult, but it should be noted that when detecting the dimension is to detect the execution of the coordinate dimension rather than the dimension of the executor.
Entity
Check whether one or more specific entities exist
Format: IF/Unless Entity
explain:
The Entity parameter is equivalent to the testfor instructions before 1.13. It usually does not use it alone. It will cooperate with some specific tags for use. For example:
/execute if entity @e [name = "pineapple", distance = .. 3] Run Give @a Minecraft: Diamond 2
If the "pineapple" is less than 3 in the command execution, then two diamonds are given to all players.
loaded
To detect whether the block where a coordinate is located has been loaded
Format: if loaded
usage:
The coordinates must be a block coordinate, which means that this position must be an integer coordinate. You can also use relative coordinates. If the relative coordinates are decimal after participating in the operation, it will be automatically taken down.
predict
Used to check whether the predicate passes (the result is positive)
Format: IF/Unless Predicate
usage:
Involved in JSON text, no introduction here, readers who want to know can inquire about what the predicate is.
score
Whether the score of the score in the scoring panel that specifies the target scoring board is as the score of the score of the score of the notes of the other (or the same) target conforms to the specified relationship, or whether it is within the given range
Format: IF/Unless SCORE
explain:
SCORE parameters are often used for bubbling sorting and winning and defeat in the game. For example (the target score here is scores):
/Execute if score referee Scores> Badass Scores Run Give Minecraft: Gold_block 1
Here is the score of "referee" than the score of "Badass", then give a gold block to the "Magistrator".
Storing subdue command
The storage submissions can allow the resulting result returned by the command after executing or the number of successful times in the scoring board, NBT data, or BOSS column, and there are two modes: Store Result and Store Success.Note that the return value of the command must be an integer.The return value of each command is recorded or text records on the corresponding page.This chapter is more complicated, so it only shows the purpose.
There are five different storage modes:
Store (Result | Success) Block -stored in the square NBT
Store (Result | Success) Bossbar -Store (Result | SUCCESS) Entity stored in the data stored in the BOSS column -
Store (Result | Success) Score -
Store (Result | Success) Storage —— stored in the stored NBT
block
Store the return value to the label data in the block entity.It can be stored as a format of byte, short integrity, integer, long integer, floating point, or dual -precision floating point.If the return value is decimal, it will be taken down and then multiplied by a certain
bossbar
Stay the return value of the command to the current or maximum value of the BOSS column.
Entity
The return value or successful number is multiplied by
score
Use the
storage
Stay the return value or successful number in the specified NBT label of the specified storage container. If the target storage container does not exist, it will be created.
When the execution is successful, the return value is taken down and multiplied by the
Execute sub -command
It only contains the Run sub -command, and the commands to be executed later must be followed.
Format: Run
Parameter:
Results: After executing this command, the specified command is successful when the execution is successful, and the failure when it fails
explain:
The Runzi command has seen many examples before, and some things are emphasized here:
The Run Zi command can also execute the Execute instruction behind it, but this is not meaningful. In the Execute instructions, the Execute instruction
Runzi command will reset the COMMAND Dispatcher's root node when executing
The Runzi command will not use any execute submissions in the back unless you use the Execute instruction again, which means that an Execute instruction can only execute one instruction
Common Execute sub -command nested combination
Triggered when stepping on a specific block:
/execute as @a at @s if block ~ ~ -1 ~run
Used to execute commands at the entity:
/execute at @a run
Place the square in the place where the player's cross is alert:
/execute as @a at @S Run SetBlock^^^2
Used to test whether the player has reached a specific position:
/execute if entity @a [x =, y =, z =, distance = .. 1] Run
1.13 What are the advantages and disadvantages of Execute instructions