Modding

Modding
MCPI-Reborn has modding abilities that allows for users to make mods that directly change MCPI or Reborn.

The mods are compiled into ARM shared libraries that are loaded from ~/.minecraft-pi/mods when MCPI launches.

Reborn loads mods when it launches, so MCPI will have to be relaunched each time a mod is changed for the change to take effect.

C and C++ are the most common languages to mod Reborn with, while mods might be possible in any programming languages that allow for compilation into shared libraries, it is highly discoraged.

Changing MCPI
The way that mods change MCPI is exactly how Reborn changes MCPI; by patching and overwriting memory addresses.

To find an address a reverse engineering tool can be used (the most popular one in the Revival community is the NSA's open source ghidra tool).

Another way is to use already known adresses such as the ones in `minecraft.h` which is a header file that is full of useful addresses, property offsets and functions that are very useful for modding.

Property offsets are another way to get or change data in MCPI, once you have an object you can add or subtract a property offset to get a different object from it.

For example if you had a player object and you wanted to get an inventory object from it you would do:

Changing Reborn
Changing Reborn mostly uses a small but powerful macro called HOOK which allows mods to override or proxy calls to a function.

This cannot be done to static or internally visible functions.

Example mods
Here are two very basic example mods, they can be compiled with this command: arm-linux-gnueabihf-gcc -shared -fPIC -Wall -Wextra -O6 -o libfile.so file.c

Hello log!
This mod will print a message to the terminal.

hello-log.c:

Goodbye log!
This will print a message when MCPI is closed

goodbye-log.c: