From 9efaf5ec4219a82b5b1cca0e9e4e358271b79912 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Thu, 4 Mar 2021 19:27:24 -0500 Subject: [PATCH] Document Patches --- debian/client/common/usr/bin/minecraft-pi | 3 --- docs/DEDICATED_SERVER.md | 25 +++++++++++++++++++++-- libreborn/include/libreborn/minecraft.h | 4 ++++ libreborn/src/libreborn.c | 2 +- mods/src/chat/chat.cpp | 2 +- mods/src/game_mode/game_mode.c | 12 +++++------ mods/src/game_mode/game_mode.cpp | 2 +- mods/src/misc/misc.c | 2 +- mods/src/options/options.c | 10 ++++----- mods/src/server/server.cpp | 6 +++--- mods/src/textures/textures.cpp | 2 +- scripts/package.sh | 2 +- 12 files changed, 47 insertions(+), 25 deletions(-) diff --git a/debian/client/common/usr/bin/minecraft-pi b/debian/client/common/usr/bin/minecraft-pi index df94907c..e834e916 100755 --- a/debian/client/common/usr/bin/minecraft-pi +++ b/debian/client/common/usr/bin/minecraft-pi @@ -34,9 +34,6 @@ export MCPI_FEATURES export MCPI_RENDER_DISTANCE export MCPI_USERNAME -# Allow X11 Connections From Root -xhost local:root - # Prepare Environment export USER_HOME="${HOME}" export USER_UID="$(id -u)" diff --git a/docs/DEDICATED_SERVER.md b/docs/DEDICATED_SERVER.md index b299ed6e..3f42e269 100644 --- a/docs/DEDICATED_SERVER.md +++ b/docs/DEDICATED_SERVER.md @@ -1,10 +1,31 @@ # Dedicated Server The dedicated server is a version of Minecraft: Pi Edition modified to run in a headless environment. It loads settings from a ``server.properties`` file. -To use, install the ``minecraft-pi-reborn-server`` package and run ``minecraft-pi-reborn-server``. It will generate the world and ``server.properties`` in the current directory. - This server is also compatible with MCPE Alpha v0.6.1. +## Setup + +### Debian Package +To use, install the ``minecraft-pi-reborn-server`` package and run ``minecraft-pi-reborn-server`` or use. It will generate the world and ``server.properties`` in the current directory. + +### Docker Compose +Make sure you have ``qemu-user-static`` installed and ``binfmt`` setup. +```yml +version: "3.7" + +services: + minecraft-pi: + image: thebrokenrail/minecraft-pi-reborn:server + volumes: + - ./minecraft-pi/data:/home/.minecraft-pi + - /usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static + restart: always + stdin_open: true + tty: true + ports: + - "19132:19132/udp" +``` + ## Server Limitations - Player data is not saved because of limitations with MCPE LAN worlds - An easy workaround is to place your inventory in a chest before logging off diff --git a/libreborn/include/libreborn/minecraft.h b/libreborn/include/libreborn/minecraft.h index 53de81a9..41c23142 100644 --- a/libreborn/include/libreborn/minecraft.h +++ b/libreborn/include/libreborn/minecraft.h @@ -124,6 +124,10 @@ static uint32_t Minecraft_gui_property_offset = 0x198; // Gui static uint32_t CommandServer_minecraft_property_offset = 0x18; // Minecraft * +// ServerLevel + +#define SERVER_LEVEL_SIZE 0xb80 + // Packet typedef void (*Packet_read_t)(unsigned char *packet, unsigned char *bit_stream); diff --git a/libreborn/src/libreborn.c b/libreborn/src/libreborn.c index 717e6da6..8e8f65af 100644 --- a/libreborn/src/libreborn.c +++ b/libreborn/src/libreborn.c @@ -172,7 +172,7 @@ void _overwrite_calls(const char *file, int line, void *start, void *target) { // Overwrite Function void _overwrite(const char *file, int line, void *start, void *target) { - unsigned char patch_data[4] = {0x04, 0xf0, 0x1f, 0xe5}; + unsigned char patch_data[4] = {0x04, 0xf0, 0x1f, 0xe5}; // "ldr pc, [pc, #-0x4]" _patch(file, line, start, patch_data); _patch_address(file, line, start + 4, target); diff --git a/mods/src/chat/chat.cpp b/mods/src/chat/chat.cpp index fb5d400f..1c6a63d1 100644 --- a/mods/src/chat/chat.cpp +++ b/mods/src/chat/chat.cpp @@ -111,7 +111,7 @@ void chat_send_messages(unsigned char *minecraft) { // Init void init_chat() { // Disable Original ChatPacket Loopback - unsigned char disable_chat_packet_loopback_patch[4] = {0x00, 0xf0, 0x20, 0xe3}; + unsigned char disable_chat_packet_loopback_patch[4] = {0x00, 0xf0, 0x20, 0xe3}; // "nop" patch((void *) 0x6b490, disable_chat_packet_loopback_patch); // Manually Send (And Loopback) ChatPacket overwrite_call((void *) 0x6b518, (void *) CommandServer_parse_CommandServer_dispatchPacket_injection); diff --git a/mods/src/game_mode/game_mode.c b/mods/src/game_mode/game_mode.c index bd4479bd..47dc4c8c 100644 --- a/mods/src/game_mode/game_mode.c +++ b/mods/src/game_mode/game_mode.c @@ -13,11 +13,11 @@ static void set_is_survival(int new_is_survival) { INFO("Setting Game Mode: %s", new_is_survival ? "Survival" : "Creative"); // Correct Inventpry UI - unsigned char inventory_patch[4] = {new_is_survival ? 0x00 : 0x01, 0x30, 0xa0, 0xe3}; + unsigned char inventory_patch[4] = {new_is_survival ? 0x00 : 0x01, 0x30, 0xa0, 0xe3}; // "mov r3, #0x0" or "mov r3, #0x1" patch((void *) 0x16efc, inventory_patch); // Use Correct Size For GameMode Object - unsigned char size_patch[4] = {new_is_survival ? SURVIVAL_MODE_SIZE : CREATOR_MODE_SIZE, 0x00, 0xa0, 0xe3}; + unsigned char size_patch[4] = {new_is_survival ? SURVIVAL_MODE_SIZE : CREATOR_MODE_SIZE, 0x00, 0xa0, 0xe3}; // "mov r0, #SURVIVAL_MODE_SIZE" or "mov r0, #CREATOR_MODE_SIZE" patch((void *) 0x16ee4, size_patch); // Replace Default CreatorMode Constructor With CreatorMode Or SurvivalMode Constructor @@ -41,15 +41,15 @@ void init_game_mode() { overwrite_calls((void *) Minecraft_setIsCreativeMode, Minecraft_setIsCreativeMode_injection); // Replace CreatorLevel With ServerLevel (This Fixes Beds And Mob Spawning) - unsigned char level_patch[4] = {0x68, 0x7e, 0x01, 0xeb}; + unsigned char level_patch[4] = {0x68, 0x7e, 0x01, 0xeb}; // "bl 0x7692c" patch((void *) 0x16f84, level_patch); // Allocate Correct Size For ServerLevel - unsigned char level_size_patch[4] = {0x94, 0x0b, 0x00, 0x00}; - patch((void *) 0x17004, level_size_patch); + uint32_t level_size = SERVER_LEVEL_SIZE; + patch((void *) 0x17004, (unsigned char *) &level_size); // Allow Connecting To Survival Servers - unsigned char server_patch[4] = {0x0f, 0x00, 0x00, 0xea}; + unsigned char server_patch[4] = {0x0f, 0x00, 0x00, 0xea}; // "b 0x6dcb4" patch((void *) 0x6dc70, server_patch); // Init C++ diff --git a/mods/src/game_mode/game_mode.cpp b/mods/src/game_mode/game_mode.cpp index 4b1f3193..9d25c3d8 100644 --- a/mods/src/game_mode/game_mode.cpp +++ b/mods/src/game_mode/game_mode.cpp @@ -53,6 +53,6 @@ void init_game_mode_cpp() { patch_address(SelectWorldScreen_tick_vtable_addr, (void *) SelectWorldScreen_tick_injection); patch_address(Touch_SelectWorldScreen_tick_vtable_addr, (void *) Touch_SelectWorldScreen_tick_injection); // Make The SimpleChooseLevelScreen Back Button Go To SelectWorldScreen Instead Of StartMenuScreen - unsigned char simple_choose_level_screen_back_button_patch[4] = {0x05, 0x10, 0xa0, 0xe3}; + unsigned char simple_choose_level_screen_back_button_patch[4] = {0x05, 0x10, 0xa0, 0xe3}; // "mov r1, #0x5" patch((void *) 0x31144, simple_choose_level_screen_back_button_patch); } \ No newline at end of file diff --git a/mods/src/misc/misc.c b/mods/src/misc/misc.c index 227c7131..8d160331 100644 --- a/mods/src/misc/misc.c +++ b/mods/src/misc/misc.c @@ -71,7 +71,7 @@ void init_misc() { 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}; + unsigned char invalid_item_background_patch[4] = {0x00, 0xf0, 0x20, 0xe3}; // "nop" patch((void *) 0x63c98, invalid_item_background_patch); } diff --git a/mods/src/options/options.c b/mods/src/options/options.c index 55da7b05..2aabbf93 100644 --- a/mods/src/options/options.c +++ b/mods/src/options/options.c @@ -78,7 +78,7 @@ void init_options() { // Main UI overwrite((void *) Minecraft_isTouchscreen, Minecraft_isTouchscreen_injection); // Force Correct Toolbar Size - unsigned char toolbar_patch[4] = {0x01, 0x00, 0x50, 0xe3}; + unsigned char toolbar_patch[4] = {0x01, 0x00, 0x50, 0xe3}; // "cmp r0, #0x1" patch((void *) 0x257b0, toolbar_patch); } @@ -115,24 +115,24 @@ void init_options() { if (feature_has("Disable Autojump By Default")) { // Disable Autojump By Default - unsigned char autojump_patch[4] = {0x00, 0x30, 0xa0, 0xe3}; + unsigned char autojump_patch[4] = {0x00, 0x30, 0xa0, 0xe3}; // "mov r3, #0x0" patch((void *) 0x44b90, autojump_patch); } if (feature_has("Display Nametags By Default")) { // Display Nametags By Default - unsigned char display_nametags_patch[4] = {0x1d, 0x60, 0xc0, 0xe5}; + unsigned char display_nametags_patch[4] = {0x1d, 0x60, 0xc0, 0xe5}; // "strb r6, [r0, #0x1d]" patch((void *) 0xa6628, display_nametags_patch); } // Show Block Outlines int block_outlines = feature_has("Show Block Outlines"); - unsigned char outline_patch[4] = {block_outlines ? !touch_gui : touch_gui, 0x00, 0x50, 0xe3}; + unsigned char outline_patch[4] = {block_outlines ? !touch_gui : touch_gui, 0x00, 0x50, 0xe3}; // "cmp r0, #0x1" or "cmp r0, #0x0" patch((void *) 0x4a210, outline_patch); smooth_lighting = feature_has("Smooth Lighting"); if (smooth_lighting) { // Enable Smooth Lighting - unsigned char smooth_lighting_patch[4] = {0x01, 0x00, 0x53, 0xe3}; + unsigned char smooth_lighting_patch[4] = {0x01, 0x00, 0x53, 0xe3}; // "cmp r3, #0x1" patch((void *) 0x59ea4, smooth_lighting_patch); } } \ No newline at end of file diff --git a/mods/src/server/server.cpp b/mods/src/server/server.cpp index 7f9b2210..e990ee47 100644 --- a/mods/src/server/server.cpp +++ b/mods/src/server/server.cpp @@ -464,7 +464,7 @@ static void server_init() { } // Prevent Main Player From Loading - unsigned char player_patch[4] = {0x00, 0x20, 0xa0, 0xe3}; + unsigned char player_patch[4] = {0x00, 0x20, 0xa0, 0xe3}; // "mov r2, #0x0" patch((void *) 0x1685c, player_patch); // Start World On Launch overwrite_calls((void *) Minecraft_update, (void *) Minecraft_update_injection); @@ -474,14 +474,14 @@ static void server_init() { signal(SIGINT, exit_handler); signal(SIGTERM, exit_handler); // Set Max Players - unsigned char max_players_patch[4] = {get_max_players(), 0x30, 0xa0, 0xe3}; + unsigned char max_players_patch[4] = {get_max_players(), 0x30, 0xa0, 0xe3}; // "mov r3, #MAX_PLAYERS" patch((void *) 0x166d0, max_players_patch); // Custom Banned IP List overwrite((void *) RakNet_RakPeer_IsBanned, (void *) RakNet_RakPeer_IsBanned_injection); if (get_server_properties().get_bool("show-minecon-badge", DEFAULT_SHOW_MINECON_BADGE)) { // Show The MineCon Icon Next To MOTD In Server List - unsigned char minecon_badge_patch[4] = {0x04, 0x1a, 0x9f, 0xe5}; + unsigned char minecon_badge_patch[4] = {0x04, 0x1a, 0x9f, 0xe5}; // "ldr r1, [0x741f0]" patch((void *) 0x737e4, minecon_badge_patch); } diff --git a/mods/src/textures/textures.cpp b/mods/src/textures/textures.cpp index b67ccbda..e60642a8 100644 --- a/mods/src/textures/textures.cpp +++ b/mods/src/textures/textures.cpp @@ -63,7 +63,7 @@ void init_textures() { if (feature_has("Disable gui_blocks Atlas")) { // Disable gui_blocks Atlas Which Contains Pre-Rendered Textures For Blocks In The Inventory - unsigned char disable_gui_blocks_atlas_patch[4] = {0x00, 0xf0, 0x20, 0xe3}; + unsigned char disable_gui_blocks_atlas_patch[4] = {0x00, 0xf0, 0x20, 0xe3}; // "nop" patch((void *) 0x63c2c, disable_gui_blocks_atlas_patch); // Fix Grass And Leaves Inventory Rendering When The gui_blocks Atlas Is Disabled overwrite_calls((void *) ItemRenderer_renderGuiItemCorrect, (void *) ItemRenderer_renderGuiItemCorrect_injection); diff --git a/scripts/package.sh b/scripts/package.sh index 7dd16f87..c5f692d0 100755 --- a/scripts/package.sh +++ b/scripts/package.sh @@ -6,7 +6,7 @@ DEB_VERSION='1.0.0' # Dependencies REQUIRED_DOCKER_VERSION='19.03' COMMON_DEPENDENCIES="docker.io (>=${REQUIRED_DOCKER_VERSION}) | docker-ce (>=${REQUIRED_DOCKER_VERSION}), libseccomp2 (>=2.4.2), docker-compose, binfmt-support" -CLIENT_DEPENDENCIES='zenity, x11-xserver-utils, login, policykit-1, passwd' +CLIENT_DEPENDENCIES='zenity, login, policykit-1, passwd' RECOMMENDED_DEPENDENCIES='qemu-user-static' set -e