Example Code

Minecraft-Pi API in LabVIEW

Code and Documents

Attachment

This is the API for the recently released Minecraft edition for the Raspberry Pi computer implemented in LabVIEW 2011. You have to be running the Pi edition of Minecraft on a Raspberry Pi on the same subnet as your LabVIEW code. This doesn't work with the full version of Minecraft.

You can download Minecraft for the Raspberry Pi at http://pi.minecraft.net.

Once installed, start a game and load a world. This will start a server in the background.

In the Minecraft-Pi library, you create a Minecraft-Pi object using Init.vi in the Connection Methods folder. You call it with the IP address of the Raspberry Pi running Minecraft. Once you have created the object, use Connect.vi to connect to the server. From there, if it didn't error, you are connected until you call Close.vi. You can use any of the other methods to set or read the available values. I included the "mcpi-protocol-spec" text file to explain how the functions work.

Beyond that, make sure you can ping your Raspberry Pi and that your networking isn't blocking the ports. The Minecraft-Pi server uses port 4711.

The API functions are contained in a LVClass called Minecraft-pi and are broken into groups based on functionality. There are also several example VIs that show how to connect to Minecraft Pi and use some of the features. All of the inputs and outputs use custom Type-Defs.

Library Contents.png

Below is the block diagram of the Golden Road.vi example which will turn any grass the player walks on to gold.

Golden Road block diagram.png

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors