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?
1 Answers
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.)
- 221
- 2
- 11