Understanding the Logic Behind the Command Block System in Minecraft

Topic

1. What made you choose this topic?

Over my summer vacations and when I was in school, I played Minecraft a lot and did a lot of personal projects involving command blocks. I thought studying the logic behind the command system of Minecraft would be very interesting and also help me to further my knowledge in programming and programming logic. Since I have worked so much with command blocks I feel it will be easier for me to understand and explain the logic behind the command block system.

2. What do you expect to learn from evaluating this topic?

I would like to learn the reasoning behind the logic for commands, as well as the "backbone" of the command features. I would like to compare the command features to the programming logic of real world systems like HTML and JAVA.

3. How long have you been using or known about this topic?

I have known about Minecraft command blocks for roughly 5 years. However, I only dived into using them in depth for about 3 years. My main projects took place over the course of the summer of 2020.

Logic

1. Explain in words a section of your topic.

I have chosen to describe the Conditional paired with Needs Redstone setting. This setting makes the command block test for a successful output from the previous command block as well as a redstone signal. When a redstone signal is applied to the command block, it will test the previous command block for a successful output. If the output was successful, the command block will execute its own command. If the previous output was unsuccessful, the command block will not execute its command. This is the most complex setting since it is testing for two variables. In order to test this, place two command blocks next to each other facing the same way. The default setting should be Unconditional and Needs Redstone. Set the second command block to conditional.

2. Convert your words into either pseudocode or a flow chart.

It is important to note that the impulse command block tests for a redstone signal before testing for a previous command success. If the command block is powered and then the previous command block executes a command, the command block will not execute its own command. The previous command block must power and execute before the next command block is powered. For chain blocks, the block must be powered first and then the previous command block must execute.

Impulse Conditional and Needs Redstone:
Start
Input Command block
Output "Please enter a command to be executed"
Input function command
while(command block exists){
  if(powered=true){
   if(previous output=true){
    do command
   }//endif
  }//endif
}//endwhile
End

3. Test your pseudocode or a flow chart by showing the process.

The first command block is an impulse block with an unconditional and needs redstone setting. The second command block is an impulse block with a conditional and needs redstone setting. Both command blocks are programmed to spawn a block of dirt 2 blocks above the command block. When the first command block is powered, a single dirt block appears. Then when the next command block is powered, a second dirt block appears.

First command block setting page. Set to Unconditional and Needs Redstone.
Second command block setting page. Set to Conditional and Needs Redstone.
How the setup looks
Activating the first command block
Activating the second command block
Incorrect order of powering the command blocks
Notice how both command blocks are powered and the system looks just like the first example. However, since the second block was powered before the first command block, the comparison of the second command block was incorrect.

Wrap Up

1. Did you learn what you expected to? Why or Why not?

I learned part of what I expected to learn in that I learned how the command blocks operate. What I wasn't expecting to learn was that there is a specific order that the command blocks test for their conditions. Needing a positive execution from a previous command block before powering a command block was not something that I thought was important. I also learned that the logic behind the command blocks is simpler than I exepected it to be. Converting the in game mechanics to pseudocode was not as difficult as anticipated.

2. What was the biggest challenge?

The biggest challenge for me was using minecraft to get the screenshots of each feature or step without losing focus and just playing the game. Doing the research was fairly simple and it was easy to document everything that I needed. Figuring out how to format my research and make it presentable was another challenge as I have a hard time coming up with ideas from scratch.