top of page

Execute

This tutorial will teach you about execute. If you have come here to know what the 1.13 version of the 1.12 command is then here it is execute as [selector] at @s run [command]. However we will be going into more detail into each of the sub commands. The main sub commands are "as", "at", "if", "unless" and "run". There are other commands but I find these 5 are the ones used most of the time. To use the execute command you need a selector first. Use the one below.

The order I listed them in is the recommended order to type them in. It is customisable except run has to be last. Okay so as/at are each half of the 1.12 execute. Say you want every entity to say hi. You would use as. Say you want every entity to have the block above them turn to stone. You would use at. Which one to use depends on whether you need the position or the @s. If you need @s which is the executing entity then that will need as. The one you set with as is @s. The reason as is first is so you can use @s rather than type the entire selector over again. If you need both do as and then type at @s after.

​

If and unless are next. These might seem useless at first as you could just use the main selector to specify all information. That is wrong. You can use it on other entities not just the executing one. In one of my super pig commands to transform cows into pigs I needed 2 executes. In 1.13 I made that one. What I did was in 1.12 /execute @e[type=pig] ~ ~ ~ execute @e[type=cow,r=5] ~ ~ ~ summon pig. The 1.13 command is now /execute at @e[type=cow] if @e[type=pig,distance=..5] run summon pig. Unless is the opposite of if. So if the statement is true don't run. This can be useful for example in my super effect I didn't want it to be if you have a sneak of 0 make the carpet because pigs and other entities will have a sneak of null. So I made it unless there is a sneak of at least 1. I will let you figure what these commands are on your own.

​

The final subcommand is run. After this you will specify a command and it will run.

​

Ok I will quickly go over the rest of the subcommands in order of usefulness. First is align. This will align along an axis. For example if you want to summon a shulker to be the collision box for a custom block you would need to align it. For this you can do /execute align xyz run summon ~0.5 ~ ~0.5 shulker. This aligns it but since the mob uses those coordinates to specify its center it would be at the corner so that's why there is an offset. The xyz part can be changed for whatever axis you want.

​

Next is anchored. Recently I wanted to summon an item behind a players head so they wouldn't see it. Here's how you could do it with anchored. /execute anchored eyes run summon ^ ^ ^-1 item. It can also anchor to feet aswell.

Now onto facing. It is more useful however I rarely use it so thats why its third. /execute facing entity @e[tag=target,limit=1] eyes run tp ^ ^ ^1 this is an example where you want to face an entity. If you want to go to a target for example with a grappling hook you would face the entity marking the grappling hook and tp ^ ^ ^1 for example. If you allow multiple entities then the command will execute for each of them. Also at the end is the eyes or feet from the anchored subcommand. You can also face a block like /execute facing ~ ~1 ~ run say hi.

​

Next is positioned and rotated. These are each a half of the at functionality. For positioned the syntax is either positioned as @e[tag=target] or positioned ~ ~1 ~. It works similar to the facing subcommand however replace entity with as. For rotated it is the same except for if you want to specify numbers there is only two, one for yaw one for pitch, ie rotated 45 90. Yaw is up or down pitch is left or right.

​

Next is in. This is very simple but allows you to change dimensions. However that area must be loaded. For example execute in minecraft:the_nether run setblock ~ ~ ~ diamond_ore will allow you to summon diamond ore at that location but in the nether. This works for all 3 dimensions.

​

Last is store. It is very advanced and if I'm honest I've never used it and only seen it once. This has it's own tutorial in the intermediate section it is very complicated and I need to make sure the tutorial is perfect and easy to understand.

bottom of page