Hello Minecraft World!

Minecraft screen shots with your Raspberry Pi

We are just about to begin teaching our Python and Minecraft unit at school so I began testing everything out on our latest Raspberry Pi image to make sure we were ready for the lessons and adjust any of the lesson plans if necessary.

Our latest Raspberry Pi image runs Jessie. Now one of the improvements Jessie brings us is that the Print Screen button on your keyboard has been set up to run Scrot in the background to save a png screen shot into your home directory. You can read more about it here.

Now that is great as for quite some time taking a screen shot on your Raspberry Pi involved installing Scrot and then running it from the terminal; not the most user-friendly way to get students to take screen shots!

So with this in mind I thought I would check that we could get our students to take screen shots of both their Python shell and the Minecraft screen if we needed them to document the output of their python scripts. This is where I ran into an issue!

Minecraft appears to run its graphics in some kind of overlay screen which Scrot does not capture when taking a screen shot… This could prove troublesome!

A quick bit of Google searching lead me to Matt Hawkins’ Raspberry Pi Spy website where he has an article on “How To Capture Minecraft Screenshots On The Raspberry Pi” – great! This makes use of AndrewFromMelbourne’s Raspi2png program.

Now I made a couple of changes from Matt’s steps so I thought I would document them here and show some examples of how are students will be able to use this to create documentation of their work on the Raspberry Pis.

Steps to follow

  1. First off you need to ensure the dependencies are installed:
    sudo apt-get install libpng12-dev
  2. Now we move to the /usr/local/bin directory – because that is really where we should be installing local binary and executable files to; at least if you are following the Linux File System Hierarchy 😉 Joking aside, there is a real benefit to installing here; this location is on all users path by default so you can run the command from anywhere!
    cd /usr/local/bin
  3. Now we can grab the latest version of Andrew’s program by downloading it from his Github site
    sudo wget https://github.com/AndrewFromMelbourne/raspi2png/archive/master.zip
  4. Next we unzip the download into the /usr/local/bin directory
    sudo unzip -j ./master.zip
  5. Now we can remove a load of unneeded files
    sudo rm ./master.zip ./LICENSE ./Makefile ./raspi2png.c ./README.md
  6. Now we can test it works. first move to your home directory
    cd ~
  7. Now let’s make a directory to save our screen shots in
    mkdir ./Documents/ScreenShots
  8. Now move into the new directory
    cd ./Documents/ScreenShots
  9. and finally take a screen shot
    raspi2png -p test.png

You should now have a screen shot in your “ScreenShots” directory in your “Documents”. Open it up with your image viewer and check it out!

Raspberry Pi Minecraft Screen shot

Command options

There are a number of different options you can pass to the raspi2png program which will be of use when taking screen shots. The help file for raspi2png lists these:

Usage: raspi2png [--pngname name] [--width ] [--height ] [--compression ] [--delay ] [--display ] [--stdout] [--help]

--pngname,-p - name of png file to create (default is snapshot.png)
--height,-h - image height (default is screen height)
--width,-w - image width (default is screen width)
--compression,-c - PNG compression level (0 - 9)
--delay,-d - delay in seconds (default 0)
--display,-D - Raspberry Pi display number (default 0)
--stdout,-s - write file to stdout
--help,-H - print this usage information

Perhaps the most useful will be the -p and -d options, which will allow you to specify time delay and file name for your screen shot. So for example you can open a terminal in your X session and run this command:

raspi2png -p switch.png -d 15

and then quickly switch to another TTY session by pressing “Ctrl” + “Alt” + “F2”, log in and run a command like “top” and raspi2png will screen shot what is open your TTY2 screen like so:

Raspi2png switch TTY

Conclusion

So in conclusion we are back to using the terminal to take screen shots; but we have the added advantage of being able to screen shot the overlay layer used by Minecraft! Maybe I will get a student to try to write a GUI for the program at a later date!

1 thought on “Minecraft screen shots with your Raspberry Pi

Leave a Reply

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