From 0465dc75a733447d07f5d6fbd76a50d8815151b7 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Thu, 16 Sep 2021 16:39:24 -0400 Subject: [PATCH] Instead Of Crashing, Disable Polling Block Hits In Survival Mode Using The API --- VERSION | 2 +- docs/CHANGELOG.md | 3 +++ mods/src/game-mode/game-mode.c | 14 ++++++++++++++ scripts/build-all.sh | 2 +- scripts/build.sh | 11 ++++++++++- symbols/include/symbols/minecraft.h | 3 +++ 6 files changed, 32 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index 585940699..530cdd91a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.2.3 +2.2.4 diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index cdad6f1d7..86bafaee8 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +**2.2.4** +* Instead Of Crashing, Disable Polling Block Hits In Survival Mode Using The API + **2.2.3** * Fix Crash When Taking Odd-Sized Screenshots diff --git a/mods/src/game-mode/game-mode.c b/mods/src/game-mode/game-mode.c index 9d0b3cec4..11f84f57f 100644 --- a/mods/src/game-mode/game-mode.c +++ b/mods/src/game-mode/game-mode.c @@ -35,6 +35,17 @@ static void Minecraft_setIsCreativeMode_injection(unsigned char *this, int32_t n (*Minecraft_setIsCreativeMode)(this, new_game_mode); } +// Disable CreatorMode-Specific API Features (Polling Block Hits) In SurvivalMode, This Is Preferable To Crashing +static unsigned char *Minecraft_getCreator_injection(unsigned char *minecraft) { + if (is_survival) { + // SurvivalMode, Return NULL + return NULL; + } else { + // CreatorMode, Call Original Method + return (*Minecraft_getCreator)(minecraft); + } +} + // Init void init_game_mode() { // Dynamic Game Mode Switching @@ -49,6 +60,9 @@ void init_game_mode() { uint32_t level_size = SERVER_LEVEL_SIZE; patch_address((void *) 0x17004, (void *) level_size); + // Disable CreatorMode-Specific API Features (Polling Block Hits) In SurvivalMode, This Is Preferable To Crashing + overwrite_calls((void *) Minecraft_getCreator, (void *) Minecraft_getCreator_injection); + // Init C++ _init_game_mode_cpp(); } diff --git a/scripts/build-all.sh b/scripts/build-all.sh index 4ecd3cf75..f1223d1df 100755 --- a/scripts/build-all.sh +++ b/scripts/build-all.sh @@ -8,7 +8,7 @@ rm -rf out # Build ./scripts/build.sh native client ./scripts/build.sh native server -./scripts/build.sh arm64_build client +./scripts/build.sh arm64 client ./scripts/build.sh arm64 server ./scripts/build.sh arm client ./scripts/build.sh arm server diff --git a/scripts/build.sh b/scripts/build.sh index ba4f9de95..e92b65708 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -4,7 +4,7 @@ set -e # This Script Assumes An x86_64 Host if [ "$(uname -m)" != "x86_64" ]; then - echo 'Invalid Build Architecture' + echo 'Invalid Host Architecture' > /dev/stderr exit 1 fi @@ -111,6 +111,12 @@ arm_build() { cd ../../ } +# Verify Mode +if [ "$2" != "client" ] && [ "$2" != "server" ]; then + echo "Invalid Mode: $2" > /dev/stderr + exit 1 +fi + # Build if [ "$1" = "native" ]; then native_build "$2" @@ -118,4 +124,7 @@ elif [ "$1" = "arm64" ]; then arm64_build "$2" elif [ "$1" = "arm" ]; then arm_build "$2" +else + echo "Invalid Architecture: $1" > /dev/stderr + exit 1 fi diff --git a/symbols/include/symbols/minecraft.h b/symbols/include/symbols/minecraft.h index 8ce53c874..2c897298b 100644 --- a/symbols/include/symbols/minecraft.h +++ b/symbols/include/symbols/minecraft.h @@ -114,6 +114,9 @@ static Minecraft_leaveGame_t Minecraft_leaveGame = (Minecraft_leaveGame_t) 0x15e typedef int (*Minecraft_handleBack_t)(unsigned char *minecraft, bool do_nothing); static uint32_t Minecraft_handleBack_vtable_offset = 0x34; +typedef unsigned char *(*Minecraft_getCreator_t)(unsigned char *minecraft); +static Minecraft_getCreator_t Minecraft_getCreator = (Minecraft_getCreator_t) 0x17538; + static uint32_t Minecraft_screen_width_property_offset = 0x20; // int32_t static uint32_t Minecraft_network_handler_property_offset = 0x174; // NetEventCallback * static uint32_t Minecraft_rak_net_instance_property_offset = 0x170; // RakNetInstance *