Minecraft Client on ODROID

Minecraft landscape

Minecraft can now be played on the ODROID! Installation is pretty easy, thanks to the packaging skills of Tobias aka @meveric. After installing his repository, type the following command:

$ sudo apt-get install minecraft-odroid
Minecraft will install with a couple of dependencies and be ready to launch. It comes packaged with the default launcher, so you can play the demo, or you can login with your account to play.

Performances

One thing to know is that currently, it’s not really compatible with mipmaps, and will get poor performances unless you set mipmaps to “none”. Once the game has started, go to the Options menu, select Video, then choose Mipmap Levels: OFF.

Figure 1 - Video Settings

After that, other settings are pretty standard and have the expected effect. I recommend lowering the Render Distance (5 chunks is fine but you may want to lower this to get more FPS), choose Graphics: Fast (so that tree leaves will not be transparent), and set Smooth Lightning to OFF for max speed or Minimum for some soft shadows (but it’s slower). Also, the Max Framerate should be around your current FPS (30 fps is nice for a smooth gameplay). With these settings, I can get around 12 to 15 FPS in full HD. You can use “F3” during the game to have some statistics displayed, including FPS, but be aware that the F3 screen uses some FPS itself, around 3 or 4 at least.

Figure 2 - Death screen

More performance

If you want your Minecraft to run faster, you can use OptiFine, which is a mod that lets you tweak many Minecraft settings as well as the rendering method in order to get smoother gameplay. You need to first start Minecraft and launch a game, so that the current version of Minecraft is registered and downloaded. Then, go to the OptiFine website at http://bit.ly/1jOG2Di and download the version for your Minecraft version (at the time of writing, it’s 1.9.4). You will receive a .jar file that can launched, which will install automatically. To launch it, just double-click or, using a terminal, type the following command:

$ java -jar OptiFine_1.9.4_HD_U_B4.jar
You will then see a menu asking what you want to do. OptiFine first auto-detects the locale Minecraft folder, and after a short while, it should install smoothly,

Figures 3 - Optifine mod installation

Re-launch Minecraft, and you will notice that the profile is now called OptiFine. Once in game, you will notice the chunks are loading faster. There are a lot more settings to play with in the Options screen, as shown in Figure 5.

Figure 4 - Optifine video settings

Without touching anything, OptiFine can give you a few more FPS (I get 4 FPS more on my ODROID), but it greatly depends on the actual configuration. I estimate that you can expect around 25% to 50% better performance.

How it works

The first question you may ask is why Minecraft wasn’t available sooner on the ODROID. After all, it’s a Java game, so it should run as is. However, Java programs are not CPU dependent, and not system dependent either, since it’s a Virtual Machine. So, a Java program that runs on x86/Windows can also be run on x86/Linux or ARM/Linux. Sometimes Java is not enough to make a program, and you need to interface with some native library to do more advanced stuff. It’s called JNI (Java Native Interface), and it’s a mechanism that allows a Java program to directly call a native library. For example, you need that to use an OpenAL sound or OpenGL graphics, and that’s what Minecraft does: it uses a Java library called “lwjgl” (Light Weight Java GL) to access OpenGL for the rendering. In order to use this library, Minecraft downloads it directly from its server, along with all other needed libraries and assets, when you first launch a game. And it checks you have everything correctly in place every time you launch it. The issue is that Minecraft is not supported on ARM. It doesn’t even know this architecture. So when it downloads its version of lwjgl, it obtains a version meant for an x86 CPU, which simply doesn’t work because it’s not the right one. To work around that, a special launcher has been created which intercepts all calls to Java, analyzes the commands, and replaces the link to the x86 version with the one installed in the system. It’s a bit crude, but it does work in allowing Minecraft to start. Although it does start, it doesn’t get far since it needs OpenGL, and the ODROID only provides GLES. So glshim needs to be used in order to translate all OpenGL calls to GLES. Glshim has only provided OpenGL 1.5 up until now, so Minecraft warns us to update our drivers with a warning that OpenGL 1.x won’t be supported anymore, and OpenGL 2.0 will be needed. Incidentally, glshim contains some special hacks that were created specifically for Minecraft. The first version of Minecraft on ARM machine was on the OpenPandora, 2 years ago. And in the beginning, it looked as shown in Figure 5.

Figure 5 - Early version of Minecraft on OpenPandora

As you can see, it was not very colorful! After some debugging, I eventually coded a hack in glshim to compensate for the way that Minecraft does its lighting. It uses multitexturing, where the first texture is the color of the block, and the second texture is the light map, which is a very common method of lighting. However, what Minecraft does is render the textures such that each block is considered to have a uniform lightning, so that you don’t have a half-lit block. So, when issuing the drawing command for a block/cube, all the vertex coordinates are given to openGL, along with the textures coordinates for the first texture, with only one texture coordinate for the light map. And that case, which is technically correct according to OpenGL specs), wasn’t handled by glshim. It was fixed by checking to see if there were only one texture coordinates for a texture. In that case, those coordinates are duplicated for all vertexes, making it easier to handle in glshim. If you are curious about the technical details, inpect the function “glshim_glEnd” in the file “gl.c” (http://bit.ly/24WP30W).

What’s next

After creating the custom launcher and modifying glshim, Minecraft runs pretty well. Still, things can always be improved. There are still three main areas to work on in the glshim application:

  • Improve the handling of the Mipmap settings
  • Get more speed by using Batch mode of glshim
  • Have a glshim working in GLES2

The mipmap settings is a bit puzzling, and I have to understand what the Mipmap levels really do, which is not easy with closed source software. The Batch mode can be quite effective sometimes, such as with Xash3D or Emilia Pinball, for example, but completely ineffective sometimes. It can even break the rendering engine, as is the case with Minecraft. More work is needed to get this feature stabilized. Having glshim use GLES2, and proposing an OpenGL 2.x version is a long term goal for glshim, but will be needed sooner or later, as more and more software has dropped support for the fixed pipeline, which is an OpenGL 1.x function, in favor of using shading instead.

Be the first to comment

Leave a Reply