From 2b0f2b4cc12e17541d305f21af30cf9412438775 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Wed, 10 Feb 2021 15:47:38 -0500 Subject: [PATCH] Small Technical Improvement --- MODDING.md | 2 +- .../native/usr/share/minecraft-pi/client/docker-compose.yml | 2 +- .../virgl/usr/share/minecraft-pi/client/docker-compose.yml | 2 +- .../server/usr/share/minecraft-pi/server/docker-compose.yml | 2 +- launcher/src/launcher.c | 6 +++--- libreborn/include/libreborn/minecraft.h | 3 ++- mods/src/misc/misc.c | 5 +++++ mods/src/override/override.c | 2 +- mods/src/screenshot/screenshot.c | 4 ++-- mods/src/server/server.cpp | 4 ++-- mods/src/test/test.c | 4 ++-- 11 files changed, 21 insertions(+), 15 deletions(-) diff --git a/MODDING.md b/MODDING.md index 7830d4c7..18160e64 100644 --- a/MODDING.md +++ b/MODDING.md @@ -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. ## 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 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``. diff --git a/debian/client/native/usr/share/minecraft-pi/client/docker-compose.yml b/debian/client/native/usr/share/minecraft-pi/client/docker-compose.yml index f68c27fb..2dd8e0a5 100644 --- a/debian/client/native/usr/share/minecraft-pi/client/docker-compose.yml +++ b/debian/client/native/usr/share/minecraft-pi/client/docker-compose.yml @@ -6,7 +6,7 @@ services: volumes: - /usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static - '/tmp/.X11-unix:/tmp/.X11-unix' - - '${USER_HOME}/.minecraft-pi:/home/.minecraft' + - '${USER_HOME}/.minecraft-pi:/home/.minecraft-pi' devices: - '/dev/dri:/dev/dri' environment: diff --git a/debian/client/virgl/usr/share/minecraft-pi/client/docker-compose.yml b/debian/client/virgl/usr/share/minecraft-pi/client/docker-compose.yml index 90a81bb5..c5207d17 100644 --- a/debian/client/virgl/usr/share/minecraft-pi/client/docker-compose.yml +++ b/debian/client/virgl/usr/share/minecraft-pi/client/docker-compose.yml @@ -7,7 +7,7 @@ services: - /usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static - '/tmp/.X11-unix:/tmp/.X11-unix' - '/tmp/.virgl_test:/tmp/.virgl_test' - - '${USER_HOME}/.minecraft-pi:/home/.minecraft' + - '${USER_HOME}/.minecraft-pi:/home/.minecraft-pi' environment: - 'DISPLAY=unix${DISPLAY}' - 'MCPI_FEATURES=${MCPI_FEATURES}' diff --git a/debian/server/usr/share/minecraft-pi/server/docker-compose.yml b/debian/server/usr/share/minecraft-pi/server/docker-compose.yml index 0c5b5b07..88dbffa1 100644 --- a/debian/server/usr/share/minecraft-pi/server/docker-compose.yml +++ b/debian/server/usr/share/minecraft-pi/server/docker-compose.yml @@ -5,7 +5,7 @@ services: network_mode: 'host' volumes: - /usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static - - '${MCPI_ROOT}:/home/.minecraft' + - '${MCPI_ROOT}:/home/.minecraft-pi' environment: - 'USER_UID=${USER_UID}' - 'USER_GID=${USER_GID}' diff --git a/launcher/src/launcher.c b/launcher/src/launcher.c index c5e37472..9fec5570 100644 --- a/launcher/src/launcher.c +++ b/launcher/src/launcher.c @@ -105,7 +105,7 @@ int main(__attribute__((unused)) int argc, char *argv[]) { // Minecraft Folder char *minecraft_folder = NULL; - asprintf(&minecraft_folder, "%s/.minecraft", getenv("HOME")); + asprintf(&minecraft_folder, "%s/.minecraft-pi", getenv("HOME")); { // Check Minecraft Folder struct stat obj; @@ -133,9 +133,9 @@ int main(__attribute__((unused)) int argc, char *argv[]) { // Load Mods From ./mods load(&ld_path, &ld_preload, "./mods/"); - // Loads Mods From ~/.minecraft/mods + // Loads Mods From ~/.minecraft-pi/mods 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); free(home_mods); diff --git a/libreborn/include/libreborn/minecraft.h b/libreborn/include/libreborn/minecraft.h index 53915156..91ee045d 100644 --- a/libreborn/include/libreborn/minecraft.h +++ b/libreborn/include/libreborn/minecraft.h @@ -7,7 +7,8 @@ // 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_snowball = (unsigned char **) 0x17bbb0; diff --git a/mods/src/misc/misc.c b/mods/src/misc/misc.c index ebb46dc8..2222dcf3 100644 --- a/mods/src/misc/misc.c +++ b/mods/src/misc/misc.c @@ -6,7 +6,12 @@ #include +#define NEW_PATH "/.minecraft-pi/" + 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")) { // 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}; diff --git a/mods/src/override/override.c b/mods/src/override/override.c index 320d8cf9..4b320809 100644 --- a/mods/src/override/override.c +++ b/mods/src/override/override.c @@ -17,7 +17,7 @@ static int starts_with(const char *s, const char *t) { static char *get_override_path(const char *filename) { // Get Asset Override Path char *overrides = NULL; - asprintf(&overrides, "%s/.minecraft/overrides", getenv("HOME")); + asprintf(&overrides, "%s/.minecraft-pi/overrides", getenv("HOME")); // Get data Path char *data = NULL; char *cwd = getcwd(NULL, 0); diff --git a/mods/src/screenshot/screenshot.c b/mods/src/screenshot/screenshot.c index 73aad697..9626c286 100644 --- a/mods/src/screenshot/screenshot.c +++ b/mods/src/screenshot/screenshot.c @@ -30,7 +30,7 @@ void take_screenshot() { strftime(time, TIME_SIZE, "%Y-%m-%d_%H.%M.%S", timeinfo); char *screenshots = NULL; - asprintf(&screenshots, "%s/.minecraft/screenshots", getenv("HOME")); + asprintf(&screenshots, "%s/.minecraft-pi/screenshots", getenv("HOME")); int num = 1; char *file = NULL; @@ -83,7 +83,7 @@ __attribute__((constructor)) static void init() { // Screenshots Folder char *screenshots_folder = NULL; - asprintf(&screenshots_folder, "%s/.minecraft/screenshots", getenv("HOME")); + asprintf(&screenshots_folder, "%s/.minecraft-pi/screenshots", getenv("HOME")); { // Check Screenshots Folder struct stat obj; diff --git a/mods/src/server/server.cpp b/mods/src/server/server.cpp index 19fd4840..3bdc4bbb 100644 --- a/mods/src/server/server.cpp +++ b/mods/src/server/server.cpp @@ -138,7 +138,7 @@ static void print_progress(unsigned char *minecraft) { static std::string get_banned_ips_file() { std::string file(getenv("HOME")); - file.append("/.minecraft/banned-ips.txt"); + file.append("/.minecraft-pi/banned-ips.txt"); return file; } @@ -421,7 +421,7 @@ static unsigned char get_max_players() { static void server_init() { // Open Properties File std::string file(getenv("HOME")); - file.append("/.minecraft/server.properties"); + file.append("/.minecraft-pi/server.properties"); std::ifstream properties_file(file); diff --git a/mods/src/test/test.c b/mods/src/test/test.c index fd300ae7..621faadb 100644 --- a/mods/src/test/test.c +++ b/mods/src/test/test.c @@ -44,10 +44,10 @@ void run_tests() { } } - // Test ~/.minecraft Permissions + // Test ~/.minecraft-pi Permissions { char *path = NULL; - asprintf(&path, "%s/.minecraft", getenv("HOME")); + asprintf(&path, "%s/.minecraft-pi", getenv("HOME")); int ret = access(path, R_OK | W_OK); free(path);