Exploring Minecraft with Python

  • Kurt Grandis (@kgrandis)
  • CEO @ Parelio
  • 04/10/2015

The Challenge

Can we create an environment that's easy and engaging enough to teach kids how to program?

What is Minecraft?

It's Minecraft. It's super popular.

Coding & Minecraft?

Console-based games aren't thaaaat exciting for kids, hence the trend toward robotics and visual programming, like with Minecraft.

Raspberry Pi edition of Minecraft (Minecraft Pi Edition) has a Python API.

But not everyone has a raspberry pi at home, so there's a Bukkit plugin for Minecraft: https://github.com/zhuowei/RaspberryJuice - lets you use the python API with the PC version of Minecraft

  • Mojang isn't building a python API, because RaspberryJuice is already out there

The API


In [ ]:
from mcpi import minecraft

mc = minecraft.Minecraft.create(ip, port, my_name)

# send a chat message
mc.....

# teleport
mc.player.getPos()  # returns a Vec3 instance; could also get pitch/orientation of player
mv.player.setPos(pos_vector)

# place blocks
from mcpi import block

mc.setBlock(x, y, z, block.STONE)
mv.setBlocks(x0, y0, z0, x1, y1, z2, block.STONE)

# detect blocks
mc.getBlock(x, y, z)
mc.getBlocks(x0, y0, z0, x1, y1, z1)

Challenges


In [ ]:
# clear all the things
mc.setBlocks(0, 0, 4, 100, 100, 100, block.AIR)

In [ ]:
# introduce writing and using functions
wall()
tower(height)
sphere(radius)
pyramid(width, height)
house()
lava(x, y, z)
water(x, y z)

In [ ]:
# create your own teleporter by watching for the player stepping on a certain block, then changing their position

Resources: Servers

  • simple short term server hosting
    • meant to be easy for educators to use during workshops
  • AWS images
  • http://cubedhost.com

Martin O'Hanlon

Community Projects

Closing Thoughts

  • still an exciting thing - recent acquisition by Microsoft
  • great tool to teach programming
  • it's one tool, though - some might not like it