Minecraft

To start minecraft :

1. Run LXterminal

2. Type the following commands exactly (press ENTER after each command):

cd mcpi
./minecraft-pi

When in minecraft, you can release the mouse by pressing TAB. To get back into minecraft, just click on the minecraft window.

Here are some example scripts (programs) that you can try.

Each script needs to be saved as <something>.py in the ~/mcpi/api/python folder. If your program is not in the same folder as the minecraft API, it cannot ‘see’ minecraft.

Script 1

# minecraft example script 1 (teleport)
# place this file in ~/mcpi/api/python
# start minecraft before running this script
# run from IDLE or from the command line
import mcpi.minecraft as minecraft
mc = minecraft.Minecraft.create()
x = 10
y = 11
z = 12
mc.player.setTilePos(x, y, z)
# experiment with teleporting to different coordinates
# which of the variables x, y, z represents HEIGHT?
# when could a script like this be useful?

Script 2

# minecraft example script 2 (surprise)
# place this file in ~/mcpi/api/python
# start minecraft before running this script
# run from IDLE or from the command line
import mcpi.minecraft as minecraft
import mcpi.block as block
from math import *
colours = [14,1,4,5,3,11,10]
num_colours = len(colours)
mc = minecraft.Minecraft.create()
height = 60
mc.setBlocks(-64,0,0,64,height + num_colours, 0, 0)
for x in range (128):
	for colour_index in range(num_colours):
		y = sin((x/128.0) * pi) * height + colour_index
		mc.setBlock(x - 64, int(y),0 , block.WOOL.id, colours[num_colours - 1 - colour_index])
# can you reach the end of the ______?
# can you smash the _______?
# can you climb on the _______?
# can you teleport to a place on the _______?
# How can you find out the right co-ordinates to jump to?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>