Minecraft Blogs / Tutorial

"Only One Command" Tutorial | Infinite Commands in One Command Block

  • 21,373 views, 1 today
  • 8
  • 8
  • 5
TheJared802's Avatar TheJared802
Level 43 : Master Nerd
29
Hi! We all know and love those Vanilla Mods that are installed with only one command. Have you ever wanted to make your own but not known how? Well, I've got good news for you. Today I will be showing you how to make your own "Only one Command" commands. It may be a lengthy read and may take a bit of practice, but trust me, you'll get there.

Note: This tutorial is outdated, the commands only work in 1.8. I am in the process of writing a 1.9-compatible version of the tutorial.

It took me months of research to completely figure out how these commands work. What will happen is that you will summon FallingSand riding other FallingSand riding other FallingSand and so on. When the first one lands, the one riding it lands on top. This repeats until you have an infinite tower of command blocks. There are two ways you can do this. The first is with simultaneous activation, and the other is with sequential activation.

This tutorial has four parts. These parts are Simultaneous Activation, Sequential Activation, Adding a Terminator Block, and Debugging your Command. I recommend that you read all of these sections to create the best commands. Happy Minecrafting!

Simultaneous Activation

The command we will be using is /summon. Because we will be summoning blocks, we will be summoning FallingSand. For the coordinates, you could realistically put anything. However, for simplicity and convenience, I would highy recommend that you put the coordinates as directly above the command block. The y coordinate should be at least positive 1.6, but it is perfectly fine to put more. If you ever find that your command is not working the way you would expect, my first debugging suggestion would be to increase the initial y coordinate.

At this point, you should have this:
/summon FallingSand ~ ~2 ~

Now, we start adding the data tags. Yay... ?
Like most /summon FallingSand, the first few data tags will only apply to the first block that is summoned. There are a few tags that we will apply to all the blocks we summon. These are the TileID and Time tags. TileID will be 137 right now, which is the id for command blocks. However, for the first block, we will need to make TileID be 152. This is because we need to power one of the command blocks, and id 152 is the id for redstone blocks. You will understand better in a moment. Time will AWAYS be 1. Without Time being set to 1, our blocks would not last more than a fraction of a second.

How our command will work is that we will have mulitple command blocks, each riding the one beneath it. Every command block that is riding another block has a y-offset that allows the landing time to match perfectly. As the first command block lands, the one riding it lands on top of it because it is already located above it. When that one lands, the one of it lands as well, and the process continues until it runs out of blocks. In order to do this, we will need to use the Riding data tag.

By now, our command should like this:
/summon FallingSand ~ ~2 ~ {
TileID:152,
Time:1,
Riding:
{ }
}

Now, what do we put into our Riding tag? First, we need to say that the FallingSand will be riding other FallingSand. To do this, we need to state the "id" tag like in the following example:
/summon FallingSand ~ ~2 ~ {
TileID:152,
Time:1,
Riding:
{
id:FallingSand
}
}

Furthermore, the Riding tag will also have to include all the same information as our original entity. Because this is our first command block, TileID will be 137.
/summon FallingSand ~ ~2 ~ {
TileID:152,
Time:1,
Riding:
{
id:FallingSand,
TileID:137,
Time:1
}
}

You can also add another Riding tag within the ridden entity:
/summon FallingSand ~ ~2 ~ {
TileID:152,
Time:1,
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
Riding:
{
id:FallingSand,
TileID:137,
Time:1
}
}
}

You can put as many Riding tags as you would like. However, you need to provide at least one more command block than what your commands will be in. This is because we need one of the blocks to power all of the other blocks. This will make more sense later.

If you were to run the most previous example, you will notice that it summons two command blocks with a redstone block on top. The redstone block powers the command block on top, but not the one on the bottom. The top command block will be the activation command block. This means that it will use /fill to power the other command blocks.

You're probably thinking, "This is great and all, but how do I put commands in my command blocks?" Well, in order to access the data tags for the block itself, we first need to use the TileEntityData tag. Because it will be holding other tags, we will use curly brackets as its value.
/summon FallingSand ~ ~2 ~ {
TileID:152,
Time:1,
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
TileEntityData:
{
}
}
}
}

Within TileEntityData, we will use the Command tag.
/summon FallingSand ~ ~2 ~ {
TileID:152,
Time:1,
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
TileEntityData:
{
Command: "/say Hello!"
}
}
}
}

This is pretty straightforward.
The very first command block is the one that will use /fill to activate the others.
However many blocks you summon will be how many down your redstone block fill will be going. Or, you can just try it without the /fill and count.
In extent, we will be filling a tower of redstone blocks next to all of the command blocks you summon. Put your command in a command block and power it. Count how many total blocks were summoned (including the redstone block) and then subtract two. Let's say I were to use this command:
/summon FallingSand ~ ~2 ~ {
TileID:152,
Time:1,
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
TileEntityData:
{
Command: "/say Hello!"
}
}
}
}
}

If I put that in a command block and power it, I get a total of four blocks summoned. If I subtract two from four, I get two. This is how many negative y I will be going. Let's take a look at a basic /fill command:
/fill ~ ~ ~ ~ ~ ~ redstone_block

Now we need to make the x-y-z coordinates more accurate. For x1 and x2, put 1. This way we can make the redstone tower be next to the command blocks rather than replacing them:
/fill ~1 ~ ~ ~1 ~ ~ redstone_block

The z1 and z2 will stay as just ~. For y1, put -1. This way it only powers the command blocks beneath it and not itself. For y2, put the negative version of the value you came up with by counting and subtracting 2. In my case, I got 2.
/fill ~1 ~-1 ~ ~1 ~-2 ~ redstone_block

Put your final /fill command as your first command:
/summon FallingSand ~ ~2 ~ {
TileID:152,
Time:1,
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
TileEntityData:
{
Command:"/fill ~1 ~-1 ~ ~1 ~-2 ~ redstone_block"
},
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
TileEntityData:
{
Command: "/say Hello!"
}
}
}
}
}

Now you can add as many commands as you want! Keep in mind that as you edit your command and add/remove blocks, you will have to keep up with your /fill command to make sure it still powers all of your blocks.

That's pretty much all there is to it! As a final example, you can have something like this:

/summon FallingSand ~ ~2 ~ {
TileID:152,
Time:1,
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
TileEntityData:
{
Command:"/fill ~1 ~-1 ~ ~1 ~-2 ~ redstone_block"
},
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
TileEntityData:
{
Command:"/time set night"
},
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
TileEntityData:
{
Command: "/say Hello!"
}
}
}
}
}

One of the hardest parts about making commands like these is making sure
that your curly brackets are balanced. I have a method that has not
failed me yet. The sequence below shows my method better than any words
could. The cursor is represented by a '|'.

Riding:{|
Riding:{}|
Riding:{|}
Riding:{id:|}
Riding:{id:FallingSand,Riding:|}
Riding:{id:FallingSand,Riding:{}|}
Riding:{id:FallingSand,Riding:{id:FallingSand|}}
etc.

Basically, I write both curly brackets at once, then define their content.

Note: Sometimes you may notice that your bottom command block is being powered twice. This is because it is being powered by both the button and the redstone block. There are two solutions to this. The first is to shorten your tower of redstone blocks so that it doesn't power that block. However, because this problem is most likely not constant, I highly recommend against this strategy. Option two is to put a stone block in front of the "mother" command block and power it through that block, which would prevent the button from powering the summoned command block above it. P.S. this note assumes that you are powering your command block with a button, even though there are many ways to power blocks

If you have any questions, please leave a comment or PM me.

Sequential Activation

This section assumes that you have read the previous section about simultaneous activation.

This is great! We now know how to run multiple commands with only one command block! But what if we want them run in a specific order? For example, let's say we're building a house. You make the cube with /fill, and then use /fill again to clear out the inside. If the clearing /fill is run at the same time as the cube is made, we can get unintended results.

So how do we specify which order they shall be run in? Well, to tell the truth, it is very different from simultaneous activation. Instead of having one command block activate all of them at once, we're going to make them all get powered as they land. In order to do this, we need to make every other block be a redstone block (id 152). Take this as an example:
/summon FallingSand ~ ~2 ~ {
TileID:152,
Time:1,
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
TileEntityData:
{
Command:"/fill ~1 ~-1 ~ ~1 ~-2 ~ redstone_block"
},
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
TileEntityData:
{
Command:"/time set night"
},
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
TileEntityData:
{
Command: "/say Hello!"
}
}
}
}
}

In this example, we need to remove the command block that powers the others.

/summon FallingSand ~ ~2 ~ {
TileID:152,
Time:1,
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
TileEntityData:
{
Command:"/time set night"
},
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
TileEntityData:
{
Command: "/say Hello!"
}
}
}
}

Furthermore, we need to put redstone blocks between each command block:

/summon FallingSand ~ ~2 ~ {
TileID:152,
Time:1,
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
TileEntityData:
{
Command:"/time set night"
},
Riding:
{
id:FallingSand,
TileID:152,
Time:1,
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
TileEntityData:
{
Command: "/say Hello!"
}
}
}
}
}

Please keep in mind that "/say Hello!" will be run before "/time set night". In other words, they will be run in backwards order. Later in this section I will explain how to change that.

In this example, "/say Hello!" lands first. Then the redstone block lands on top of it and powers it. Then, "/time set night" lands, and the next redstone block lands on top, powering it.

Using this method, you can create as many command blocks as you would like.

This works, and it's reasonably simple. But even then, it can be confusing. Particularly the fact that the commands are run in the reverse order of which they are stated. This confusion can easily be avoided. Rather than stating the commands as the blocks are defined, we can state the commands as the Riding tags are closed. For best understanding, the next example i layed out differently from the others:

/summon FallingSand ~ ~2 ~ {
     TileID:152,
     Time:1,
     Riding:
         {
         id:FallingSand,
         TileID:137,
         Time:1,
         Riding:
             {
             id:FallingSand,
             TileID:152,
             Time:1,
             Riding:
                 {
                 id:FallingSand,
                 TileID:137,
                 Time:1,
                 TileEntityData:
                     {
                     Command: "/say Hello!"
                     }
                 }
             },
         TileEntityData:
             {
             Command:"/time set night"
             }
         }
     }

Condensed Version - click to reveal
/summon FallingSand ~ ~2 ~ {TileID:152,Time:1,Riding:{id:FallingSand,TileID:137,Time:1,Riding:{id:FallingSand,TileID:152,Time:1,Riding:{id:FallingSand,TileID:137,Time:1,TileEntityData:{Command: "/say Hello!"}}},TileEntityData:{Command:"/time set night"}}}

As you can see, the TileEntityData tag for "/time set night" has moved. But if you were to test this command, "/say Hello!" is still run first! This is because although TileEntityData is stated after the other block, it is still within the same Riding tag. This can be especially helpful when you have tens, or even hundreds of different commands that will be run.

Well, there ya go. If you have any questions about this section or any section, please leave a comment or PM me.

Adding a Terminator Block

Every time after you've tested your command, you've had to manually destroy all the command blocks that were summoned. Using a terminator block, we can automatically destroy the command blocks after they all have been run.

No, a terminator block is not a giant robot that comes and blows up your command blocks. It is a command block that clears the other blocks using /fill. When using simultaneous activation, the terminator block cannot be one of the normal command blocks that are powered all at once. If it is, it will clear the other command blocks before they have a chance to be run. Instead, we must use a strategy similar to what we used for sequential activation.

Before the activation command block, we must create two more blocks. The first will be a redstone block, and the second will be a command block.

/summon FallingSand ~ ~2 ~ {
TileID:152,
Time:1,
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
Riding:
{
id:FallingSand,
TileID:152,
Time:1,
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
TileEntityData:
{
Command:"/fill ~1 ~-1 ~ ~1 ~-2 ~ redstone_block"
},
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
TileEntityData:
{
Command:"/time set night"
},
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
TileEntityData:
{
Command: "/say Hello!"
}
}
}
}
}
}
}

As you can see, we have added two blocks, one of id 152 (redstone block) and one of id 137 (command block).
Don't forget to add two curly backets } at the end!
At this point, you can run your command. You will see that on top of your previous blocks, two more will appear. Find the command block you added, and count how many total blocks are below that. Consider this /fill command:
/fill ~ ~ ~ ~ ~ ~ air

As x1, we will put 1, but we'll leave x2 as 0. This way it will clear both the redstone block tower and the command blocks.
As y1, we'll put 1. This way it clears the redstone block above it. As y2, we'll put the negative version of the number of blocks below it. In my case, that would be -4. We'll leave z1 an z2 as 0. Our final command is this:
/fill ~1 ~1 ~ ~ ~-4 ~ air

Now, we move this command into our command block:

/summon FallingSand ~ ~2 ~ {
TileID:152,
Time:1,
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
TileEntityData:
{
Command:"/fill ~1 ~1 ~ ~ ~-4 ~ air"
},
Riding:
{
id:FallingSand,
TileID:152,
Time:1,
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
TileEntityData:
{
Command:"/fill ~1 ~-1 ~ ~1 ~-2 ~ redstone_block"
},
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
TileEntityData:
{
Command:"/time set night"
},
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
TileEntityData:
{
Command: "/say Hello!"
}
}
}
}
}
}
}

If we are using sequential activation, we still add the two blocks. Really, the only difference is in the /fill command. Our x1 is equal to 0 rather than 1.

/summon FallingSand ~ ~2 ~ {
TileID:152,
Time:1,
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
TileEntityData:
{
Command:"/fill ~ ~1 ~ ~ ~-4 ~ air"
},
Riding:
{
id:FallingSand,
TileID:152,
Time:1,
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
TileEntityData:
{
Command:"/time set night"
},
Riding:
{
id:FallingSand,
TileID:152,
Time:1,
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
TileEntityData:
{
Command: "/say Hello!"
}
}
}
}
}
}
}

If you have any questions about this section or any section, please leave a comment or PM me.

Debugging Your Command

These commands can get huge, and you will undoubtebly run into some errors. If you don't, then you are either very lucky, or are simply very good at this

There are many error messages you may get when testing your command. I will cover as many as I can, but if you encounter any that I did not go over then please put your command and error message in a comment or PM and I will surely help you figure out what went wrong.

One error message you may get is:

Data tag parsing failed: Unbalanced curly brackets {}: YOURCOMMANDHERE

If you get this, it can mean a few things. The most obvious is that your closing } and openning { curly brackets are not equal. to find this, I walk through my command slowly and keep a number in my head. It starts at 0. Whenever I encounter an openning curly bracket, I add 1. When I see a closing bracket, I subtract 1. If I end the command with 0, I move to the next option for this error message. If I get a number that is nonzero, I add or remove curly brackets at the end to make it zero.

If you did this and it's still not working, there are still other reasons why you're getting this message. Sometimes, if you forget a comma after a closing curly bracket and before a data tag, you can get this message. For example, you would get this message if you did this:
Riding:{id:FallingSand}TileEntityData:{Command:"/say hi"}

This should be written as follows:
Riding:{id:FallingSand},TileEntityData:{Command:"/say hi"}

Finding mistakes like this can be difficult, so I recommend you do your best to make sure you do this right the first time.

Furthermore, If I were to put in this command,

/summon FallingSand ~ ~2 ~ {
TileID:152,
Time:1,
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
TileEntityData:
{
Command:"/fill ~ ~1 ~ ~ ~-4 ~ air"
},
Riding:
{
id:FallingSand,
TileID:152,
Time:1,
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
TileEntityData:
{
Command:"/time set night"
},
Riding:
{
id:FallingSand,
TileID:152,
Time:1,
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
TileEntityData:
{
Command: "/tellraw @a "Hi!""
}
}
}
}
}
}
}

You will get the error message:

Data tag parsing failed: Unexpected token 'H' at: Hi!""

This is because of the Command tag at the end. If your command involves quotes, you need to put backslashes in front of the quotes. This way, the two sets of quotes will not get confused. This Command tag should be written as follows:
Command:"/tellraw @a \"Hi!\""

It is worth noting that the command tag does not need to be in quotes. This can be useful when you have a command within a command that needs quotes, such as the following:
Command:/tellraw @a {text:"Then John said, \"Hello!\""}

There are also many errors related to "Data tag parsing failed: Unexpected..." However, If I were to cover all of them, this tutorial would take hours to read. For now, I will stick with the two most common error messages. If you find any not mentioned, please put it in a comment or PM.

There are also many problems that can occur that do not show error messages. For example, the following would not make an error message:
/summon FallingSand ~ ~2 ~ {
TileID:152,
Time:1,
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
TileEntityData:
{
Command:"/fill ~ ~1 ~ ~ ~-4 ~ air"
},
Riding:
{
id:FallingSand,
TileID:152
Time:1,
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
TileEntityData:
{
Command:"/time set night"
},
Riding:
{
id:FallingSand,
TileID:152,
Time:1,
Riding:
{
id:FallingSand,
TileID:137,
Time:1,
TileEntityData:
{
Command: "/tellraw @a "Hi!""
}
}
}
}
}
}
}

If you notice, we are missing a comma between TileID and Time. This will not create an error message because it's a tag for the block, not part of the command. However, when you run the command, you will notice how that block does not show up at all. This is becuase these two tags changed from TileID:137,Time:1, to TileID:137Time:1. This will cause the Time tag not to work, and will cause the FallingSand to not last for more than a few ticks.

There are many other reasons why your command may not work. If your problem was not solved by these suggestions, please leave your command in a comment or PM and I will help you solve your problem. I will be adding more troubleshooting tips over time, so make sure to check in every once in a while.

If you have any questions about this section or any section, please leave a comment or PM me.

Thanks for reading! If you enjoyed, please feel free to leave a diamond... or not. Either way, have fun with these commands and tips!
Tags

4 Update Logs

Update #4 : by TheJared802 05/14/2015 6:57:48 pmMay 14th, 2015

Changed title, fixed grammer and spelling, and fixed subtitle errors
LOAD MORE LOGS

Create an account or sign in to comment.

1
07/24/2017 8:26 pm
Level 1 : New Miner
dj80777
dj80777's Avatar
How do you activate the command so that you get the machine its self?
1
01/03/2016 9:51 am
Level 2 : Apprentice Miner
_Technokid_
_Technokid_'s Avatar
I have been trying to figure out how to do this for ages, even resorting to using online one command block generators. This tutorial really helped me.
1
05/14/2015 7:37 pm
Level 40 : Master Crafter
Benzoes
Benzoes's Avatar
This is pretty cooool bro.
1
05/15/2015 6:41 pm
Level 43 : Master Nerd
TheJared802
TheJared802's Avatar
Thanks!
1
05/10/2015 11:22 am
Level 8 : Apprentice Network
PeterJHC
PeterJHC's Avatar
You can use this in a command block: summon FallingSand ~ ~1 ~ {Block:redstone_block,Time:999,Riding:{id:FallingSand,Block:command_block,Time:999,TileEntityData:{Command:(command)},Riding:{id:FallingSand,Block:redstone_block,Time:999,Riding:{id:command_block,Time:999,TileEntityData:{Command:(command}}}}}}

(I might have gotten the end braces wrong. Experiment.)
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome