diff --git a/VERSION b/VERSION index f041bc6..3f5987a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.4.8 +2.4.9 diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 5238f9e..d105af3 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +**2.4.9** +* Allow Overriding GUI Scale With ``MCPI_GUI_SCALE`` Environmental Variable +* Add ``Disable Block Tinting`` Feature Flag (Disabled By Default) +* Add ``Disable Hostile AI In Creative Mode`` Feature Flag (Enabled By Default) +* Allow Accessing Configuration At Runtime (Useful For Mods That Need To Support Multiple Versions) + **2.4.8** * Fix Bug In ``extract_from_bl_instruction`` * Update LIEF And GLFW diff --git a/images/start.png b/images/start.png index d6e4091..328d183 100644 Binary files a/images/start.png and b/images/start.png differ diff --git a/launcher/src/client/available-feature-flags b/launcher/src/client/available-feature-flags index e987638..f2232a3 100644 --- a/launcher/src/client/available-feature-flags +++ b/launcher/src/client/available-feature-flags @@ -46,3 +46,5 @@ FALSE Disable Speed Bridging FALSE Disable Creative Mode Mining Delay FALSE Add Biome Colors To Grass TRUE Generate Caves +FALSE Disable Block Tinting +TRUE Disable Hostile AI In Creative Mode diff --git a/libreborn/include/libreborn/util.h b/libreborn/include/libreborn/util.h index 13da730..46e9d8f 100644 --- a/libreborn/include/libreborn/util.h +++ b/libreborn/include/libreborn/util.h @@ -45,6 +45,11 @@ int is_progress_difference_significant(int32_t new_val, int32_t old_val); int lock_file(const char *file); void unlock_file(const char *file, int fd); +// Access Configuration At Runtime +const char *reborn_get_version(); +int reborn_is_headless(); +int reborn_is_server(); + #ifdef __cplusplus } #endif diff --git a/libreborn/src/util/util.c b/libreborn/src/util/util.c index 5d5af34..6a37b7b 100644 --- a/libreborn/src/util/util.c +++ b/libreborn/src/util/util.c @@ -2,6 +2,7 @@ #include #include +#include // Safe Version Of pipe() void safe_pipe2(int pipefd[2], int flags) { @@ -43,3 +44,22 @@ void unlock_file(const char *file, int fd) { } close(fd); } + +// Access Configuration At Runtime +const char *reborn_get_version() { + return MCPI_VERSION; +} +int reborn_is_headless() { +#ifdef MCPI_HEADLESS_MODE + return 1; +#else + return 0; +#endif +} +int reborn_is_server() { +#ifdef MCPI_SERVER_MODE + return 1; +#else + return 0; +#endif +} diff --git a/mods/src/misc/misc.c b/mods/src/misc/misc.c index 1bc8d6a..6cf4121 100644 --- a/mods/src/misc/misc.c +++ b/mods/src/misc/misc.c @@ -390,6 +390,31 @@ static void RandomLevelSource_buildSurface_injection(unsigned char *random_level (*LargeCaveFeature_apply)(cave_feature, random_level_source, level, chunk_x, chunk_y, chunk_data, 0); } +// No Block Tinting +static int32_t Tile_getColor_injection() { + return 0xffffff; +} + +// Disable Hostile AI In Creative Mode +static unsigned char *PathfinderMob_findAttackTarget_injection(unsigned char *mob) { + // Call Original Method + unsigned char *mob_vtable = *(unsigned char **) mob; + PathfinderMob_findAttackTarget_t PathfinderMob_findAttackTarget = *(PathfinderMob_findAttackTarget_t *) (mob_vtable + PathfinderMob_findAttackTarget_vtable_offset); + unsigned char *target = (*PathfinderMob_findAttackTarget)(mob); + + // Check If Creative Mode + if (target != NULL) { + unsigned char *inventory = *(unsigned char **) (target + Player_inventory_property_offset); + bool is_creative = *(bool *) (inventory + FillingContainer_is_creative_property_offset); + if (is_creative) { + target = NULL; + } + } + + // Return + return target; +} + // Init static void nop() { } @@ -506,6 +531,32 @@ void init_misc() { overwrite_calls((void *) RandomLevelSource_buildSurface, (void *) RandomLevelSource_buildSurface_injection); } + // Disable Block Tinting + if (feature_has("Disable Block Tinting", server_disabled)) { + patch_address((void *) GrassTile_getColor_vtable_addr, (void *) Tile_getColor_injection); + patch_address((void *) TallGrass_getColor_vtable_addr, (void *) Tile_getColor_injection); + patch_address((void *) StemTile_getColor_vtable_addr, (void *) Tile_getColor_injection); + patch_address((void *) LeafTile_getColor_vtable_addr, (void *) Tile_getColor_injection); + overwrite((void *) LiquidTile_getColor, (void *) Tile_getColor_injection); + } + + // Custom GUI Scale + const char *gui_scale_str = getenv("MCPI_GUI_SCALE"); + if (gui_scale_str != NULL) { + unsigned char nop_patch[4] = {0x00, 0xf0, 0x20, 0xe3}; // "nop" + patch((void *) 0x173e8, nop_patch); + patch((void *) 0x173f0, nop_patch); + float gui_scale = strtof(gui_scale_str, NULL); + uint32_t gui_scale_raw; + memcpy(&gui_scale_raw, &gui_scale, sizeof (gui_scale_raw)); + patch_address((void *) 0x17520, (void *) gui_scale_raw); + } + + // Disable Hostile AI In Creative Mode + if (feature_has("Disable Hostile AI In Creative Mode", server_enabled)) { + overwrite_call((void *) 0x83b8c, (void *) PathfinderMob_findAttackTarget_injection); + } + // Init C++ And Logging _init_misc_cpp(); _init_misc_logging(); diff --git a/mods/src/version/version.cpp b/mods/src/version/version.cpp index b492c8d..f32318a 100644 --- a/mods/src/version/version.cpp +++ b/mods/src/version/version.cpp @@ -9,7 +9,7 @@ char *version_get() { static char *version = NULL; // Load if (version == NULL) { - safe_asprintf(&version, "%s / Reborn v" MCPI_VERSION, *minecraft_pi_version); + safe_asprintf(&version, "%s / Reborn v%s", *minecraft_pi_version, reborn_get_version()); } // Return return version; diff --git a/symbols/include/symbols/minecraft.h b/symbols/include/symbols/minecraft.h index b611ed5..8d5da8e 100644 --- a/symbols/include/symbols/minecraft.h +++ b/symbols/include/symbols/minecraft.h @@ -144,6 +144,18 @@ static void *GrassTile_getColor_vtable_addr = (void *) 0x111660; static Tile_getColor_t TallGrass_getColor = (Tile_getColor_t) 0xc25fc; static void *TallGrass_getColor_vtable_addr = (void *) 0x1121f0; +// StemTile + +static void *StemTile_getColor_vtable_addr = (void *) 0x111088; + +// LeafTile + +static void *LeafTile_getColor_vtable_addr = (void *) 0x112980; + +// LiquidTile + +static Tile_getColor_t LiquidTile_getColor = (Tile_getColor_t) 0xc8774; + // TileRenderer typedef void (*TileRenderer_tesselateBlockInWorld_t)(unsigned char *tile_renderer, unsigned char *tile, int32_t x, int32_t y, int32_t z); @@ -432,6 +444,11 @@ static uint32_t Mob_die_vtable_offset = 0x130; static uint32_t Mob_health_property_offset = 0xec; // int32_t +// PathfinderMob + +typedef unsigned char *(*PathfinderMob_findAttackTarget_t)(unsigned char *mob); +static uint32_t PathfinderMob_findAttackTarget_vtable_offset = 0x204; + // Player typedef int (*Player_isUsingItem_t)(unsigned char *player); @@ -690,6 +707,7 @@ static FillingContainer_compressLinkedSlotList_t FillingContainer_compressLinked static uint32_t FillingContainer_linked_slots_property_offset = 0xc; // int32_t[] static uint32_t FillingContainer_linked_slots_length_property_offset = 0x14; // int32_t +static uint32_t FillingContainer_is_creative_property_offset = 0x24; // bool // RakNet::RakString