Minecraft
Advanced
30 mins
145 points
What you need:
  • Chromebook/Laptop/PC
  • Minecraft Education Edition

Yellow Brick Road

Create a path of flowers and a yellow brick road wherever you walk.

1 - Open Minecraft

In this project we are going to learn how to create a program Minecraft that will leave a trail of flowers or a yellow brick road behind you wherever you walk in the world.

First, open Minecraft Education Edition, login, create a new world and open the Code Builder.

2 - Flower trail

Add the following code to leave a trail of flowers behind you, wherever you walk in the Minecraft world.

player.onTravelled(WALK, function () {
    blocks.place(YELLOW_FLOWER, pos(0, 0, 0))
})

As we are using the position 0 0 0, the flowers get created wherever you are. The on player [walk] block triggers whatever code you put inside it when the player walks.


3 - Different types of flowers

Next update your code as follows to place different types of flowers wherever you walk.

player.onTravelled(WALK, function () {
    blocks.place(POPPY, pos(0, 0, 0))
    blocks.place(ALLIUM, pos(0, 0, 0))
    blocks.place(CORNFLOWER, pos(0, 0, 0))
})

4 - On fly

You may have noticed the on player [walk] block can be changed to trigger the code inside it for different things the player can do.

Change the block so that it triggers on player [fly] and then run your code.

player.onTravelled(FLY, function () {
    blocks.place(POPPY, pos(0, 0, 0))
    blocks.place(ALLIUM, pos(0, 0, 0))
    blocks.place(CORNFLOWER, pos(0, 0, 0))
})

To make your player fly, press the space bar twice and then use the w or s keys to move around.


5 - Walk and place gold

Add the following new code to place a gold block wherever your player walks.

player.onTravelled(WALK, function () {
    blocks.place(GOLD_BLOCK, pos(0, 0, 0))
})

Run your code and make your player walk around. Notice that gold blocks get placed on top of the ground, wherever you walk.


Join our club 😃

To view the remaining 3 steps and access hundreds of other coding projects please login or create an account.

Copyright Notice
This lesson is copyright of 123code. Unauthorised use, copying or distribution is not allowed.
🍪 Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more