How to Run Minecraft Pi? Server Creation, Mods, and more!
Ever played the popular sandbox game Minecraft but wonder how you can download and run Minecraft Pi Edition on the Raspberry Pi? With today’s tutorial, I’ll cover the following topics:
- How to install Minecraft Pi
- Creating a Minecraft Pi server for multiplayer
- Running Minecraft Pi Mods with Python Programming API
- Minecraft Pi Projects
Before we get started if you’ve yet to own a Pi, what are you waiting for? Here at Seeed, we carry the latest Raspberry Pi 4 Computer Model B 4GB that guarantees smooth running of Minecraft for your selection!
Installing Minecraft Pi with Raspbian
As Minecraft Pi is the only version of the game that comes with a programming interface, we’ll be running commands on the command terminal. Good news if you’re running Raspbian, the default OS for Raspberry Pi as it should have Minecraft Pi already pre-installed!
However, if for some reason you do not have Minecraft Pi in your system, simply launch the terminal window (4th icon from the left) and run this command at the command prompt:
sudo apt-get install minecraft-pi
Minecraft Pi can then be run by clicking the Desktop Icon or with the command line below:
minecraft-pi
How to create a Minecraft Server?
Have friends that play on the Minecraft Pi too or want to play with other players on the multiplayer server? Here’s how you can set up the latest 1.15.1.jar server with this tutorial!
Note: If you want to access your Minecraft server, you’ll need a paid copy of Minecraft for Windows or Mac, with a username and login.
1. Raspberry Pi Setup
We’ll have to first set up your Raspberry Pi to get it ready. So, first, make sure that your Pi is connected to the internet with WiFI or Ethernet.
Connected? Let’s Get Started!
- Step 1: Open the terminal window and type the following commands:
sudo apt-get update
sudo apt-get upgrade
- Step 2: Type the following command to get into the Raspberry Pi Configuration settings:
sudo raspi-config
Head to Advanced Options -> Memory Split, and change the figure to 16, click save your changes. This way, more memory can be freed for the server.
- Step 3: Finding your local IP address for users to connect to your server once installed
sudo hostname -I
Take note of the outputted number, as you’ll require that for other users to join your server.
- Step 4: Installing Java
As the server setup is only compatible with Minecraft: Java Edition, this step is necessary. Otherwise, you wouldn’t be able to build or launch the server. Install it via the command below:
sudo apt install default-jdk
2. Installing Minecraft Server
Now that we’ve set up everything that you need, its time to download and install the actual Minecraft server software!
- Step 1: Copy and paste the command below in your terminal:
sudo mkdir /home/minecraftcd /home/minecraft
sudo wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
- Step 2: Enter the following command to ensure that you see a file that looks like “BuildTools.jar”
ls
- Step 3: Run the BuildTools file we just downloaded and type the following command to create a Minecraft server
sudo java -jar BuildTools.jar
Once installed, you’ll receive a message that the compilation is done!
3. Launching your Minecraft Server
Now you’re ready to launch and run your Minecraft Server.
- Copy and paste the launch command below into terminal (Ensure that you’re still in the /home/minecraft/directory)
java -Xmx1024M -Xms1024M -jar minecraft_server.1.15.1.jar nogui
- If the Minecraft server stops working after it the End User License Agreement (EULA), you’ll need to open the text document and change the wording as follow:
sudo nano eula.txt
Now your Minecraft server should launch successfully after you run the launch command again!
4. Connect to your Minecraft Server and Start Playing!
Now that your server is up and running, all that’s left is for you to connect to the server!
- Launch Minecraft and log in with your credentials, press play and choose the multiplayer button
- Click on direct connect if you want to enter server details every time you connect or click add server if you want to save the details
- Enter server details with the IP address earlier, click done
- Select server and Join
And now we’re done! Your very own Minecraft Server running on the Raspberry Pi. Enjoy the multiplayer world by sending your IP address to your friends and family!
How to run Minecraft Pi Mods with Python API
Since Minecraft comes with a programming interface, you can create games or run mods to enhance your gaming experience! Not only that, it’s a fun way to start with python programming as well.
The way you can get started is with Python API, allowing you to write programs that control, alter, and unlock the whole new world of Minecraft hacking! Let’s get started with a few fun hacks you can try.
Hello Minecraft World
The first code that all programmers learn is called “Hello World”, which puts “Hello World” on the screen. We’ll be doing the same but in Minecraft!
Here are the steps:
- Head to the Minecraft Menu by hitting the ESC key, but leave the game running
- Open Python IDLE: Menu > Programming > Python 3
- Hit File > New Window and create a new program. Save it as hellominecraftworld.py.
- Import the Minecraft module by copy and pasting the code below:
import mcpi.minecraft as minecraft
- Create a connection from your program to Minecraft, calling it mc: mc = minecraft.Minecraft.create()
- Use your Minecraft connection and the function postToChat() to put the following message in the chat window:
mc.postToChat("Hello Minecraft World")
- Run your program by clicking Run > Run Module
Now head back to Minecraft and you’ll see the message “Hello Minecraft World” on your screen. You’ve now successfully programmed your first code in Minecraft Pi!
Teleportation Mod
Now that you’ve programmed your first code in Minecraft Pi, we’ll move on to some fun hacks you can try. Firstly, teleporting with this teleportation mod!
Using your newly learned skills, we’ll be utilizing the player and block axis to teleport them to wherever you want. When you first spawn, your player starts at point x = 0, y =0, z=0, and by adding codes, you can choose which position you want your player to teleport to.
Here’s how to do with an example of putting your player 100 blocks up the air:
- Add the following code to your Minecraft World Program:
mc.player.setPos(0, 100, 0)
- Click Run > Run Module to run your program
- Switch back to Minecraft and watch your player fall to the floor
You can change the value in setPos() to teleport your player in the places you wish!
Changing Blocks with Block ID Mod
Every played Minecraft and find it difficult to source for the block that you’re looking for? With this mod, you can turn any block in the world into any other block; E.g. Dirt to diamond, water to lava, etc.!
In this tutorial, we’ll be turning a character into an Ice Man, leaving trails of snow wherever he walks and turning blocks into ice with the touch of his sword!
- You can change the code block.SNOW to other different blocks and see what happens with the complete list here!
Here’s are the steps:
- Launch Python 3
- Create a new program and save it as ‘iceman.py’
- Import both Minecraft and block modules at the top of your program:
import mcpi.minecraft as minecraft
import mcpi.block as block
- Create a connection from your program to Minecraft and call it mc: mc = minecraft.Minecraft.create()
- Get your player’s tile position and store it in a variable called: p: p = mc.player.getTilePos()
- Use the setBlock function to change this block to snow:
mc.setBlock(p.x, p.y, p.z, block.SNOW)
- Click Run > Run Module to run your program
Minecraft TNT Run Game
Remember the times where we would place TNT and light it up to clear terrains? Now, we’ll be using it to create a game called TNT Run, where you’ll be running a long line of TNT and trying to make it to safety before it explodes in your face!
What makes this game run special on the Pi edition is the TNT behaves differently here. Normally, when you set off TNT with fire charge or flaming equipment, but in the Pi edition, all you need is to hit it a couple of times with anything. To achieve that, we’ll have to add block data values.
Here’s the code to run this game on your Minecraft Pi:
#import all the necessary modules
from mcpi.minecraft import Minecraft
from mcpi import block
import time
#connect with the minecraft world
mc=Minecraft.create()
#get the players position
pos=mc.player.getTilePos()
#check if the end of the world will engulf your TNT creation and will then move you if you are to close
if pos.z<-40:
mc.postToChat('teleporting to safer distance in progress!')
mc.player.setPos(pos.x,pos.y,-40)
pos=mc.player.getTilePos()
#mark were the teleport is
zpos=pos.z-40
#create the valley by hollowing it out with air
#mc.setBlocks(pos.x-1,pos.y+3,pos.z,pos.x+1,pos.y-7,pos.z,block.AIR.id)
mc.setBlocks(pos.x-1,pos.y+3,pos.z,pos.x+1,pos.y-7,pos.z-88,block.AIR.id)
#build the invisible bedrock support
mc.setBlocks(pos.x,pos.y-1,pos.z,pos.x,pos.y-7,pos.z,block.BEDROCK_INVISIBLE.id)
mc.setBlocks(pos.x-1,pos.y-1,pos.z,pos.x,pos.y-7,pos.z,block.BEDROCK_INVISIBLE.id)
mc.setBlocks(pos.x+1,pos.y-1,pos.z,pos.x,pos.y-7,pos.z,block.BEDROCK_INVISIBLE.id)
mc.setBlocks(pos.x,pos.y-1,pos.z-88,pos.x-1,pos.y-7,pos.z-88,block.BEDROCK_INVISIBLE.id)
mc.setBlocks(pos.x-1,pos.y-1,pos.z-88,pos.x,pos.y-7,pos.z-88,block.BEDROCK_INVISIBLE.id)
mc.setBlocks(pos.x+1,pos.y-1,pos.z-88,pos.x,pos.y-7,pos.z-88,block.BEDROCK_INVISIBLE.id)
mc.setBlocks(pos.x,pos.y,pos.z,pos.x,pos.y-7,pos.z-92,block.BEDROCK_INVISIBLE.id)
#build the bomb
mc.setBlocks(pos.x,pos.y,pos.z,pos.x,pos.y,pos.z-88,block.TNT.id,1)
#build the end podium
mc.setBlocks(pos.x-2,pos.y,pos.z-93,pos.x+2,pos.y,pos.z-97,block.GLOWING_OBSIDIAN.id)
mc.setBlocks(pos.x-1,pos.y+1,pos.z-94,pos.x+1,pos.y+1,pos.z-96,block.NETHER_REACTOR_CORE.id,1)
mc.setBlock(pos.x,pos.y+2,pos.z-95,block.REDSTONE_ORE.id)
#setting how many teleports you have
teleport=1
#build the display teleport signal block
mc.setBlock(pos.x+1,pos.y+1,pos.z-44,block.NETHER_REACTOR_CORE.id,2)
mc.setBlock(pos.x-1,pos.y+1,pos.z-44,block.NETHER_REACTOR_CORE.id,2)
#teleport player when at a certain position
while teleport ==1:
pos=mc.player.getTilePos()
if pos.z==zpos:
mc.player.setPos(pos.x,pos.y,pos.z-24)
teleport=0
Above is just a few Minecraft Pi Edition mods and games you can try. For the full list of what you can do in Minecraft Pi, do check out this Minecraft Essential Guide!
Minecraft Pi Projects
To end off today’s tutorial, here’s an interesting project you can try to enhance your gaming experience on Minecraft Pi Edition!
Build a Custom Controller to Control Minecraft Pi
Want to dump the normal controls of using a Keyboard and Mouse when playing Minecraft Pi? Well, with this project, you’re able to build a custom controller that takes the gaming experience to the next level! Fear not as with the hardware used, interfacing is made simple as well.
What do you need?
Hardware components:
- Dexter Industries GrovePi+
- Raspberry Pi 2 Model B
- Dexter Industries Raspbian for Robots
- Seeed Grove Buttons
- Seeed Grove Joystick
- Wireless Keyboard and Mouse
Software apps and online services:
- Dexter Industries Raspbian for Robots
Interested to find out more? You can check out the full tutorial by Dexter Industries on Seeed Project Hub!
Summary
That’s all for today’s tutorial on Minecraft Pi. I hope with this, you get a basic understanding of how to install Minecraft Pi, create servers and run mods on it!
Do consider the latest and greatest Raspberry Pi 4 Computer Model B to go alongside it!