How to install Minecraft on a Raspberry Pi

Minecraft on Raspberry Pi

It is well known that the great game of LEGO-type platforms and construction what is Minecraft, if you don't know it I recommend you read a little about himit is very worthwhile. In this tutorial we will show you how to install Minecraft to play it on your Raspberry PiThanks to its compact size and power, it will not be a great challenge and the result is very successful.

It is worth mentioning that this is an unofficial development, but it was developed by one of the staff of Mojang (the company behind Minecraft), so it may have its flaws, and it is based on the version of Minecraft: Pocket Edition (the same as for iOS and Android), so we'll see that it's not the same game we have for PC and Android. we will only be able to make constructions in free modenot play a standard game.

What do we need?

Before we start we will have to stock up on everything you need to install Minecraft on your Raspberry Pi without complications and without giving too many laps, let's start:

  • Of course a Raspberry Pi.
  • Box, HDMI cable, power supply of at least 3A and a uSD card for installation of RaspbianIf it is class 10, everything will go faster too.
  • Optionally, and to further improve its performance, we are going to enable overclockingso we will need to cool the board. I recommend our all-in-one cooling pack.
  • If you don't have your Raspberry Pi connected to the Internet, you will need to download the latest version of Minecraft: Pi EditionIf we have it connected, we will do so in the installation process.

Let's get to work

We assume that we have our Raspberry Pi well configured to start and that we are already on the desktop of our Raspbian system. We open a terminal and download Minecraft: Pi Edition:

[cpp]wget https://s3.amazonaws.com/assets.minecraft.net/pi/minecraft-pi-0.1.1.tar.gz[/cpp]

Once it has finished, unzip it:

[cpp]tar -zxvf minecraft-pi-0.1.1.tar.gz[/cpp]

And we executed it:

[cpp]cd mcpi
./minecraft-pi[/cpp].

Ta-dah, it's as simple as that installing Minecraft on our Raspberry Pibut do we want to investigate further, come on...

Hacking Minecraft: Pi Edition

Thanks to the fact that this version is specially designed for learningcomes with API access so we can program our own variations. We create the test directory /minecraft-tests/ to play around a bit.

[cpp]mkdir minecraft-testing[/cpp]

And we copy all the contents of the Python libraries.

[cpp]cp -r mcpi/api/python/mcpi minecraft-tests/minecraft[/cpp].

We create a new file so as not to break anything.

[cpp]nano minecraft-testing/minecraft-testing.py[/cpp]

We import the Minecraft library and create an object that connects to the game. The first test can be done by sending something to the chat:

[py]import minecraft.minecraft as minecraft

mc = minecraft.Minecraft.create()
mc.postToChat('Hello world!')[/py]

We save and from the terminal we open our beloved file that we have just created. (it is very important to have a game open in the background to see the changes, you can use the Tab key to move from one window to another).:

[cpp]python minecraft-testing/minecraft-testing.py[/cpp]

If we look at the game window we will see how our little code takes effect - magic!

To see the potential of this, let's take a look at a fun hack, the automatic bridge: (the code is not mine, so it is attributed accordingly)

[py]
#Created by www.stuffaboutcode.com
#Adapted by ComoHacer.eu
#Raspberry Pi, Minecraft - Automatic Bridge

1TP3Import minecraft.py module from Minecraft directory
import minecraft.minecraft as minecraft
1TP3We import Minecraft block module
import minecraft.block as block
1TP3We import time in order to be able to use the delays.
import time

#function for positioning players
def roundVec3(vec3):
return minecraft.Vec3(int(vec3.x), int(vec3.y), int(vec3.z))

if __name__ == "__main__":

time.sleep(2)

#Connecting to minecraft by creating the minecraft object
# - we need minecraft to be with an open game
mc = minecraft.Minecraft.create()

#MDisplay a message in the chat window
mc.postToChat("Hello Minecraft - Automatic bridge active")
mc.postToChat("Created by www.stuffaboutcode.com - Adapted by ComoHacer.eu")

#Oget the position of the players
lastPlayerPos = mc.player.getPos()

while (True):

#Oget the position of the players
playerPos = mc.player.getPos()

1TP3Find the difference between the position of the players and the last position.
movementX = lastPlayerPos.x - playerPos.x
movementZ = lastPlayerPos.z - playerPos.z

#SIf the player moves more than 0.2 in any direction horizontally (x, z)
if ((movementX < -0.2) or (movementX > 0.2) or (movementZ < -0.2) or (movementZ > 0.2)):

#Projects the direction of the players to the next square.
nextPlayerPos = playerPos
# maintains the movement of players to the next block if it is encountered.
while ((int(playerPos.x) == int(nextPlayerPos.x)) and (int(playerPos.z) == int(nextPlayerPos.z))):
nextPlayerPos = minecraft.Vec3(nextPlayerPos.x - movementX, nextPlayerPos.y, nextPlayerPos.z - movementZ)

#SIf the following block is air, replace it with a diamond one
blockBelowPos = roundVec3(nextPlayerPos)
#resolves the positions if they were negative
if blockBelowPos.z < 0: blockBelowPos.z = blockBelowPos.z - 1
if blockBelowPos.x < 0: blockBelowPos.x = blockBelowPos.x - 1
blockBelowPos.y = blockBelowPos.y - 1
if mc.getBlock(blockBelowPos) == block.AIR:
mc.setBlock(blockBelowPos.x, blockBelowPos.y, blockBelowPos.z, block.DIAMOND_BLOCK)

#Save the last player position
lastPlayerPos = playerPos

1TP3Delay
time.sleep(0.01)
[/py]

Enjoy, if you program something interesting, pass me the code to try it ­čśÇ.

Buy - Raspberry Pi

Download - Minecraft: Pi Edition, Source code of the automatic bridge

Leave a Comment

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

en_GBEnglish
Scroll to Top