Take the 2-minute tour ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

I recently downloaded the Minecraft Pi edition for my Raspberry Pi. The main feature of the Minecraft Pi edition is the ability to interactively edit the landscape using Python. One would expect that if you can control a game through Terminal on the Raspberry Pi, you should be able to control it through terminal over ssh. Is this possible?

share|improve this question
1  
In a word, yes. –  Tom Medley Feb 12 '13 at 15:23
add comment

1 Answer

up vote 4 down vote accepted

It is entirely possible to control the Minecraft Pi edition interactively through ssh, with one caveat. To control Minecraft Pi edition, you must first launch Minecraft Pi edition. However, you can only launch it from the Raspberry Pi itself. Once it is launched, however, you will be able to control it through ssh. To do so, first ssh into your Raspberry Pi. Then navigate to the folder containing the Minecraft Pi edition. In this folder are a number of subfolders. You want to navigate to api/python/. Now launch Python in interactive mode, by typing python. To control Minecraft Pi edition, you must then type import mcpi.minecraft as minecraft. Now you can establish a connection to the game by typing mc = minecraft.Minecraft.create(). From this point you can issue commands by typing mc, followed by the command name. For example, mc.postToChat("Hi").

Incidentally, you don't even need ssh in order to control Minecraft Pi edition remotely. If you download Minecraft Pi edition onto your regular PC, you can edit the API to connect to your Pi without ssh. To do this, navigate through api/python/mcpi, and open python.py. Now search for the word localhost, and replace it with the IP address of your Raspberry Pi. Now you can run code locally on your regular computer, and it will still communicate with Minecraft on the Pi. (Assuming Minecraft is running.)

share|improve this answer
6  
I just tried Minecraft on the pi. I could start it over ssh, once I had said startx in another ssh session. This opened a black window on the pc where I ran ssh, and showed the Minecraft graphics on a TV connected to the raspberry. The black window then accepted both mouse and keyboard input, so I could play completely over ssh. –  Frepa Feb 12 '13 at 16:59
    
That is really cool! –  daviewales Feb 13 '13 at 1:01
    
@Frepa any idea how to play Minecraft over SSH without a TV? My main goal is to be able to write Python scripts and see it control Minecraft, but all from my laptop... –  Dave Dec 17 '13 at 19:08
    
@Dave do you mean you want the Minecraft graphics to render on your laptop screen, rather than on your Pi's screen? –  daviewales Dec 19 '13 at 4:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.