How programming (coding) can be used to interact with the Minecraft game. Aimed at teachers, parents or children with some basic coding experience.
Sorry, embedded videos aren't working.
2. Who is this for?
• Teachers and students
with an interest in
Minecraft and/or
wanting to learn to
code
• Recommend ages
10 to 16
pic: Kiama Library
3. Why Minecraft?
• High engagement
• Relatively low
cost
• Code your own
creations
pic: K Jarrett
4. A path into coding
• Many kids already using commands in Minecraft
5. Minecraft Pi API
Developed by Mojang for the free Minecraft Pi edition
A simplified way to send commands to Minecraft
server using Python (or Java)
eg. to place blocks
move the player
check if a block has been hit
6. What you can do:
• Build faster
• Larger structures /
shapes
• Duplication
• Animate blocks eg.
change colour
• Games within a
game
Welcome
I’m a freelance media + technology trainer + for 8 years teaching at PHM everything from movie making to robotics. Also Scratch and basic coding and for couple years been combining that with Minecraft.
Hoping to inspire you to try it out.
Hands up who uses Minecraft in classroom? Who teaches any kind of programming language?
Which ones?
New to coding or if they’ve had some experience using Scratch, Python or another language
Why use Minecraft as a tool to teach coding? First, kids love it (or most do!)
Unlike a coding game like Code Avengers or Code Kingdom you can create your own games or just build things you want.
Kids are already playing Minecraft so why not go where they are and teach them a new language they can use in the world they love.
In fact anyone who has played PC or Mac version is probably already familiar with issuing commands : changing weather, time, teleporting player around.
Some kids may also have used command blocks in the game or even set up their own simple server.
Modifying the game further does require some fairly advanced coding in Java which is a barrier for most kids, but
There is an Application Programming Interface which allows you to do many things within the game without modifying the source code.
You can then use Python or Java (but I’ll focus on Python as its an easier language to learn for beginners) to send commands.
So, what can you do with it?
With coding you can build things that otherwise would take ages to complete. No mobs (by default) so focus is on building
Almost all the kids I’ve taught with this start off wanting to run around and place blocks as normal but as soon as they see what they can build with code, they get hooked on the coding.
So what do you need?
If you have a small Raspberry Pi computer hook it to a monitor and keyboard.
Raspberry Pi comes preloaded with the FREE Minecraft Pi edition which has everything you need to work with Python. Someone has actually made a version of the API libraries so you can use Scratch instead of Python but this only works on the Pi.
If you do have a Pi there are some other cool things you can do such as send a signal to a Pi Camera via Minecraft.
If you don’t have a Raspberry Pi … you can now do this on a normal PC / Mac
You’ll need to buy a copy of Minecraft for each computer and download the Raspberry Juice plugin (which is free) and comes with server software and libraries
API libraries let you write programs in Python the server will understand
Each computer runs its own server so you work in your own world. Its possible to run it as multiplayer but we tried it at PHM and too much distraction
demo setting it up
Intro: print, PostToChat
WhereAmI : co-ordinates
Hide and Seek : co-ords, random, pythagoras, if
Build a line / wall
Spheres ?
generated a random position for a block, then calculated the distance between player and the block using Pythagoras, then some simple if statements and a timer to run the game
Computers do the thinking for you.
Eg. office tower, once I understand some basic of using co-ordinates and loops I can build the code a lot faster than manually building the tower and can duplicate it as many times as I want
So, what can you teach with it?
Could be as simple as co-ordinates, distance and counting through to radius, pythagoras’ theorem, even trigonometry if you want to calculate angles
You can also import CSV data files to build certain shapes like a maze
create shapes, explore the relationship between maths + art!
could also look at examples of geo-fencing in real world and try to replicate in the game, could create a game where your “oxygen” decreases as you get higher up
If you want to extend it further, connect it to some external devices. Here’s an example of connecting a small Arduino and button to trigger something in game
mod called Computercraft which you install on top of Minecraft. You make a computer in the game and then program it in Lua language to make mining turtles, make interactive games
This one you have to buy extra software and there are learning resources to teach you how to code your own mods.
Other options are using Forge mod to code your own mods in Java, but we are starting to get quite advanced there.
If you have a Raspberry Pi, go to the Pi website and there are resources there about Minecraft Pi.
Stuff about code: Minecraft clock, Game of Snake and more!