diff --git a/mods/CMakeLists.txt b/mods/CMakeLists.txt index 37b55a4e..69fe7eb3 100644 --- a/mods/CMakeLists.txt +++ b/mods/CMakeLists.txt @@ -12,7 +12,7 @@ target_link_libraries(compat core SDL EGL GLESv1_CM GLESv2 X11 dl) # Force GLESv1 Link target_link_options(compat PRIVATE "-Wl,--no-as-needed") -add_library(extra SHARED src/extra.c) +add_library(extra SHARED src/extra.c src/extra.cpp) target_link_libraries(extra core dl) add_library(readdir SHARED src/readdir.c) diff --git a/mods/src/extra.c b/mods/src/extra.c index a116dc63..a0328137 100644 --- a/mods/src/extra.c +++ b/mods/src/extra.c @@ -84,6 +84,9 @@ static int has_feature(const char *name) { return ret; } +// Defined In extra.cpp +extern void readAssetFile(unsigned char *target, unsigned char *app_platform, unsigned char *path); + __attribute__((constructor)) static void init() { if (has_feature("Touch GUI")) { // Use Touch UI @@ -120,16 +123,23 @@ __attribute__((constructor)) static void init() { if (has_feature("Fix Attacking")) { // Allow Attacking Mobs - unsigned char patch_data_5[4] = {0x00, 0xf0, 0x20, 0xe3}; - patch((void *) 0x162d4, patch_data_5); + unsigned char patch_data_6[4] = {0x00, 0xf0, 0x20, 0xe3}; + patch((void *) 0x162d4, patch_data_6); } if (has_feature("Mob Spawning")) { // Enable Mob Spawning overwrite((void *) 0xbabec, can_spawn_mobs); - - // Replace CreatorLevel With Level - unsigned char patch_data_4[4] = {0x96, 0x3d, 0x02, 0xeb}; - patch((void *) 0x16f84, patch_data_4); } + + // Replace CreatorLevel With ServerLevel (This Fixes Beds And Mob Spawning) + unsigned char patch_data_4[4] = {0x68, 0x7e, 0x01, 0xeb}; + patch((void *) 0x16f84, patch_data_4); + + // Allocate Correct Size For ServerLevel + unsigned char patch_data_5[4] = {0x94, 0x0b, 0x00, 0x00}; + patch((void *) 0x17004, patch_data_5); + + // Implement AppPlatform::readAssetFile So Translations Work + overwrite((void *) 0x12b10, readAssetFile); } diff --git a/mods/src/extra.cpp b/mods/src/extra.cpp new file mode 100644 index 00000000..ea0c9e8c --- /dev/null +++ b/mods/src/extra.cpp @@ -0,0 +1,15 @@ +#include +#include +#include + +#include + +extern "C" { + std::string readAssetFile(__attribute__((unused)) unsigned char *obj, const std::string& path) { + std::string full_path("./data/"); + full_path.append(path.c_str()); + std::ifstream stream(full_path); + std::string str((std::istreambuf_iterator(stream)), std::istreambuf_iterator()); + return str; + } +}