Getting a Raspberry Pi to play Minecraft Pi…

If you already have a Raspberry Pi, feel free to skip to the next blog post.

Occasionally I have a discussion with someone about the Raspberry Pi and at some point I mention what a wonderful device this $35 computer is…  they typically get excited they can do so much for just $35.  And if I have the chance, I’ll try to adjust their expectations noting that it can cost “as little as $35” if you have all the “accessories” already.

So I wanted to try to lay out in this post just what it costs to get started – and hopefully this may be a useful list if you want to buy one yourself.

The Raspberry Pi is an amazing little computer and it only costs $35.  However if you want to play minecraft pi or access the web, you’ll need a few more things including:

  1. a TV or PC Monitor capable of receiving a signal via HDMI.  (For this post, I’ll assume only HDMI – although Raspberry PI includes analog/composite video and analog stereo support)
  2. A HDMI cable to connect from the Raspberry PI to the TV/Monitor.
  3. A cable to power the USB – e.g. a micro USB power cable with 1 amp of power.
  4. A 4GB+ SD card for local storage (including the operating system)
  5. A keyboard with USB connection
  6. A mouse with USB connection
  7. a USB Wifi 802.11b+ adapter so you can connect to Wifi.  (You can also connect via Ethernet, but I’ll assume Wifi is what most people want)
  8. A USB hub (because the Pi includes 2 USB ports, and I’ve specified 3 USB devices above – Wifi, keyboard and mouse)
  9. And of course… the Rasbperry Pi device — 256MB of RAM or 512MB of RAM

Now for me, I already had everything else when I got the Rapsberry Pi.  I had a micro USB device from my kindle ebook reader, with a USB charger.  I had a keyboard, mouse and USB hub from an old computer.  I did have to buy the USB Wifi adapter/chip, but my cost was closer to $35.  If you have nothing though (other than a HDMI Capable TV/monitor) you’ll need to spend more like $130 (including the $35 for the Raspberry Pi).

Here’s how I came up with the $130 price.  Newark.com (aka Element 14) is one of the manufacturers and retailers of the Raspberry PI – so via their web site I added the following to my cart:

Screen Shot 2013-02-26 at 4.35.26 PM

And the total for the above was:

Screen Shot 2013-02-26 at 4.35.35 PM

Add another approximately $8 for shipping and you get to $130…

So again — hopefully this will cost you less as you have some of the above things already not being used, but worst cast it’s like $130.

Is it worth it?

So if you’re asking whether it’s worth spending that much money for one of these devices?  I’d say:

  1. If you are considering buying a kid a Raspberry PI vs. a low cost desktop/laptop PC — I’d say go for the PC!  Yes you can access the web, etc with the Raspberry PI — but it’s slow and it’s more complex for a kid to start out.
  2. If you are considering buying this to experiment, play or other purposes — then absolutely go for it!

For me, as a father wanting to teach my kids more about computers — it was a great investment (and I just bought two more today).

Of course my bias is on software — and Rapsberry Pi is as much about connecting to to hardware of all types – and controlling it with software.  That’s something you can’t get to the same degree on a PC..

Beware the starter kits — know what it includes and whether it’s important to you…

Again if you are mostly looking for how to get it up and running so you can interact with the software — the list above is what you need.

There are lots of great web sites that sell starter kits that include what you need to connect raspberry pi to other hardware — but not the mouse, keyboard, power, SD card, hdmi cable, etc described above.  So look carefully at what’s included in these kits.

Are you looking at Raspberry Pi primarily as a way to play minecraft?

In that case, you should know that Minecraft Pi Edition is free — but it’s a subset of the full Minecraft experience on the PC.  Minecraft Pi is based on Minecraft Pocked Edition and both are missing some features that many kids enjoy like the ability to connect to multiplayer servers across the internet.

What did I miss?

Hopefully the above is helpful — and make no mistake, I’m very excited about Raspberry Pi and I recommend to most people to get one — as long as they understand what it is they are and are not getting…

Please add your comments though on your view.  If there are cheaper options to get a starter kit as described above – please add that in the comments as well!

Advertisements

Calling contributors for anything and everything!

Writing this blog has been a lot of fun — far more than I expected.  It was started as a way to collect the python programs Phillip and I found and to encourage ourselves and others to learn about Python by playing with Minecraft and Raspberry Pi.  It’s been great to see how many people are discovering Minecraft PI Edition (MCPI) themselves and writing python scripts… and I given this is just v0.1.1 and a few weeks old, I expect it it will continue to take off.

Which is leading me to the realization — there is more already than Phillip and I can handle ourselves and we need the help of others to continue this.  So I’m making a request for help!

If you are interested in helping, please drop us an email at mcpipy@mcpipy.com and if you have ideas on how you can help – please include that.

There is lots that can be done, here are a few ideas on how I’d like to get help from others — but if there is something you can do not on this list, please let us know!

  1. One time or repeat contributors – Write one or more articles to appear on the blog.  It can be any topic related to Python (or Programming), Minecraft and Raspberry PI (or RaspberryJuice)
  2. Finding scripts – help us search the far corners of the the net for interesting creations we should highlight.
  3. Testing scripts – we have a number of scripts we haven’t had time to test out.  Test them, grab some photos or even make a youtube video!
  4. Github updates – besides checking in the last scripts, we can discuss ideas on how to improve this resource further…
  5. Promotion – help us get the word out on how to program Minecraft in python on raspberry pi — and find others that can learn from the blog, and contribute!

Finally if you aren’t able to help — then please leave a comment to encourage us and note what you’d like to see on future blog posts.  We have a wide range of interests among the readers and we’d like to get to know you better so we can prioritize creating the right content.

As always, thanks for reading and all the contributions to date!!

Programming Minecraft with languages other than Python…

So this blog has been focused on Python because well that’s what I know (and continue to learn) and I think Python is beautiful.  But of course there are still people using other languages out there <g> and I’m thrilled to see people are connecting these up to Minecraft Pi Edition.

I don’t expect to blog any further about the non-python bindings, but wanted to share what I’ve seen so far.  If I’ve missed any, please feel free to add them via the comments and I’ll update this posting periodically to catalog them.

Also please let me know as well if there are collections of programs written in other languages as well and I’m happy to link to them!

MineScanner – Convert Minecraft Objects into Python scripts for Minecraft Pi Edition

This weekend Phillip and I have both been working on programs that required us to figure out where to put our blocks in 3d space (e.g. the x, y and z coordinates).  We took two different approaches:

  1. Phillip did a trial and error, writing/editing a line of python, running it and switching to minecraft to test it.  He did this over several hours until he created what he wanted.
  2. I turned to graph paper, drawing out what I wanted and then writing down the coordinates I needed to add to my program.

I was unhappy with either approach and wanted a better solution – so I’ve created it with the “minescan.py” program.   This program does a few things.  First in it’s scanning mode:

  1. When you run it, it will connect to a world using the MCPI API (e.g. Minecraft Pi Edition running on a Raspberry Pi, or a RaspberryJuice plugin on a bukkit server)
  2. It will then query every block id between two sets of x,y,z coordinates.  (e.g. from 0,0,0 to 10,10,10 by default)
  3. It will then output a python program that recreates these objects.  (It does not specify objects that are of type AIR — it assumes you’ll recreate the object on a clean map, such as using snowbound_flatmap.py)

I expect this script can be used for several purposes:

  1. Learning — If you are just learning how to program MCPI using python, you can use this script to see how 3d objects are created.
  2. Designing — If you are developing a new program, you can create it interactively in minecraft — and then convert it to python to then further edit.
  3. Scraping — If you find a great object on an existing minecraft world, you can capture it and use it in one of your programs.

So I expect this to be very useful and now that I’ve written it, I’m using it already for my next script.

But the script has another mode and use as well.  If you are Designing, you may find it useful to define the boundaries for your creation.  So there are two modes:

  1. the “-c” flag will create a glass container without erasing anything inside.  This is particularly useful for the Scraping scenario (e.g. figure out the coordinates, generate a container to make sure you have the coordinates right, then scan it)
  2. the “-e” flag will create a class container with NOTHING inside (it replaces all interior blocks with AIR)

The tool is intended to be run from the command line like any good unix utility.

To get the script – you’ll find it on github as usual, here’s the link to minescan.py

To see how to use it, run the program with a -h flag like the following and it will tell you what the options are.

$ ./minescan.py -h

usage: minescan [-hcevj] [-x num] [-y num] [-z num]
[-X num] [-Y num] [-Z num] [-o outputfile]

MineScan will connect to Minecraft PI Edition server or Bukkit Server using the
RaspberryJuice plugin. It will by default scan a region and generate a python
script which can be used to regenerate the blocks in that region.

There is also an option to create a glass box around the region it will scan.
This can be used to first define an area in which you will later create something
in minecraft, then scan it.

The options are as follows:

-h: this Help message on how to use minescan

-c: Create a glass container around the specified coordinates.  Doesn't affect
what's inside the container.

-e: Creates a EMPTY glass container.  This will annihilate anything inside the
glass container.

-v: Verbose output on the console, prints information on what's found...

-j: If specified, scripts assumes it's running on RaspberryJuice which doesn't
support the getBlockWithData command.  As a result, some detail won't be scanned.

MineScan needs to be told the xyz coordinates of where to scan and/or create
the container and the how far to scan.  This is done by specifying:

-x num: The starting value of x.  This can be positive or negative
-y num: The starting value of y.  This can be positive or negative
-z num: The starting value of z.  This can be positive or negative
-X num: The starting value of X.  This can be positive or negative
-Y num: The starting value of Y.  This can be positive or negative
-Z num: The starting value of Z.  This can be positive or negative

The defaults are as follows:
x = 0, y = 0, z = 0, X = 10, Y = 10, Z = 10
This means that the program will scan and/or create a container
from 0,0,0 to 10,10,10.

Note that when scanning the program must scan each block one by one,
so in the above example 10 * 10 * 10 or 1000 blocks must be scanned.  This
takes some time. So if you increase these numbers significantly it will take
some time to complete!

Finally...

-o filename: specifies what file to output, such as "scanned.py".  If this
file exists, it will be overwritten! The default is to create a filename with
a prefix of "my-minescanned" with the date/time and a ".py".
If not specified, this time the program would have output to %s

-s address: Specifies the IP address/hostname of the Minecraft Server.
Default is 127.0.0.1 (local machine)

So let’s walk through the different ways you can use this.

Creating a non-destructive container with default dimensions

$ ./minescan.py -c

Here’s an image showing what’s created.  In this case I ran snowbound_flatmap.py first and you can see there is a glass floor under the sand — because -c is not destructive.

Screen Shot 2013-02-24 at 2.00.15 PM

Creating a empty (destructive) container with default dimensions

$ ./minescan.py -e

Here's another image showing what's created, because -e is destructive notice there is no sand inside the glass cube.

Screen Shot 2013-02-24 at 2.00.33 PM

Scanning the object with default dimensions

So first let’s create an object in Minecraft.  Fleap created a house for me and I scanned it…

I then run the script to scan minecraft and create the python program:

$ ./minescan.py
15:06:35 @ ~/Dropbox/python/mcpipy > ./minescan.py 
Output file is "my-minescanned-20130224-153149.py"
[10/1000] 1% complete
[20/1000] 2% complete
[30/1000] 3% complete
[40/1000] 4% complete
[50/1000] 5% complete
[60/1000] 6% complete
[70/1000] 7% complete
[80/1000] 8% complete
[90/1000] 9% complete
[100/1000] 10% complete
[edited]
[950/1000] 95% complete
[960/1000] 96% complete
[970/1000] 97% complete
[980/1000] 98% complete
[990/1000] 99% complete
[1000/1000] 100% complete

And the above generates the following program with a auto generated default name.

The script generated was called “my-minescanned-20130224-153149.py”  I added it to the github directory as scans/fleap_house.py

Here’s a picture of what it recreated:

photo

And here’s an abbreviated version of the program it generated, so you can get a sense of what it creates…

#!/usr/bin/env python
# generated by minescan.py from mcpipy.com

import mcpi.minecraft as minecraft
import mcpi.block as block
import server

mc = minecraft.Minecraft.create(server.address)
mc.postToChat("Re-creating world")

# The following was generated by minescan.py from mcpipy.com
mc.setBlock(0,0,0,block.STONE_BRICK.id)
mc.setBlock(0,0,1,block.STONE_BRICK.id)
mc.setBlock(0,0,2,block.STONE_BRICK.id)
mc.setBlock(0,0,3,block.STONE_BRICK.id)
# Note this block is not supported in Minecraft Pi Edition v0.1.1
mc.setBlock(0,0,4,109)
# Note this block is not supported in Minecraft Pi Edition v0.1.1
mc.setBlock(0,0,5,109)
# Note this block is not supported in Minecraft Pi Edition v0.1.1
mc.setBlock(0,0,6,109)
mc.setBlock(0,0,7,block.STONE_BRICK.id)
mc.setBlock(0,0,8,block.STONE_BRICK.id)
mc.setBlock(0,0,9,block.STONE_BRICK.id)
mc.setBlock(0,0,10,block.STONE_BRICK.id)
mc.setBlock(1,0,0,block.STONE_BRICK.id)
mc.setBlock(1,0,1,block.STONE_BRICK.id)
[... many more lines deleted for brevity sake ...]
mc.setBlock(0,5,0,block.GLOWSTONE_BLOCK.id)
mc.setBlock(0,5,10,block.GLOWSTONE_BLOCK.id)
mc.setBlock(4,5,0,block.GLOWSTONE_BLOCK.id)
mc.setBlock(4,5,10,block.GLOWSTONE_BLOCK.id)
mc.setBlock(6,5,0,block.GLOWSTONE_BLOCK.id)
mc.setBlock(6,5,10,block.GLOWSTONE_BLOCK.id)
mc.setBlock(10,5,0,block.GLOWSTONE_BLOCK.id)
mc.setBlock(10,5,4,block.GLOWSTONE_BLOCK.id)
mc.setBlock(10,5,6,block.GLOWSTONE_BLOCK.id)
mc.setBlock(10,5,10,block.GLOWSTONE_BLOCK.id)
mc.postToChat('World Re-created!')

And that’s it!

Other Commands

As you can see from the -h help text above, there are other commands above.  The most useful are the ability to set a custom start and end x, y and z.

Let’s say you want to create a non-destructive container from -5, -4, -15 to 14, 10, 30 and then scan the same coordinates.

The command you would use to create the container around these coordinates is:

./minescan.py -x -5 -y -4 -z -15 -X 14 -Y 10 -Z 30 -c

And the cmmand to scan these coordinates is:

./minescan.py -x -5 -y -4 -z -15 -X 14 -Y 10 -Z 30

That’s it!

Got an interesting scan?

If you have an interesting scan you’d like to share, contact us via the instructions on the above to submit your interesting object scan!

One last thing… using this with RaspberryJuice on a bukkit server

As I was developing this script I used a bukkit server as that was more convenient — and found that the RaspberryJuice plugin didn’t implement one of the APIs that the MCPI on Raspberry Pi Supports.  Specifically getBlocksWithData.  As a result, this script can capture more detail when run on a Raspberry Pi than against a bukkit server.

Anyway, to allow this script to work with both – I’ve added a “-j” option which should be set when you are running it against a bukkit server with the RaspberryJuice plug-in.  If you forget to do this, the script will hang.

Hopefully the RaspberryJuice plugin will be updated with support for getBlocksWithData in the future so this will no longer be necessary…

Note: RaspberryJuice has since been updated to 1.2 and it includes support for getblocksWithData.  If you are using this script with a bukkit server, then make sure you upgrade!

 

IRC Channel for Minecraft PI Edition

Kristina (@gelicia) has created a #minecraftpi channel on IRC over on the espernet chat network.

IRC is “Internet Relay Chat” which is essentially a chat room that allows for real time communication.  Lots of communities and topics create IRC rooms so people can discuss things in real time.  Often this is a great resource if you are having trouble with something, as people can in real time help you through problems.

If you’d like to connect in and join the discussion or just ask for help you have a few options.

  1. The simplest way is to use their web interface — http://www.esper.net/publicirc.php.  Just create a name, type in #minecraftpi for the chat room and enter.  If you intend to join the IRC often, you may want to use one of these solutions below as they provide a more powerful interface…
  2. You may want to use a native IRC Client for more features.  Here are some recommendations for Windows, Mac, Raspberry Pi and Linux.

Hope this works for you — if you have any problems, please feel free to leave a comment!

PS: Here’s an image showing what to enter on the espernet web interface.  Change test123 to your own nickname 🙂

Screen Shot 2013-02-24 at 2.33.57 PM

 

The user “stretch” on the IRC channel reported the following URL may open IRC automatically if you have the right software installed.  Here’s the URL:

irc://irc.esper.net:5555/minecraftpi

Daniel Bates’ demo scripts for Minecraft Pi Edition

Back when Minecraft Pi Edition was first announced by Daniel Bates here, he included a youtube video showing what could be achieved through programming.

Unfortunately once the official release of Minecraft Pi Edition v0.1.1 came out, these scripts no longer worked as the interface had changed.

I had shared these scripts on one of this blog’s early posts. Luckily Daniel saw it and fixed his code — and I’ve been slow in sharing it back out.

So first, here’s the original youtube video from WAY BACK in December 22nd, 2012 — it’s still pretty cool.

So if you want to try this out, you’ll need two scripts:

  1. danielbates_setblockdemo.py
  2. danielbates_minecraft_basic.py

The first is the actual script, the second is a set of helper functions.

Both are available on the github as usual, instructions on how to download and sync are here.

PS: Starting with this post, I’ll no longer be including source code for the python scripts except for the most simple scripts.  The reason for this change is python being a white space sensitive language (e.g. the spaces and tabs control program execution) it can be a real pain to copy and paste python code.  The right way to get this code is to get it from github.  If you want to copy and paste code or view it — you can do it from the github links above.  Or it’s hopefully even easier for you to download all of the code to your machine.

 

 

A few blog updates…

I wanted to call out a few things you may not have noticed on the blog:

  1. We’ve updated the about page the past week describing what the blog is about, how to reach us and who we are.  I’ve included below the current version and we may update this periodically.
  2. I’ve updated the “Related Links” on the right to highlight the various great resources online for Minecraft Pi Edtion…
  3. The logo has been updated as well to hopefully make clear to everyone why we choose mcpipy for a name 🙂

Here is the current about page..


 

Welcome to MCPIPY (MineCraft for raspberry PI and PYthon) and thanks for checking it out.

The purpose of this blog is to promote the use of Python with Minecraft Pi Edition running on Raspberry Pi.  What we do is:

  1. Find python scripts others have posted to forums, blogs or anywhere else (including occasionally our own creations)
  2. Share out the source, images, videos and some commentary
  3. Add the scripts to our github repository to make it easy for a new and old viewers to get them all easily
  4. Ensure the authors get the credit they deserve — in the blog posting and in the source code.

We do modify the source code as required to ensure it works with the rest of the scripts in the github.  Usually this just means modifying the import statements at the top of the script.

If you are new to the blog I’d recommend starting with these articles:

If you’d like to get in contact with us there are several options.  You can leave a comment, contact us on twitter @mcpipy or email us at mcpipy at mcpipy.com

This blog is maintained by Phillip (fleap in minecraft) and Brooks (bluepillRabbit).

About Phillip:

Hi, I’m Phillip, I’m 9 years old and my nickname is Fleap.  I love programing and Minecraft and I also do html:) check out my website here i also use codeacademy to help me learn. If you want to find me on a server i usually play a server called Empire minecraft the server name is: “smp5.Empire.us”. I do not currently have my own public server YET.   Well we covered about everything about me i want to share here but one more thing to contact me my twitter user name!:) is: fleap123 . Here is a link to my twitter page.. Thats it :) .

About Brooks:

I’m Phillip’s Dad and I started this blog with Phillip because I love Python and what Raspberry PI represents — which is a return to the old days of computing where kids learned how to program and hack these devices to do amazing new things.  When I was a kid, my very first computer was a Franklin Ace 1000 which was a Apple IIe clone.  In those days it wasn’t very easy to get new software – if I wanted to do something new with my computer I’d probably have to get the latest issue of Compute! magazine and type in one of the basic programs like this one.  Things have certainly changed since then, but playing with Raspberry Pi brings me back to those days.  As I’ve seen how much Phillip, my daughters and their friends love Minecraft – I hope Minecraft Pi Edition and Raspberry Pi will give them a chance to experience the joy of creating something for themselves — but making it easy and approachable.  I hope you discover the same things.