Small Technical Improvement

This commit is contained in:
TheBrokenRail 2021-02-10 15:47:38 -05:00
parent b81d29095b
commit 2b0f2b4cc1
11 changed files with 21 additions and 15 deletions

View File

@ -5,7 +5,7 @@ Modding Minecraft: Pi Edition is possible by patching the binary at runtime. To
Minecraft: Pi Edition has no symbols so you must patch the hex address of an instruction instead of using a function name. Hex addresses can be found using tools like [Ghidra](https://ghidra-sre.org) or [RetDec](https://retdec.com). To find out what a function does, you can find its equivalent in Minecraft: Pocket Edition 0.6.1 and use its name for reference because Minecraft: Pocket Edition 0.6.1 includes symbols. Minecraft: Pi Edition has no symbols so you must patch the hex address of an instruction instead of using a function name. Hex addresses can be found using tools like [Ghidra](https://ghidra-sre.org) or [RetDec](https://retdec.com). To find out what a function does, you can find its equivalent in Minecraft: Pocket Edition 0.6.1 and use its name for reference because Minecraft: Pocket Edition 0.6.1 includes symbols.
## Loading Directories ## Loading Directories
``minecraft-pi-reborn`` loads mods from two locations, ``/app/minecraft-pi/mods``, and ``~/.minecraft/mods``. The first location only exists in the Docker container and is immutable, so you should place your mods in ``~/.minecraft/mods`` which is mounted on the host as ``~/.minecraft-pi/mods``. ``minecraft-pi-reborn`` loads mods from two locations, ``/app/minecraft-pi/mods``, and ``~/.minecraft-pi/mods``. The first location only exists in the Docker container and is immutable, so you should place your mods in ``~/.minecraft-pi/mods`` which is mounted on the host.
## C++ Strings ## C++ Strings
Minecraft: Pi Edition was compiled with an old version of GCC, so when interacting with C++ strings, make sure you set ``-D_GLIBCXX_USE_CXX11_ABI=0``. Minecraft: Pi Edition was compiled with an old version of GCC, so when interacting with C++ strings, make sure you set ``-D_GLIBCXX_USE_CXX11_ABI=0``.

View File

@ -6,7 +6,7 @@ services:
volumes: volumes:
- /usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static - /usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static
- '/tmp/.X11-unix:/tmp/.X11-unix' - '/tmp/.X11-unix:/tmp/.X11-unix'
- '${USER_HOME}/.minecraft-pi:/home/.minecraft' - '${USER_HOME}/.minecraft-pi:/home/.minecraft-pi'
devices: devices:
- '/dev/dri:/dev/dri' - '/dev/dri:/dev/dri'
environment: environment:

View File

@ -7,7 +7,7 @@ services:
- /usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static - /usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static
- '/tmp/.X11-unix:/tmp/.X11-unix' - '/tmp/.X11-unix:/tmp/.X11-unix'
- '/tmp/.virgl_test:/tmp/.virgl_test' - '/tmp/.virgl_test:/tmp/.virgl_test'
- '${USER_HOME}/.minecraft-pi:/home/.minecraft' - '${USER_HOME}/.minecraft-pi:/home/.minecraft-pi'
environment: environment:
- 'DISPLAY=unix${DISPLAY}' - 'DISPLAY=unix${DISPLAY}'
- 'MCPI_FEATURES=${MCPI_FEATURES}' - 'MCPI_FEATURES=${MCPI_FEATURES}'

View File

@ -5,7 +5,7 @@ services:
network_mode: 'host' network_mode: 'host'
volumes: volumes:
- /usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static - /usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static
- '${MCPI_ROOT}:/home/.minecraft' - '${MCPI_ROOT}:/home/.minecraft-pi'
environment: environment:
- 'USER_UID=${USER_UID}' - 'USER_UID=${USER_UID}'
- 'USER_GID=${USER_GID}' - 'USER_GID=${USER_GID}'

View File

@ -105,7 +105,7 @@ int main(__attribute__((unused)) int argc, char *argv[]) {
// Minecraft Folder // Minecraft Folder
char *minecraft_folder = NULL; char *minecraft_folder = NULL;
asprintf(&minecraft_folder, "%s/.minecraft", getenv("HOME")); asprintf(&minecraft_folder, "%s/.minecraft-pi", getenv("HOME"));
{ {
// Check Minecraft Folder // Check Minecraft Folder
struct stat obj; struct stat obj;
@ -133,9 +133,9 @@ int main(__attribute__((unused)) int argc, char *argv[]) {
// Load Mods From ./mods // Load Mods From ./mods
load(&ld_path, &ld_preload, "./mods/"); load(&ld_path, &ld_preload, "./mods/");
// Loads Mods From ~/.minecraft/mods // Loads Mods From ~/.minecraft-pi/mods
char *home_mods = NULL; char *home_mods = NULL;
asprintf(&home_mods, "%s/.minecraft/mods/", getenv("HOME")); asprintf(&home_mods, "%s/.minecraft-pi/mods/", getenv("HOME"));
load(&ld_path, &ld_preload, home_mods); load(&ld_path, &ld_preload, home_mods);
free(home_mods); free(home_mods);

View File

@ -7,7 +7,8 @@
// Globals // Globals
static char **default_username = (char **) 0x18fd4; static char **default_path = (char **) 0xe264; // /.minecraft/
static char **default_username = (char **) 0x18fd4; // StevePi
static unsigned char **Item_flintAndSteel = (unsigned char **) 0x17ba70; static unsigned char **Item_flintAndSteel = (unsigned char **) 0x17ba70;
static unsigned char **Item_snowball = (unsigned char **) 0x17bbb0; static unsigned char **Item_snowball = (unsigned char **) 0x17bbb0;

View File

@ -6,7 +6,12 @@
#include <libreborn/minecraft.h> #include <libreborn/minecraft.h>
#define NEW_PATH "/.minecraft-pi/"
void init_misc() { void init_misc() {
// Store Data In ~/.minecraft-pi Instead Of ~/.minecraft
patch_address((void *) default_path, (void *) NEW_PATH);
if (feature_has("Remove Invalid Item Background")) { if (feature_has("Remove Invalid Item Background")) {
// Remove Invalid Item Background (A Red Background That Appears For Items That Are Not Included In The gui_blocks Atlas) // Remove Invalid Item Background (A Red Background That Appears For Items That Are Not Included In The gui_blocks Atlas)
unsigned char invalid_item_background_patch[4] = {0x00, 0xf0, 0x20, 0xe3}; unsigned char invalid_item_background_patch[4] = {0x00, 0xf0, 0x20, 0xe3};

View File

@ -17,7 +17,7 @@ static int starts_with(const char *s, const char *t) {
static char *get_override_path(const char *filename) { static char *get_override_path(const char *filename) {
// Get Asset Override Path // Get Asset Override Path
char *overrides = NULL; char *overrides = NULL;
asprintf(&overrides, "%s/.minecraft/overrides", getenv("HOME")); asprintf(&overrides, "%s/.minecraft-pi/overrides", getenv("HOME"));
// Get data Path // Get data Path
char *data = NULL; char *data = NULL;
char *cwd = getcwd(NULL, 0); char *cwd = getcwd(NULL, 0);

View File

@ -30,7 +30,7 @@ void take_screenshot() {
strftime(time, TIME_SIZE, "%Y-%m-%d_%H.%M.%S", timeinfo); strftime(time, TIME_SIZE, "%Y-%m-%d_%H.%M.%S", timeinfo);
char *screenshots = NULL; char *screenshots = NULL;
asprintf(&screenshots, "%s/.minecraft/screenshots", getenv("HOME")); asprintf(&screenshots, "%s/.minecraft-pi/screenshots", getenv("HOME"));
int num = 1; int num = 1;
char *file = NULL; char *file = NULL;
@ -83,7 +83,7 @@ __attribute__((constructor)) static void init() {
// Screenshots Folder // Screenshots Folder
char *screenshots_folder = NULL; char *screenshots_folder = NULL;
asprintf(&screenshots_folder, "%s/.minecraft/screenshots", getenv("HOME")); asprintf(&screenshots_folder, "%s/.minecraft-pi/screenshots", getenv("HOME"));
{ {
// Check Screenshots Folder // Check Screenshots Folder
struct stat obj; struct stat obj;

View File

@ -138,7 +138,7 @@ static void print_progress(unsigned char *minecraft) {
static std::string get_banned_ips_file() { static std::string get_banned_ips_file() {
std::string file(getenv("HOME")); std::string file(getenv("HOME"));
file.append("/.minecraft/banned-ips.txt"); file.append("/.minecraft-pi/banned-ips.txt");
return file; return file;
} }
@ -421,7 +421,7 @@ static unsigned char get_max_players() {
static void server_init() { static void server_init() {
// Open Properties File // Open Properties File
std::string file(getenv("HOME")); std::string file(getenv("HOME"));
file.append("/.minecraft/server.properties"); file.append("/.minecraft-pi/server.properties");
std::ifstream properties_file(file); std::ifstream properties_file(file);

View File

@ -44,10 +44,10 @@ void run_tests() {
} }
} }
// Test ~/.minecraft Permissions // Test ~/.minecraft-pi Permissions
{ {
char *path = NULL; char *path = NULL;
asprintf(&path, "%s/.minecraft", getenv("HOME")); asprintf(&path, "%s/.minecraft-pi", getenv("HOME"));
int ret = access(path, R_OK | W_OK); int ret = access(path, R_OK | W_OK);
free(path); free(path);