Minecraft Blogs / Tutorial

MEGATUTORIAL - Command blocks 2, Electric Boogaloo!

  • 527 views, 2 today
  • 5
  • 2
  • 4
ronsiv8's Avatar ronsiv8
Level 8 : Apprentice Miner
4
If you didn't see part 1, Check it out here!
Welcome back!
To our questionably long blog all about command blocks!
Today, hold on to your chair, becuase were checking out the EXECUTE command!
"But.. What is the execute command?" you may ask.
Its just most powerful command in minecraft! Why is that? It allows us to make if.. than commands! which means, we use it to ask the question If something something IS something something THAN do something something!
Pretty cool, right?
Well, the execute command allows us to do a lot more than that!


It allows us to target specific entities and run a command with them!
The scope of command is nearly endless, and it can do a lot!
LETS TALK SOME SYNTAX!
Okay, I gotta level with you. Were not gonna show the WHOLE execute command syntax here.
It's way too long.
It's very long.
So, were gonna talk about the most important command syntaxes:
Execute as
Execute if
Execute in
Execute align
Execute anchor.
Heres the good news: These are pretty simple.
Heres the bad news: There is a lot of math, especially with anchor.
But, don't click off yet! Ill make it simple. First off: Let's do some Execute as!
EPISODE 1: EXECUTE AS
Quick roundup of what execute as does: it targets an entity. The entity targeted can have multiple block offs: such as if your score is than run. The run subcommand can be typed after the targeted entity has been defined.
What does this even mean? Well, lets go through it, one by one.
Execute as targets an entity, using Selectors (check out the last tutorial) such as @a, @r, or @p. After that selector is defined, the subcommand RUN is used. Run is a simple subcommand that comes after an execute that allows you to run any command.
So, If i would like to give everyone, say, a stick, using execute, i would use:
/execute as @a run give @a stick
Yes!
But, you may say, This is kind of useless, since you could just use /give @a stick.
And you would be right!
But...
Does /give work with conditonal command blocks?
I dont think so.
You see, execute, depending on sucsess or failure, outputs a value that works with conditonal command blocks.
That is what makes the execute commands so powerful.
So, lets make an example, since for this command, out execute will always work unless there is nobody in the game to give a stick to. So, the execute command is confirmed to be useless and dumb.
Tutorial end!


...Okay, maybe that isnt true . We can make selectors that check for things. Renember the last tutorial?
We used
/execute as @a[scores={Scoreobjective=x}] run anycommand
Lets break this command down!
execute as @a, so were executing the command for all players, but, by using [scores={Scoreobjective=x}] we can check if the score of the player equals x.
But, you may ask, how can i make such cool custom selectors?
Heres a cool generator!
For creating such a selector as we can see in this command change the selection type to @a, and after that scroll down to Score. you can set a min and max score, but if you want it to be equal to one number, put the same number in the min and the max. Put in the score name and viola!
You may notice something called a "tag". They are another way of quite literally tagging people.
using /tag, selecting the targets who recive the tag (SELECTORS!!) add and the tags name.
To get a list of tag for a specific player, use /tag target(SELECTORS!!) remove and the tags name.
Tags can be very useful!
EPISODE 2: EXECUTE IF
Ok, look, you already got through the hard part of learning how the execute command works.
Execute if is not that different than execute as.
Quick roundup of execute if: It's execute as with only one entity as the target, but it can also target blocks.
So, if we would want, we could, say do this command:
/execute if score @a...
And we ran into a problem. Execute if can only target a single player / entity.
a command that would work would be:
/execute if score @p score = 1
you can also do if score > 1 (if the score is bigger)
if score >= 1 (if the score is bigger or equals)
if score < 1 (if the score is smaller)
if score <= (if the score is smaller or equals)
One more thing about execute if -
Execute if blocks is useful, because it allows us to check if a block at an x y and z is a block of a type, and output a command.
That means, that you can use this command to check if the block in the coords entered is a grass block -
/execute if block x y z minecraft:grass_block run ANYCOMMAND
EPISODE 3: EXECUTE IN
Were nearing the end here, hold on!
Execute in is super super simple. Executeing in means executing in a dimension, the only 3 as of 1.15.3 are The end, The nether and The overworld. so say, if we use this command:
/execute in minecraft:the_end run tp @p 0 0 0
it will tp us to 0 0 0 in the nether!
Fair warning, 0 0 0 is probably void since its very low. Oops!
EPISODE 4: EXECUTE ANCHORED

Execute anchor: Think execute as, but the coords are defined by where the player is standing, or where he is looking.
For this, the command syntax is: execute anchored EYES/FEET (where youre looking at) run ANY COMMAND.
So, if you would run this command (NOT A COMMAND BLOCK):

/execute anchored eyes run particle minecraft:flame ^ ^ ^1 0 0 0 0 10
you should see a flame particle right there, in front of your very eyes! Never thought i'd see the day...
WELL DONE!! YOU GOT THROUGH 2 OF THESE!!
You should know a LOT about command blocks, but theres still more to come! This series is nearing its end, And you being amazing at command blocks is also nearing!
Have a good day, any questions? Comment or private messege me!
Thank you so much for reading!
Tags

Create an account or sign in to comment.

1
05/21/2020 6:04 am
Level 31 : Artisan Scribe
Hawthxrn
Hawthxrn's Avatar
you have helped me a lot with coding here, please make more. I'm an actual trash coder, thank you for making these tutorials!
1
05/20/2020 10:54 am
Level 8 : Apprentice Miner
ronsiv8
ronsiv8's Avatar
The last part of the series will be uploded... soon!
2
05/08/2020 9:06 pm
Level 1 : New Miner
XManBoss6
XManBoss6's Avatar
Very helpful tutorial, hope to see a lot more of this series in the future!
1
05/16/2020 4:49 amhistory
Level 8 : Apprentice Miner
ronsiv8
ronsiv8's Avatar
Thank you! I am working on more!
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome