Fix On 64-Bit ARM Systems

This commit is contained in:
TheBrokenRail 2021-08-05 21:00:41 -04:00
parent 80d5674781
commit 578bb1c89f
18 changed files with 91 additions and 78 deletions

View File

@ -1 +1 @@
2.1.6 2.1.7

2
debian/client-arm vendored
View File

@ -4,4 +4,4 @@ Maintainer: TheBrokenRail <connor24nolan@live.com>
Description: Fun with Blocks Description: Fun with Blocks
Homepage: https://www.minecraft.net/en-us/edition/pi Homepage: https://www.minecraft.net/en-us/edition/pi
Architecture: armhf Architecture: armhf
Depends: zenity, libgles1, libegl1, libglfw3 | libglfw3-wayland, libfreeimage3 Depends: libc6, libstdc++6, zenity, libgles1, libegl1, libglfw3 | libglfw3-wayland, libfreeimage3

2
debian/client-arm64 vendored
View File

@ -4,4 +4,4 @@ Maintainer: TheBrokenRail <connor24nolan@live.com>
Description: Fun with Blocks Description: Fun with Blocks
Homepage: https://www.minecraft.net/en-us/edition/pi Homepage: https://www.minecraft.net/en-us/edition/pi
Architecture: arm64 Architecture: arm64
Depends: zenity, libgles1, libegl1, libglfw3 | libglfw3-wayland, libfreeimage3, libc6-armhf-cross, libstdc++6-armhf-cross Depends: libc6, libstdc++6, libc6:armhf, libstdc++6:armhf, zenity, libgles1, libegl1, libglfw3 | libglfw3-wayland, libfreeimage3

View File

@ -4,4 +4,4 @@ Maintainer: TheBrokenRail <connor24nolan@live.com>
Description: Fun with Blocks Description: Fun with Blocks
Homepage: https://www.minecraft.net/en-us/edition/pi Homepage: https://www.minecraft.net/en-us/edition/pi
Architecture: amd64 Architecture: amd64
Depends: zenity, libgles1, libegl1, libglfw3 | libglfw3-wayland, libfreeimage3, libc6-armhf-cross, libstdc++6-armhf-cross, qemu-user-static Depends: libc6, libstdc++6, libc6-armhf-cross, libstdc++6-armhf-cross, zenity, libgles1, libegl1, libglfw3 | libglfw3-wayland, libfreeimage3, qemu-user-static

1
debian/server-arm vendored
View File

@ -4,3 +4,4 @@ Maintainer: TheBrokenRail <connor24nolan@live.com>
Description: Fun with Blocks Description: Fun with Blocks
Homepage: https://www.minecraft.net/en-us/edition/pi Homepage: https://www.minecraft.net/en-us/edition/pi
Architecture: armhf Architecture: armhf
Depends: libc6, libstdc++6

2
debian/server-arm64 vendored
View File

@ -4,4 +4,4 @@ Maintainer: TheBrokenRail <connor24nolan@live.com>
Description: Fun with Blocks Description: Fun with Blocks
Homepage: https://www.minecraft.net/en-us/edition/pi Homepage: https://www.minecraft.net/en-us/edition/pi
Architecture: arm64 Architecture: arm64
Depends: libc6-armhf-cross, libstdc++6-armhf-cross Depends: libc6, libstdc++6, libc6:armhf, libstdc++6:armhf

View File

@ -4,4 +4,4 @@ Maintainer: TheBrokenRail <connor24nolan@live.com>
Description: Fun with Blocks Description: Fun with Blocks
Homepage: https://www.minecraft.net/en-us/edition/pi Homepage: https://www.minecraft.net/en-us/edition/pi
Architecture: amd64 Architecture: amd64
Depends: libc6-armhf-cross, libstdc++6-armhf-cross, qemu-user-static Depends: libc6, libstdc++6, libc6-armhf-cross, libstdc++6-armhf-cross, qemu-user-static

View File

@ -1,5 +1,8 @@
# Changelog # Changelog
**2.1.7**
* Fix On 64-Bit ARM Systems
**2.1.6** **2.1.6**
* Optimize Media Layer Proxy * Optimize Media Layer Proxy

View File

@ -181,31 +181,26 @@ void bootstrap(int argc, char *argv[]) {
free(new_ld_preload); free(new_ld_preload);
} }
// Free Binary Directory
free(binary_directory);
// Start Game // Start Game
INFO("%s", "Starting Game..."); INFO("%s", "Starting Game...");
// Use Correct LibC
#ifndef __ARM_ARCH
setenv("QEMU_LD_PREFIX", "/usr/arm-linux-gnueabihf", 1);
#endif
// Select Executable Interpreter
#ifdef __ARM_ARCH #ifdef __ARM_ARCH
// Create Arguments List #define EXE_INTERPRETER "/lib/ld-linux-armhf.so.3"
char *new_argv[argc + 1];
for (int i = 1; i <= argc; i++) {
new_argv[i] = argv[i];
}
new_argv[0] = NULL; // Updated By safe_execvpe()
// Run
safe_execvpe_relative_to_binary(MCPI_NAME, new_argv, environ);
#else #else
// Use Static QEMU So It Isn't Affected By LD_* Variables // Use Static QEMU So It Isn't Affected By LD_* Variables
#define QEMU_NAME "qemu-arm-static" #define EXE_INTERPRETER "qemu-arm-static"
// Use Correct LibC #endif
setenv("QEMU_LD_PREFIX", "/usr/arm-linux-gnueabihf", 1);
// Get Binary Directory
binary_directory = get_binary_directory();
// Create Full Path // Create Full Path
char *full_path = NULL; char *full_path = NULL;
safe_asprintf(&full_path, "%s/" MCPI_NAME, binary_directory); safe_asprintf(&full_path, "%s/" MCPI_NAME, binary_directory);
// Free Binary Directory // Free Binary Directory
free(binary_directory); free(binary_directory);
@ -217,6 +212,5 @@ void bootstrap(int argc, char *argv[]) {
new_argv[0] = NULL; // Updated By safe_execvpe() new_argv[0] = NULL; // Updated By safe_execvpe()
new_argv[1] = full_path; // Path To MCPI new_argv[1] = full_path; // Path To MCPI
// Run // Run
safe_execvpe(QEMU_NAME, new_argv, environ); safe_execvpe(EXE_INTERPRETER, new_argv, environ);
#endif
} }

View File

@ -35,6 +35,7 @@ static unsigned char **Tile_web = (unsigned char **) 0x181d08;
static unsigned char **Tile_topSnow = (unsigned char **) 0x181b30; static unsigned char **Tile_topSnow = (unsigned char **) 0x181b30;
static unsigned char **Tile_ice = (unsigned char **) 0x181d80; static unsigned char **Tile_ice = (unsigned char **) 0x181d80;
static unsigned char **Tile_invisible_bedrock = (unsigned char **) 0x181d94; static unsigned char **Tile_invisible_bedrock = (unsigned char **) 0x181d94;
static unsigned char **Tile_netherReactor = (unsigned char **) 0x181dd0;
static unsigned char **Tile_leaves = (unsigned char **) 0x18120c; static unsigned char **Tile_leaves = (unsigned char **) 0x18120c;
static unsigned char **Tile_leaves_carried = (unsigned char **) 0x181dd8; static unsigned char **Tile_leaves_carried = (unsigned char **) 0x181dd8;

View File

@ -44,6 +44,9 @@ target_link_libraries(death reborn feature)
add_library(misc SHARED src/misc/misc.c src/misc/misc.cpp) add_library(misc SHARED src/misc/misc.c src/misc/misc.cpp)
target_link_libraries(misc reborn feature) target_link_libraries(misc reborn feature)
add_library(creative SHARED src/creative/creative.cpp)
target_link_libraries(creative reborn feature)
add_library(options SHARED src/options/options.c) add_library(options SHARED src/options/options.c)
target_link_libraries(options reborn feature) target_link_libraries(options reborn feature)
@ -69,7 +72,7 @@ add_library(test SHARED src/test/test.c)
target_link_libraries(test reborn home) target_link_libraries(test reborn home)
add_library(init SHARED src/init/init.c) add_library(init SHARED src/init/init.c)
target_link_libraries(init compat game-mode camera input sign misc death options touch textures atlas chat home version test) target_link_libraries(init compat game-mode camera input sign misc creative death options touch textures atlas chat home version test)
if(MCPI_SERVER_MODE) if(MCPI_SERVER_MODE)
target_link_libraries(init server) target_link_libraries(init server)
else() else()
@ -77,7 +80,7 @@ else()
endif() endif()
## Install Mods ## Install Mods
install(TARGETS init compat readdir feature override game-mode camera input sign misc death options touch textures atlas chat home version test DESTINATION "${MCPI_INSTALL_DIR}/mods") install(TARGETS init compat readdir feature override game-mode camera input sign misc creative death options touch textures atlas chat home version test DESTINATION "${MCPI_INSTALL_DIR}/mods")
if(MCPI_SERVER_MODE) if(MCPI_SERVER_MODE)
install(TARGETS server DESTINATION "${MCPI_INSTALL_DIR}/mods") install(TARGETS server DESTINATION "${MCPI_INSTALL_DIR}/mods")
else() else()

View File

@ -0,0 +1,2 @@
# ``creative`` Mod
This mod adds an optional feature flag to add more items to the Creative Mode inventory.

View File

@ -0,0 +1,57 @@
#include <libreborn/libreborn.h>
#include <libreborn/minecraft.h>
#include "../init/init.h"
#include "../feature/feature.h"
// Add Item To Inventory
static void inventory_add_item(unsigned char *inventory, unsigned char *item, bool is_tile) {
ItemInstance *item_instance = new ItemInstance;
ALLOC_CHECK(item_instance);
item_instance = (*(is_tile ? ItemInstance_constructor_tile : ItemInstance_constructor_item))(item_instance, item);
(*FillingContainer_addItem)(inventory, item_instance);
}
// Expand Creative Inventory
static int32_t Inventory_setupDefault_FillingContainer_addItem_call_injection(unsigned char *filling_container, ItemInstance *item_instance) {
// Call Original
int32_t ret = (*FillingContainer_addItem)(filling_container, item_instance);
// Add Items
inventory_add_item(filling_container, *Item_flintAndSteel, false);
inventory_add_item(filling_container, *Item_snowball, false);
inventory_add_item(filling_container, *Item_egg, false);
inventory_add_item(filling_container, *Item_shears, false);
// Dyes
for (int i = 0; i < 16; i++) {
if (i == 15) {
// Bonemeal Is Already In The Creative Inventory
continue;
}
ItemInstance *new_item_instance = new ItemInstance;
ALLOC_CHECK(new_item_instance);
new_item_instance = (*ItemInstance_constructor_item_extra)(new_item_instance, *Item_dye_powder, 1, i);
(*FillingContainer_addItem)(filling_container, new_item_instance);
}
inventory_add_item(filling_container, *Item_camera, false);
// Add Tiles
inventory_add_item(filling_container, *Tile_water, true);
inventory_add_item(filling_container, *Tile_lava, true);
inventory_add_item(filling_container, *Tile_calmWater, true);
inventory_add_item(filling_container, *Tile_calmLava, true);
inventory_add_item(filling_container, *Tile_glowingObsidian, true);
inventory_add_item(filling_container, *Tile_web, true);
inventory_add_item(filling_container, *Tile_topSnow, true);
inventory_add_item(filling_container, *Tile_ice, true);
inventory_add_item(filling_container, *Tile_invisible_bedrock, true);
return ret;
}
// Init
void init_creative() {
// Add Extra Items To Creative Inventory (Only Replace Specific Function Call)
if (feature_has("Expand Creative Inventory", 0)) {
overwrite_call((void *) 0x8e0fc, (void *) Inventory_setupDefault_FillingContainer_addItem_call_injection);
}
}

View File

@ -12,6 +12,7 @@ __attribute__((constructor)) static void init() {
init_input(); init_input();
init_sign(); init_sign();
init_misc(); init_misc();
init_creative();
init_death(); init_death();
init_camera(); init_camera();
init_options(); init_options();

View File

@ -15,6 +15,7 @@ void init_game_mode();
void init_input(); void init_input();
void init_sign(); void init_sign();
void init_misc(); void init_misc();
void init_creative();
void init_death(); void init_death();
void init_camera(); void init_camera();
void init_options(); void init_options();

View File

@ -4,5 +4,4 @@ This mod has several miscellaneous mods that are too small to be their own mod,
* Sanitizing player usernames for invalid characters. * Sanitizing player usernames for invalid characters.
* Removing the red background from unobtainable items in the inventory. * Removing the red background from unobtainable items in the inventory.
* Loading the bundled language file. * Loading the bundled language file.
* Optionally expanding the Creative Inventory.
* Printing chat messages to the log. * Printing chat messages to the log.

View File

@ -5,9 +5,9 @@
#include <libreborn/libreborn.h> #include <libreborn/libreborn.h>
#include <libreborn/minecraft.h> #include <libreborn/minecraft.h>
#include "../init/init.h"
#include "../feature/feature.h" #include "../feature/feature.h"
#include "misc.h" #include "misc.h"
#include "../init/init.h"
// Maximum Username Length // Maximum Username Length
#define MAX_USERNAME_LENGTH 16 #define MAX_USERNAME_LENGTH 16

View File

@ -5,12 +5,11 @@
#include <cstring> #include <cstring>
#include <libreborn/libreborn.h> #include <libreborn/libreborn.h>
#include <libreborn/minecraft.h>
#include "../feature/feature.h" #include "../feature/feature.h"
#include "misc.h" #include "misc.h"
#include <libreborn/minecraft.h>
// Read Asset File // Read Asset File
static AppPlatform_readAssetFile_return_value AppPlatform_readAssetFile_injection(__attribute__((unused)) unsigned char *app_platform, std::string const& path) { static AppPlatform_readAssetFile_return_value AppPlatform_readAssetFile_injection(__attribute__((unused)) unsigned char *app_platform, std::string const& path) {
// Read File // Read File
@ -25,49 +24,6 @@ static AppPlatform_readAssetFile_return_value AppPlatform_readAssetFile_injectio
return ret; return ret;
} }
// Add Item To Inventory
static void inventory_add_item(unsigned char *inventory, unsigned char *item, bool is_tile) {
ItemInstance *item_instance = new ItemInstance;
ALLOC_CHECK(item_instance);
item_instance = (*(is_tile ? ItemInstance_constructor_tile : ItemInstance_constructor_item))(item_instance, item);
(*FillingContainer_addItem)(inventory, item_instance);
}
// Expand Creative Inventory
static int32_t Inventory_setupDefault_FillingContainer_addItem_call_injection(unsigned char *filling_container, ItemInstance *item_instance) {
// Call Original
int32_t ret = (*FillingContainer_addItem)(filling_container, item_instance);
// Add Items
inventory_add_item(filling_container, *Item_flintAndSteel, false);
inventory_add_item(filling_container, *Item_snowball, false);
inventory_add_item(filling_container, *Item_egg, false);
inventory_add_item(filling_container, *Item_shears, false);
for (int i = 0; i < 16; i++) {
if (i == 15) {
// Bonemeal Is Already In The Creative Inventory
continue;
}
ItemInstance *new_item_instance = new ItemInstance;
ALLOC_CHECK(new_item_instance);
new_item_instance = (*ItemInstance_constructor_item_extra)(new_item_instance, *Item_dye_powder, 1, i);
(*FillingContainer_addItem)(filling_container, new_item_instance);
}
inventory_add_item(filling_container, *Item_camera, false);
// Add Tiles
inventory_add_item(filling_container, *Tile_water, true);
inventory_add_item(filling_container, *Tile_lava, true);
inventory_add_item(filling_container, *Tile_calmWater, true);
inventory_add_item(filling_container, *Tile_calmLava, true);
inventory_add_item(filling_container, *Tile_glowingObsidian, true);
inventory_add_item(filling_container, *Tile_web, true);
inventory_add_item(filling_container, *Tile_topSnow, true);
inventory_add_item(filling_container, *Tile_ice, true);
inventory_add_item(filling_container, *Tile_invisible_bedrock, true);
return ret;
}
// Print Chat To Log // Print Chat To Log
static bool Gui_addMessage_recursing = false; static bool Gui_addMessage_recursing = false;
static void Gui_addMessage_injection(unsigned char *gui, std::string const& text) { static void Gui_addMessage_injection(unsigned char *gui, std::string const& text) {
@ -105,11 +61,6 @@ void _init_misc_cpp() {
overwrite((void *) AppPlatform_readAssetFile, (void *) AppPlatform_readAssetFile_injection); overwrite((void *) AppPlatform_readAssetFile, (void *) AppPlatform_readAssetFile_injection);
} }
// Add Extra Items To Creative Inventory (Only Replace Specific Function Call)
if (feature_has("Expand Creative Inventory", 0)) {
overwrite_call((void *) 0x8e0fc, (void *) Inventory_setupDefault_FillingContainer_addItem_call_injection);
}
// Print Chat To Log // Print Chat To Log
overwrite_calls((void *) Gui_addMessage, (void *) Gui_addMessage_injection); overwrite_calls((void *) Gui_addMessage, (void *) Gui_addMessage_injection);
} }