How To Use The /execute Command - Minecraft: Java Edition
Maybe your like
Help Sign In/Register
- Home
- Minecraft Forum
- Minecraft: Java Edition
- Redstone Discussion and Mechanisms
- Commands, Command Blocks and Functions
- How To Use The /execute Command
- ||
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- …
- 12
- Next
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- …
- 12
- Next
- ||
- Home
- Minecraft Forum
- Minecraft: Java Edition
- Redstone Discussion and Mechanisms
- Commands, Command Blocks and Functions
- How To Use The /execute Command
Tag » How To Use Execute As Command In Minecraft
-
Commands/execute - Minecraft Wiki - Fandom
-
How To Use The Execute Command In Minecraft
-
Minecraft Execute Command [1.19] Tutorial - YouTube
-
How To Use /execute Command In Minecraft 1.17 (Java Edition, PC)
-
New Execute Command Support In Minecraft Version 1.19.10
-
What Does The /execute Command Do In Minecraft: Java Edition?
-
Useful Guide For Minecraft Bedrock Commands And MCFunction
-
Anyone Know How To Use The New /execute Command? - Reddit
-
Why Do I Have To Put At @s In A Execute Command? - Arqade
-
How To Use Execute Command In Minecraft - Bilibili
-
How To Use The Execute Command (Beginer Tutorial) For Java And ...
-
How To Use The Execute Command In Minecraft - Info Toast
-
In Minecraft Execute Command At Entities Around An Arrow
-
Essential Commands - Minecraft: Education Edition Support
Pre-note: For 1.13+, see here.
Note: This is to clarify the /execute command's syntax and abilities. It is NOT a place to ask for help with /summon, /scoreboard, selector arguments, or data tags. The syntax for the /execute command is
/execute {selector} {x} {y} {z} {command}but what does it mean? At first, I couldn't figure it out. In fact, I almost posted on the bug tracker. But after some thought, this paradoxical command started to make sense. Who's Executing? First, this part selects the entity:
/execute {selector}The can be @p, @r, @a, or @e with all the parameters. For example,
/execute @e[0,70,0,5,type=Creeper,name=Bob]will select all Creepers within a radius of 5 blocks of coordinates (0,70,0) named "Bob". Now...Where To Execute? This next part may seem redundant, but it has a use.
{x} {y} {z}determines the coordinates where the command will be executed. For the previous example,
/execute @e[0,70,0,5,type=Creeper,name=Bob] ~ ~5 ~Will now execute the command not at the Creeper's position, but five blocks above the Creeper. Just imagine that you first find a Creeper at (0,70,0), then the Creeper executes a command at (0,75,0). Now, using fixed coordinates for this is completely redundant. This is used for when an entity may be moving; the command will always be executed in the same position relative to the entity. Finally...What To Do And now, the actual command:
{command}This is a full command with all the arguments, including player selectors. So this,
/execute @e[0,70,0,5,type=Creeper,name=Bob] ~ ~5 ~ give @p[r=3] stonewill make all Creepers named Bob at most five blocks from (0,70,0) give the nearest player within three blocks of the block(s) five blocks above said Creepers stone...right. Anyways, the command can even be the /execute command itself, which can lead to some interesting scenarios. As a last example,
/execute @e[type=Chicken] ~ ~ ~ execute @p ~ ~ ~ give @p stonewill have all Chickens force the nearest player to give themselves stone. Execute Detect The execute command has an alternate syntax:
/execute {selector} {x} {y} {z} detect {x} {y} {z} {block} {data} {command}This part allows for the command to test for a block at a certain position.
detect {x} {y} {z} {block} {data}The coordinates may be relative or absolute, allowing for the command to test if a certain block is around an entity. Using the example command:
/execute @e[0,70,0,5,type=Creeper,name=Bob] ~ ~5 ~ detect ~ ~-1 ~ minecraft:wool 14 give @p[r=3] stoneThis will give said players stone only if the detected Creepers have red wool one block below them. In full sentence structure: "Execute five blocks above all Creepers named Bob within five blocks of the coordinates (0,70,0) with the block red wool one block below them, a command that gives the nearest player within three blocks stone." The damage value of the block is required, however it can be set to -1 to test for any damage value. This can be used to test for any type of stone brick, or for any color of wool.
Last edited by kwerti: Jul 25, 2017 Rollback Post to Revision RollBack- Zombie Killer
- Join Date: 10/2/2011
- Posts: 163
- Minecraft: steved14000
- Member Details
wow, this is pretty awesome- Tree Puncher
- Join Date: 10/8/2012
- Posts: 37
- Member Details
can you help, i need to figure out a way for a shot arrow to remove a torch when the arrow is in the block the torch is in, i already have the basic part /execute [type=Torch] ~ ~ ~ but when i try to do /execute [type=Torch] ~ ~ ~ fill ~ ~ ~ ~ ~ ~ air replace torch 0 it doesnt work- Zombie Killer
- Location: Nope
- Join Date: 11/7/2013
- Posts: 171
- Location: Seven
- Minecraft: TheDerpBoy
- Member Details
For that it would be something like: /execute @e[type=arrow] ~ ~ ~ setblock ~ ~ ~ air 0 replace Rollback Post to Revision RollBackIf you're reading this, then you're definitely not a sandwich. Sorry, my dear, but I don't give a snickerdoodle.
Spoiler alert!
I am not a toenail.- Tree Puncher
- Join Date: 10/8/2012
- Posts: 37
- Member Details
ok thanks it works Rollback Post to Revision RollBack- Out of the Water
- Join Date: 9/12/2013
- Posts: 5
- Member Details
Hi! Im making a hide N seek map where I execute command to players with a certain score so i do this kind of command: execute @a[score_bedrock_min=1] ~ ~ ~ summon FallingSand ~ ~ ~ {TileID:145} i hook it to a clock but then it writes: [12:37:10] The entity UUID provided is in an invalid format What should i do?:huh: Last edited by Marcusher_: Aug 27, 2014 Rollback Post to Revision RollBack- A Space Odyssey
- Join Date: 1/18/2013
- Posts: 2,013
- Location: Louverdahl
- Member Details
First, check that there is in fact a player which fulfills the requirements. Also, numeric IDs no longer exist in NBT data. Use /execute @a[score_bedrock_min=1] ~ ~ ~ summon FallingSand ~ ~ ~ {Time:1,Block:"minecraft:anvil"} Rollback Post to Revision RollBack- Tree Puncher
- Join Date: 1/3/2014
- Posts: 32
- Minecraft: spicylevel2
- Xbox: minergordon
- Member Details
could you help me. im trying to experiment and make blocks placed wherever i go, but the command doesent work. /execute @a -1 ~ ~ setblock minecraft:command_block Rollback Post to Revision RollBack- Out of the Water
- Join Date: 8/28/2014
- Posts: 9
- Member Details
It seems you made a simple mistake. You forgot to put in the coords for the setblock command. I tried it with torches, and it worked amazingly. Here it is: execute @p ~ ~ ~ setblock ~ ~ ~ minecraft:torch You also forgot to put a " ~ " before " -1 ". Last edited by ScorpionGamer880: Sep 20, 2014 Rollback Post to Revision RollBack- A Space Odyssey
- Join Date: 1/18/2013
- Posts: 2,013
- Location: Louverdahl
- Member Details
It is currently impossible to do this with the execute command. You probably want /stats and /scoreboard objectives, which is far too advanced for me. Rollback Post to Revision RollBack- A Space Odyssey
- Join Date: 1/18/2013
- Posts: 2,013
- Location: Louverdahl
- Member Details
You need to specify the player and coordinates of the spawn point /execute @a[score_home_min=1] ~ ~ ~ spawnpoint @p ~ ~ ~ Last edited by kwerti: Sep 13, 2014 Rollback Post to Revision RollBack- Tree Puncher
- Join Date: 7/3/2013
- Posts: 13
- Minecraft: KaizoBlade
- Member Details
Can someone tell me why this doesn't work? /execute @e[type=!Player,type=!Rabbit] ~ ~ ~ /summon LightningBolt ~ ~ ~ It's striking the player even when I don't want it to. Rollback Post to Revision RollBack- A Space Odyssey
- Join Date: 1/18/2013
- Posts: 2,013
- Location: Louverdahl
- Member Details
There can only be one of each parameter. Rollback Post to Revision RollBack- Tree Puncher
- Join Date: 11/7/2012
- Posts: 18
- Member Details
Hi, I'm wondering if there's a way that you could detect if an entity DOESN'T exist, instead of just inverting the signal (as that does eat up time) Rollback Post to Revision RollBack- Tree Puncher
- Join Date: 7/3/2013
- Posts: 13
- Minecraft: KaizoBlade
- Member Details
Is there a way to make it so I can target multiple targets? Rollback Post to Revision RollBack- A Space Odyssey
- Join Date: 1/18/2013
- Posts: 2,013
- Location: Louverdahl
- Member Details
Not with a single command. You will have to use one command per entity. Rollback Post to Revision RollBack- Tree Puncher
- Join Date: 7/7/2014
- Posts: 30
- Minecraft: KnightSirCody
- Member Details
I know you might not see this but you need to make a command block with this command: /testfor @p {SelectedItemSlot:0,Inventory:[{Slot:0b,id:"minecraft:feather"}]} Unfortunately that only works for on the first slot on your hotbar and if you wanted it to be all hotbar slots you'll have to set this up multiple time using 0-8 for hotbar slots 1-9. For the commandblock testing for the feather in a sselected slot you will need a redstone clock hooked up to it so it runs forever. You will then need to put a comparator next to the command block so that that when the command block successfully finds the feather in your hand it will get a signal taken out by the comparator. Now have that comparater run into a command block that has /execute @p ~ ~ ~ particle cloud ~ ~ ~ 1 2 1 0 10000 P.S i didn't change the particles part so i don't know if it will work, I've never been good with the particle command stuff Rollback Post to Revision RollBackhttps://www.youtube.com/channel/UCdBhYidKks49-AiLxAeCCog
Redstone, Command blocks, PVP, Archery, Building, and all your other minecraft needs.
- Newly Spawned
- Location: Somewhere
- Join Date: 10/5/2014
- Posts: 2
- Location: In a place
- Minecraft: Lucario400
- Xbox: Linkario400
- Member Details
my command: /execute @p ~ ~ ~ summon Slime @e[type=Pig, r=7] ~ ~ ~ Not sure whats wrong. Rollback Post to Revision RollBack- A Space Odyssey
- Join Date: 1/18/2013
- Posts: 2,013
- Location: Louverdahl
- Member Details
The /summon command does not have a player selector. You probably want /execute @e[type=Pig,r=7] ~ ~ ~ summon Slime ~ ~ ~ Rollback Post to Revision RollBack- Coal Miner
- Join Date: 6/13/2012
- Posts: 138
- Location: utube: AlphaAnimations
- Minecraft: Alpha_ThePro
- Xbox: AlphaFox_13
- Member Details
I am unfortunately the fasted way test if an entity doesn't exist is to do [1] /testfor @e[0,70,0,r=0,type=Blaze] then in the same tick directly after do [2] /testforblock ~ ~-2 ~ command_block 0 {SuccessCount:0} this asumes you have it like this [2] /testforblock -> comparator output to command block [3] [r ] power source (20hz clock normally) [1] /testfor @e if you want to be more specific with what you are trying to achieve i could possibly help more Last edited by Alpha_ThePro: Nov 9, 2014 Rollback Post to Revision RollBackBe involved in the Survival of Modding in the Post-Notch Era. Enigma + M3L + LiteLoader/API + BlazeLoader {ALL Open-Source!}