Minecraft Blogs / Tutorial

How does the /execute command work?

  • 6,964 views, 1 today
  • 5
  • 5
  • 8
Siem_72 avatar Siem_72
Level 32 : Artisan Pokemon
17
The /execute command is amazing, you can do so much cool stuff with it! You can run a command at certain entities!

Believe me, if you know how to use this command, you can create very cool mechanics and maps!

There are two versions of the command, the first one is the normal /execute and the second one is to detect for a block relative to the entity.


The first command is:
/execute <entity> <x> <y> <z> <command>

And the second command is:
/execute <entity> <x> <y> <z> detect <x> <y> <z> <block> <data> <command>


So the first command executes a command relative to an entity. So if my command is:
/execute @e[type=Creeper,name=Bomby] ~ ~ ~ <command>
The command will be executed at every creeper named Bomby.

And if my command is:
/execute @e[type=Creeper,name=Bomby] ~ ~3 ~ <command>
The command will be executed three blocks above every creeper named Bomby.

If you want to kill everyone within five blocks of every creeper named Bomby, you have to use this command:
/execute @e[type=Creeper,name=Bomby] ~ ~ ~ kill @a[r=5]

I know, it's very complicated, but you can also use the /execute command to execute an /execute command:
/execute @e[type=Creeper,name=Bomby] ~ ~3 ~ execute @p[team=red] ~ ~ ~ summon LightningBolt
This will summon a lightning bolt at the closest player on team red to three blocks above every creeper named Bomby.

If you read this a hundred times, maybe you'll begin to understand...


Now, you can also detect for a block relative to an entity:
/execute @e[type=Creeper,name=Bomby] ~ ~ ~ detect ~ ~-1 ~ stone 0 kill @a[r=5]
This will kill everyone withing five blocks from every creeper named Bomby that is standing on a stone block.


This command can be very useful for map making, so try it out and let me know what you can make!
Tags

Create an account or sign in to comment.

1
01/25/2016 11:06 am
Level 4 : Apprentice Nerd
RazorPlayz
RazorPlayz avatar
This will help out so much with my map! i will sub, thank you :)
1
01/25/2016 5:19 pm
Level 32 : Artisan Pokemon
Siem_72
Siem_72 avatar
Glad I can help!
1
06/13/2015 1:51 pm
Level 48 : Master Fox
Orbiter
Orbiter avatar
Very helpful! :D
1
06/13/2015 2:58 pm
Level 32 : Artisan Pokemon
Siem_72
Siem_72 avatar
Thanks! I'm glad to hear that!
1
06/13/2015 9:24 am
Level 22 : Expert Pirate
chrisdude011
chrisdude011 avatar
Could you please explain why this does not work.
/execute @p[score_OpenDoor_min=0,max=0] ~ ~ ~ /say hi
If i have a score of 2 it still says hi and i want it to run only if a player has a score of 0
1
06/13/2015 1:51 pm
Level 48 : Master Fox
Orbiter
Orbiter avatar
Or maybe without the " / "
1
06/13/2015 10:01 am
Level 43 : Master Architect
Welpjesfinx
Welpjesfinx avatar
Try out /execute @p[score_OpenDoor=0,score_OpenDoor_min=0] ~ ~ ~ /say hi
1
06/13/2015 2:59 pm
Level 32 : Artisan Pokemon
Siem_72
Siem_72 avatar
Yes, that will work
Planet Minecraft

Website

© 2010 - 2023
www.planetminecraft.com

Welcome