Class 1 notes: Java Coding Class

Updated: Aug 7

Hi class! So recently in my previous lesson, I got a lot of questions in the middle of the class. So from now on, after every class, I will post notes on the topic we discussed, and we will also have multiple question breaks in the middle of class. Another problem that I need to address is that some students can't see the chat. So in classes, we will be using Zoom chat only. If you have problems finding the chat button in Zoom, contact me and I can help you. Also, and I can't stress this enough, If your child does not have Minecraft java edition, they cannot participate in class. In Minecraft, different versions of the game on different platforms have slightly different features, such as commands, which is what we are working on in the Java Minecraft coding class. If you are not on windows or mac and do not have Minecraft Java edition, you can purchase it for 30$ USD at minecraft.net. I believe that is all the problems that need to be addressed, so I will move on to the class notes.


Class 1: the /setblock command

Before we get into this, you have to first understand what a command is, and how to use it. You can type commands into chat, in Minecraft, as long as you have operating commands, which can be given to you by whoever owns the server. In this class, you will automatically have operating commands. We will not be using chat to write commands or to write anything for that matter. What we will be using to execute our commands is a Command Block. You will have one when you start the class, and when you type your command into the command block, it will do whatever you say. For now, we are not going to worry about anything besides the long strip where you type your command in, and we won't worry about the other parameters on the screen inside the command block. To activate your command block, you have to activate it with some sort of redstone, so placing a redstone block next to it will work just fine.

The setblock command can be used to place a block at any point in the game, using XYZ coordinates. We will use XYZ coordinates in a lot of classes in the future, so it is absolutely required to move on. It may look complicated at first, but after practice, it is very easy to use. So each letter in XYZ represents an Axis.

The letter X is your east/west coordinate. A positive value increases the block East, while a negative value increases the block west.

Your Y value is up and down, so increasing it makes the block go higher, or lower if you make it a negative number.

The Z coordinate is your South/North location. A positive value increases the direction north, while a negative location increases your value South.

So, if I wanted to put an XYZ coordinate into a command, it would look like this: 100 20 -100, or something like that. This would mean that the first integer, 100, which is the X coordinate, is going to be 100 blocks east because a positive value in the X coordinate is east. The second integer, 20, which is representing the Y coordinate, means the block is going to be 20 blocks upward, from the point at which you are sending the command. The last integer, -100, which is representing the Z integer, is a negative number, meaning it will be going south because it is a negative number.

tip: if you want to find out which direction you are facing, you can enter the F3 menu. For windows users, pressing F3 on your keyboard should do it, as long as you haven't changed your keybind. For mac users, hold fn and then tap F3.

When you do this, the F3 menu will look pretty intimidating. For now, all you need to look at is your location, which is located in the 12th line, on the left side. This will show you which direction you are facing, which you can use to determine which block you are at.

So, moving on, the coordinate 100 20 -100 is called an Absolute Coordinate, and it is the exact point in the entire Minecraft world, out of all the infinite blocks.

Now, the 2nd way that we can represent coordinates is called a Relative coordinate and looks something like this: ~10 ~-2 ~5

These three integers also represent the three Axis, but not in the way you expect. The base version of a Relative coordinate, is just three tildes, that look like this: ~ ~ ~

A tilde (~) in commands just means whatever the location the command is being placed. For example, if I put ~ ~ ~, or a Base Relative coordinate into a command block, the location would just be the exact block where the command block is. The first tilde, representing the X coordinate, is just whatever the command blocks X-axis is, same for the Y and Z coordinates. When you put numbers after the tilde, for example, if I put a two in the 2nd tilde representing the Y-axis, that would be signifying that I want to add 2 to the Relative Y coordinate, so meaning ~2 would be the same as two blocks above the command block, same for the other axis. For the X-axis, if I put ~3 as the X-axis, that would be putting the block 3 blocks east of the command block. You can also use negative numbers as well.

A 3rd way we can represent coordinates as well, (keep in mind this is rarely used) is called a Hybrid coordinate. It's basically just when you merge the two together, so for example it could look like ~2 6 ~4. The X coordinate is Relative, the Y coordinate is Absolute, and the Z coordinate is also Relative.

That's pretty much it for coordinates, and I know it seems really complicated, but really after using it for a bit it becomes like muscle memory. If you have any questions about anything we discuss in this class, feel free to ask me in the class or after class in my private messages.

With all that covered, let's move on to the setblock command. The whole command looks something like this: /setblock ~ ~ ~ dirt

This will just place a dirt block right where the command block is, because of the Base Relative coordinates. After the coordinate, you see the word dirt, which is the block being placed. When you want to change the block, you can't just right Diamond Block or something like that. You have to write the Minecraft ID for the block, so Diamond Block would be diamond_block. Sometimes these IDs are really obscure, so you can find them all at Minecraft ID List

Search up your block, and you should see minecraft:something_something under the block name. You want to type that in. You can remove the minecraft: part too, it's not needed.

That's pretty much it for the setblock command, and you may be wondering, "Why is this useful if I can just place the block on my own?"

My answer to that is you can have a chain of command blocks, all connected with redstone, to instantly build a house with a click of a button. This command is useful in a lot of other ways too, that we will get into in later classes.

PS: I'm sorry if this was a little confusing for newcomers to coding in minecraft, but I tried to make it as simple as possible. If you have any questions, feel free to ask me in class or in my private messages on slack!