Blogs Tutorial

How does the /execute command work?

  • 7.7k views 0 today
  • 5
  • 5
  • 8
Siem_72
Lvl 32Artisan Pokémon
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!

More like this

  Have something to say?

RazorPlayz
01/25/2016 11:06 am
Level 4 : Apprentice Nerd
This will help out so much with my map! i will sub, thank you :)
1
Siem_72
01/25/2016 5:19 pm
Level 32 : Artisan Pokémon
Glad I can help!
1
Orbiter
06/13/2015 1:51 pm
Level 49 : Master Fox
Very helpful! :D
1
Siem_72
06/13/2015 2:58 pm
Level 32 : Artisan Pokémon
Thanks! I'm glad to hear that!
1
chrisdude011
06/13/2015 9:24 am
Level 22 : Expert Pirate
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
Orbiter
06/13/2015 1:51 pm
Level 49 : Master Fox
Or maybe without the " / "
1
Welpjesfinx
06/13/2015 10:01 am
Level 43 : Master Architect
Try out /execute @p[score_OpenDoor=0,score_OpenDoor_min=0] ~ ~ ~ /say hi
1
Siem_72
06/13/2015 2:59 pm
Level 32 : Artisan Pokémon
Yes, that will work
1

Welcome