Running Minecraft Bedrock Server on Raspberry Pi (or any other ARM devices)

Thursday, August 1, 2019

Update Dec 27 ‘19: Docker image has been updated to mcpelauncher-manifest#e405b8c and should support Minecraft PE 1.14. Haven’t tested yet.

Mojang (Microsoft) released Minecraft Bedrock Dedicated Server a while ago. Apparantly it is written in C++ and runs on Windows 10 and Ubuntu.

It would be so cool if I can run that on my Raspberry Pi 3B. I tried to run Minecraft Java Edition’s server before, and, as expected, it is too laggy to be playable.

Minecraft Bedrock is written in C++, unlike the Java Edition. This theoretically gives a large performance boost. However, Java programs are CPU architecture independent. C++ compiles to native codes and as a result depends on CPU architecture. The bedrock server released by Mojang only targets Intel or AMD CPUs (amd64), not Raspberry Pi CPUs (armhf/aarch64).

There’s still hope though.

  • First, I can use QEMU to run amd64 binaries on armhf.
  • Second, Minecraft on Android targets armhf/aarch64. Android runs on Linux kernel. It is possible to host a server using Minecraft on Android.
  • Third, use a third-party PHP server software.

Option 2 provides native performance and is chosen. A downside is that you need to purchase Minecraft Android to obtain the APK file. Never distribute copyrighted materials!

I use mcpelauncher-extract to extract the binary from the APK file and mcpelauncher-server to launch the binary.

Do all the following steps on your Raspberry Pi!

Extract APK using mcpelauncher-extract

Compile mcpelauncher-extract

apt install -y cmake g++ libzip-dev
git clone https://github.com/minecraft-linux/mcpelauncher-extract.git && cd mcpelauncher-extract
mkdir build && cd build
cmake ..
cmake --build . --target all

Note: If you are using an aarch64 operating system(like me), you might need to replace the following lines in src/main.cpp

#ifdef __arm__
    std::string arch = "armeabi-v7a";
#else
    std::string arch = "x86";
#endif

with

    std::string arch = "armeabi-v7a";

Extract APK

./mcpelauncher-extract <your-apk>.apk /var/lib/minecraft/mcpe

mcpelauncher-server

The Docker Image

It appears that I can only compile mcpelauncher-server on armhf devices. So I made a Docker image that contains those two binaries compiled for armhf devices. And they magically work for aarch64 devices.

The prebuilt docker image is here . The Dockerfile is here . If you want to build the image yourself you need to build it on an armhf machine.

docker run --name minecraft -v /var/lib/minecraft:/data -p 19132:19132/udp -p 19132:19132 -d black0/bedrock-server-armhf:latest

It will take a minute to launch.

Performance

Result? The performance is great. Works like a charm at render distance 22. It is possible to have even higher render distance on the new Raspberry Pi 4.

Raspberry PiARMMinecraftDocker
CC BY-SA 4.0

OTG Ethernet: Connect to Raspberry Pi 4 via USB-C

Hello World

comments powered by Disqus