Minecraft Trampoline

trampolineIn this post we will use Python 2 and Minecraft to create a virtual trampoline for Minecraft. We will first build the trampoline using Minecraft blocks (in Python). Then we will write a routine to make the main player bounce up and down on the trampoline.

Step 1: Let’s connect to the Minecraft World via our Python script

For this challenge we are using a Raspberry Pi with Minecraft and Python 2 pre-installed.

Now try this, just to make sure it works! You should see a message appearing on your minecraft screen. If you are not sure how to do this you may want to check our first minecraft + python tutorial.

(x,y,z) coordinates?

minecraft-xyz-coordinatesBefore getting started you need to understand how the (x,y,z) coordinates are used to retrieve the position of the player in the minecraft world or to add blocks at the right position. As you can see on the picture to the left, it is slightly confusing as the vertical axis is not the z axis but the y axis.

Step 2: Building the trampoline

Our trampoline will be quite basic. It will consists of 4 posts (made of stone blocks) and a 6 by 6 bouncing area made of wood (ouch!).

Before we can build this trampoline we are going to find the position of the player so we can build this trampoline next to our main player (in fact just 5 blocks away on the x axis)

So let’s see how this all works:


Step 3: Make it Bounce!

Let’s first create a new routine to make the player bounce up in the sky using a for loop.

We don’t have to worry about getting the player to go down as it will do so automatically (there is gravity in the minecraft world!).

Then we will use an infinite loop to constantly check on the player’s position. If the player is on the trampoline then we will call our bounce() procedure.

Complete script:

Your Challenge

Use the above script to make your trampoline.

Once you have it working adapt this script to create an escalator. The escalator should be built using a Python script. As the soon as the main player goes on the escalator they should automatically move up the stairs, one step at a time.

Tagged with: , ,