Minecraft Education Edition: Coding Tutorials - Walking on Air
In this lesson, you will learn how to generate blocks beneath your feet to allow you to literally 'walk on air'.
Part 1: Walking on Air
1. Launch the Microsoft 'MakeCode' editor and create a new project.
2. Select the 'PLAYER' tab (A). Drag the 'on chat command' (B) block into a blank canvas. Rename the command 'air' (see image below).
2. Select the 'PLAYER' tab (A). Drag the 'on chat command' (B) block into a blank canvas. Rename the command 'air' (see image below).
3. Select the 'LOOPS' tab (C). Drag the 'while true' block (D) inside the 'on chat command' so that they attach (see image below).
4. Click on the 'BLOCKS' tab (E). Drag the 'Place at' block (F) inside the 'while true' block.
At the moment, the blocks will appear directly inside the player. In order for the player to literally 'walk on air', we need to place the blocks beneath the player's feet.
Understanding coordinates
To place a block in Minecraft, we need to specify the coordinates. We specify the coordinates in the order 'X' (East to West), followed by 'Y' (Top to Bottom), followed by 'Z'.
Understanding coordinates
To place a block in Minecraft, we need to specify the coordinates. We specify the coordinates in the order 'X' (East to West), followed by 'Y' (Top to Bottom), followed by 'Z'.
When using the place block command, the coordinates are relative to the player's position so, if we were to use the default coordinates (0,0,0) the block will appear inside the player (see image below).
In order to place the block directly beneath the player's feet, we need to change the 'Y' coordinate.
Change the 'Y' coordinate (G) to '-1' (see image below).
5. Finally, click on the 'PLAYER' tab. Drag the 'say' block and place it in between the 'on chat command' and 'while true' blocks.
In the text box, type 'We're walking in the air' (see image below).
In the text box, type 'We're walking in the air' (see image below).
6. Press 't' to open the chat menu and type in 'air' in the command line (followed by Enter) to run your code.
Challenge:
- Try changing the blocks that appear beneath your feet.
- Change the message for your own message.
Resources:
minecraft-air.mkcd |
Part 2: Over the Rainbow
In the previous exercise, we placed a block of our choice below the the feet of our player to allow our player to literally walk on air. In this next exercise, we are going to modify our code so that different colored blocks of wool are placed below the player's feet (creating a rainbow bridge effect).
1. Launch the Microsoft 'MakeCode' editor and create a new project.
2. Select the 'PLAYER' tab. Drag the 'on chat command' block into a blank canvas. Rename the command 'rainbow' (see image below).
1. Launch the Microsoft 'MakeCode' editor and create a new project.
2. Select the 'PLAYER' tab. Drag the 'on chat command' block into a blank canvas. Rename the command 'rainbow' (see image below).
3. Select the 'LOOPS' tab. Drag the 'while true' block inside the 'on chat command' so that they attach (see image below).
Each time a block of wool is placed, we want to change the colour (ID) so as to create a 'rainbow bridge' effect. To generate the wool ID, we are going to use a for loop.
4. Select the 'LOOPS' tab again. This time, drag the 'For' block inside the 'while true' block (see images below).
4. Select the 'LOOPS' tab again. This time, drag the 'For' block inside the 'while true' block (see images below).
There are 16 different wool colours. As our loop starts at 0 (zero), we need to enter 15 in the 'to' option of the loop.
5. Click on the 'BLOCKS' tab. Drag the 'Place at' block inside the 'for' loop (see image below).
6. Click on the 'BLOCKS' tab (C).Drag the 'with data' block (D) onto the 'place' block so that it replaces the 'Grass' block.
Change the block type that is to be placed from Grass to 'Wool' and change the 'Y' coordinate to '-1' (see image below).
Change the block type that is to be placed from Grass to 'Wool' and change the 'Y' coordinate to '-1' (see image below).
7. Finally, click on the 'VARIABLES' tab (E). Drag the variable called 'index' (F) and place it inside the 'with data' slot (see images below).
9. Press 't' to open the chat menu and type in 'air' in the command line (followed by Enter) to run your code.
Challenge:
- Try replacing the wool blocks with clay.
Part 3: Bridge over troubled water
At the moment, our code will place a block beneath the player's feet whether or not they're in the air. Let's modify our code so that a block is only placed when the player is standing on 'air'!
Let's add a condition that checks to see if the block beneath the player's feet is made of air. For this we will need to add an 'If/then' block.
1. Select the 'LOGIC' tab (A). Drag the 'if then' block (B) and place it on top of the 'place white wool with data' block (see image below):
Let's add a condition that checks to see if the block beneath the player's feet is made of air. For this we will need to add an 'If/then' block.
1. Select the 'LOGIC' tab (A). Drag the 'if then' block (B) and place it on top of the 'place white wool with data' block (see image below):
2. Select the 'BLOCKS' tab. Drag the 'test for' block (C) and place it on the if 'true' block.
3. Change the 'test for' block to 'air' (D) and set the y coordinate to '-1' (E).
5. Press 't' to open the chat menu and type in 'rainbow' in the command line (followed by Enter) to run your code.
Resources:
minecraft-rainbow-bridge.mkcd |
You may also be interested in:
This work is not affiliated in any way with Mojang AB. Minecraft is a trademark of Mojang AB. The Minecraft Name, the Minecraft Brand and the Minecraft Assets are all property of Mojang AB or their respectful owner. This work adheres to the terms set out by Mojang AB at https://www.minecraft.net/terms