Challenge 1 – Glass Bridge


Walking around the Minecraft world is great fun, but water and lava can cause real problems! Wouldn’t it be great if you could walk anywhere you like, without having to fly! Well you can, just create a glass floor below you.

The Challenge

The aim of the challenge is to write a python program that builds a glass bridge under your player

Wherever you walk in MineCraft world. You can make the bridge as wide as you like, and you don’t have to make it out of glass if you don’t want to!


  • Try making the floor out of Gravel/Water blocks instead of glass. What happens?
  • Can you make a glass staircase instead?
  • How about a rainbow coloured bridge?

Step 1. Find out where you are and put a glass block under your player.

The first thing we need to do is find out where we are on the map, using mc.player.getTilePos().

We should store the returned result in 3 variables myX, myY, myZ.

>>>mc.setBlock( myX, (myY–2) , myZ, block.GLASS)

Then we need to place a glass block underneath us, using the mc.setBlock(x, y, z, block) function.

Step 2. Change your program to make a 3×3 square underneath  you.


We  now need to change the code to add a 3×3 square of glass blocks below us. We can do this in a number of different ways (such as using for loops or while loops) but in this example we will use the mc.setBlocks() function.

Using  mc.setBlocks()

This is the easiest and most efficient way to complete the challenge.

Using the top down view of your player above see if you can replace the ??? in code below to complete the glass floor below your feet.

mc.setBlocks(myX-1,myY –1 , myZ-1, ???, ???, ???, block.GLASS)

This should now create a glass floor below your feet!

Put the code in a loop

All that is left to do now is to put all your code inside a while loop and add a time delay between each loop. We need to add a time delay otherwise the python program will eat up all of your CPU power and make the program run really slowly

>>> import minecraft as minecraft
>>> import block
>>> mc = minecraft.Minecraft.create()
>>>import time
>>>while True: # This while loop will keep repeating forever.
>>>     # Put the rest of your code here!
>>>	   # don't forget to use a 4 space indent in the loop.
>>>     time.sleep( 0.1) # This means that the glass floor will be updated every 0.1ses.

The Completed Code

import minecraft as minecraft
import block
import time

mc = minecraft.Minecraft.create()

while True:	#set up the loop here
  myX, myY, myZ = mc.player.getTilePos()	#find out where we are
  mc.setBlocks(myX - 1, myY - 1, myZ - 1, myX + 1,myY -1, myZ +1,block.GLASS)
  time.sleep(0.1) # Add a 0.1 second wait so that we don't put too much strain on the Pi!