Tag Archives: school

Minecraft coding in the classroom – 1st draft

Today’s post sways a little off the normal Raspberry Pi stuff, there is a link though!

Minecraft

One of the awesomest pieces of software the Raspberry Pi has for teaching in Minecraft Pi edition Link . If you don’t have it on your Raspberry Pi, why not?! It is great as kids can easily program modifications to the game in python allowing them to place blocks, move players and do all kinds of cool stuff. There is a problem for it though in education, not every school has a classroom of Raspberry Pis…

Fret not though, a Bukkit developer has gone and made a Bukkit plugin to emulate the API but for the normal version of minecraft.

We will start though from the start. What is minecraft?

Minecraft is a sandbox! It is a game played by millions of people across the world. It is very popular with teenagers especially. The game has a massive community behind it and is easily modifiable with the use of Java.

Modifying the game though brings with it a number of problems including modifications not playing nice with each other. To make it easier to mod the game and to help mods play nice together, a number of community projects emerged making their own APIs. The 2 most popular of these are Bukkit and Minecraft Forge. Both are not run by Mojang (Minecraft developers) and are maintained as opensource projects through donations.

Bukkit is an stable and the standard server platform for 90% of Minecraft servers out there. It has an easy to use API and a massive collection of plugins allowing you to manage players on a server and keep order. There are also a number of specialist plugins, we will be looking later at one called RaspberryJuice. Bukkit is a server only platform, it can not modify the actual client (aka add more buttons, new blocks or new menus).

Minecraft forge, the other major platform, allows direct modification to the client. This allows you to do things like add new menus, buttons, blocks. MinecraftEDU is designed for Minecraft forge. It has a very powerful API that allows you to change most of Minecraft.

 Minecraft Pi edition

Minecraft Pi edition is a special version of minecraft developed for the Raspberry Pi which is based off another branch of minecraft, Pocket edition (designed for mobile devices). It has only the basic features of minecraft but can easily run on the Raspberry Pi.The important bit though about minecraft Pi edition is it has its own simple to use API for interacting with the world! You can tp players, break or place blocks etc in languages like python, java, javascript etc.

This API is great for the classroom and at home but it has an issue. What if you don’t have a Raspberry Pi? A lot of schools dont yet have a full classroom yet of Raspberry Pis but have a fully kitted out ICT suit with much more powerful computers than the Raspberry Pi. What about this API for normal PCs? A developer has gone and created just that! An easy to use plugin called RaspberryJuice has been released that allows players to use exactly the same API but using normal Minecraft.

Each student must be running a mini server though to use this seeing as it requires bukkit, this allows teaching simple commandline based server applications too.

By using Bukkit, you also have access to 1000s of plugins that allow you to customize the entire experience. For the plugins check out their database http://plugins.bukkit.org/

Lets set up a server

First you will need a minecraft account (€19), it is likely most students will have one. MinecraftEdu offer discounts to schools and can get them as low as €10. You only need 1 set of accounts per classroom (and if they arent connecting to the same server, 1 set per school).

Next you need to set up the clients, it is a very easy process. Make sure java is installed (most machines it is), download client from Here and you are good to go.

If you are using RaspberryJuice each client also needs a mini server running in the background. The basic idea is they run their own mini preconfigured server then they just connect to localhost (aka, themselves). Using this method also allows students to connect to each others servers if they know their IP addresses.

You need to create a folder with the server stuff in it. I will be demoing this on a mac, but it will work also on windows and linux.

Make a new folder for your server and grab the latest beta build of bukkit (It is also known as craftbukkit) from dl.bukkit.org .

Bukkit has 3 standard release channels, unstable (daily releases, dont use), beta (a tested build that most things should work for, these are fine) and a recommended build (these are the most stable, there are very few of these).

Minecraft is constantly being upgraded with new features, a new update comes out on average every 1.5-2 months and will be heavily publicized before its release. Best place to hear about new versions is https://mojang.com/. They also do snapshots which are unstable test versions normally released once a week. These are minecraft versions, not bukkit. Minecraft follows a numbering system that increments .1 every major release and .0.1 for bug fixes, for example as of writing, the current version is 1.6.2. 1.6 is the main version number and there has been 2 bug fix updates. Remember, these are different from bukkit releases. Bukkit releases can take 1-2 weeks after a major update and 2-3 days after a bug fix update. When a new version comes out, you dont need to update, it is normally smarter not to until everything settles down.

When configuring the clients, it is important to go into edit profile and change the dropdown menu from latest version to the current version, this way the clients wont auto update. See the picture belowVersion

So, now you have bukkit (also known as craftbukkit), place it in your server folder you created and rename it to craftbukkit.jar. The result of this is below

We only have 1 file so far, the server!
We only have 1 file so far, the server!

The normal thing to do for most people is just double click it, sadly minecraft servers dont work like that, they need a script to launch them correctly. I have provided all the startup scripts here StartFiles

The .bat is for windows, .command is for mac.

Remember, the server .jar file must be called craftbukkit.jar

We are now ready to test out our server. Double click the start.something file and watch as a terminal or cmd opens with a load text.

The important bit here is at the bottom. It explains that it is generating the minecraft work which can take a few mins.
The important bit here is at the bottom. It explains that it is generating the minecraft work which can take a few mins.

You now have your very own minecraft server up and running.

!!!VERY IMPORTANT!!! Do not ever close the terminal or cmd with the x at the top! To correctly stop a server you must type stop into the terminal and hit enter. If you close it by mistake, easiest way to fix it is reboot your computer !!!VERY IMPORTANT!!!

You can connect to your minecraft server by launching minecraft, clicking multiplayer and connecting to localhost

If you can connect, you have done it all right!

 

Plugins?

To modify the experience for your students you can use plugins. These are modifications to the server developed for free by members of the community using the bukkit API. To add one, you simply download its .jar file and drop it into the plugins folder inside the server folder. Reboot your server and it will auto load on startup. Keep an eye on which version plugins were developed for, some older plugins may not work on more recent versions of bukkit. Most plugins work perfectly fine, RaspberryJuice for example was released 2 major releases back and it still works perfectly fine. Make sure to read the documentation that is on the plugin page if you are putting any other plugins.

Other stuff you need to know

You may want to edit some configuration text files, these are auto created when the server starts. The server.properties file is the main config file for the server. Details of it and its settings can be found at http://www.minecraftwiki.net/wiki/Server.properties

Minecraft servers have a built in permission system that is rather simple, you have 2 levels.

  • Player – can build, mine and play as a normal player
  • Op – (short for operator). The Op has full power over the server, can spawn in blocks, can change to creative mode (fly and infinite blocks) and can stop the server.

To add yourself as an op open the ops.txt file and add your name on the first line. You can also add it ingame and from server console.

Commands

The server is controlled via a series of commands, a user at the console has full permission to type any command, an Op ingame can type most commands and a play can type barely any.

To type a command ingame you prefix the command with a /

For example /stop from ingame would shut down the server. At the console you only need to type in stop and hit enter and the server will shut down. Make sure to give it a min to save the map.

A full list of commands can be found at http://www.minecraftwiki.net/wiki/Commands

You will need to download the minecraft pi version to grab the api folder which contains the python library, drop the api/python/minecraft folder into the base directory of your server. Then follow the normal minecraft pi guides but make sure to save your python scripts in your server base directory

Server is red World data files are grey Some of my python files are green API folder is yellow Text files to worry about are purple Stuff to ignore is orange
Server is red
World data files are grey
Some of my python files are green
API folder is yellow
Text files to worry about are purple
Stuff to ignore is orange

Each student will need a mini server for themselves, you can create the folder, zip it up and put it on a pendrive or shared network space and let them grab it, you dont need to include the folders in grey as the server will auto generate new worlds if no worlds exist.

Also keep in mind, if students know other students IP addresses, they can connect to each others server or write python scripts to do stuff to other peoples servers, it is up to you if you want to allow them to find out each others IP addresses 🙂

With a server running, connect to it with your client and you are good to go, create some python scripts!

Resources

http://blog.whaleygeek.co.uk/minecraft-pi-with-python/
http://www.stuffaboutcode.com/p/minecraft.html
http://arghbox.wordpress.com/2013/06/13/programming-minecraft-pi-with-python-early-draft/