Instead Of Crashing, Disable Polling Block Hits In Survival Mode Using The API

This commit is contained in:
TheBrokenRail 2021-09-16 16:39:24 -04:00
parent 68a252c3df
commit 0465dc75a7
6 changed files with 32 additions and 3 deletions

View File

@ -1 +1 @@
2.2.3 2.2.4

View File

@ -1,5 +1,8 @@
# Changelog # Changelog
**2.2.4**
* Instead Of Crashing, Disable Polling Block Hits In Survival Mode Using The API
**2.2.3** **2.2.3**
* Fix Crash When Taking Odd-Sized Screenshots * Fix Crash When Taking Odd-Sized Screenshots

View File

@ -35,6 +35,17 @@ static void Minecraft_setIsCreativeMode_injection(unsigned char *this, int32_t n
(*Minecraft_setIsCreativeMode)(this, new_game_mode); (*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 // Init
void init_game_mode() { void init_game_mode() {
// Dynamic Game Mode Switching // Dynamic Game Mode Switching
@ -49,6 +60,9 @@ void init_game_mode() {
uint32_t level_size = SERVER_LEVEL_SIZE; uint32_t level_size = SERVER_LEVEL_SIZE;
patch_address((void *) 0x17004, (void *) 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 C++
_init_game_mode_cpp(); _init_game_mode_cpp();
} }

View File

@ -8,7 +8,7 @@ rm -rf out
# Build # Build
./scripts/build.sh native client ./scripts/build.sh native client
./scripts/build.sh native server ./scripts/build.sh native server
./scripts/build.sh arm64_build client ./scripts/build.sh arm64 client
./scripts/build.sh arm64 server ./scripts/build.sh arm64 server
./scripts/build.sh arm client ./scripts/build.sh arm client
./scripts/build.sh arm server ./scripts/build.sh arm server

View File

@ -4,7 +4,7 @@ set -e
# This Script Assumes An x86_64 Host # This Script Assumes An x86_64 Host
if [ "$(uname -m)" != "x86_64" ]; then if [ "$(uname -m)" != "x86_64" ]; then
echo 'Invalid Build Architecture' echo 'Invalid Host Architecture' > /dev/stderr
exit 1 exit 1
fi fi
@ -111,6 +111,12 @@ arm_build() {
cd ../../ cd ../../
} }
# Verify Mode
if [ "$2" != "client" ] && [ "$2" != "server" ]; then
echo "Invalid Mode: $2" > /dev/stderr
exit 1
fi
# Build # Build
if [ "$1" = "native" ]; then if [ "$1" = "native" ]; then
native_build "$2" native_build "$2"
@ -118,4 +124,7 @@ elif [ "$1" = "arm64" ]; then
arm64_build "$2" arm64_build "$2"
elif [ "$1" = "arm" ]; then elif [ "$1" = "arm" ]; then
arm_build "$2" arm_build "$2"
else
echo "Invalid Architecture: $1" > /dev/stderr
exit 1
fi fi

View File

@ -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); typedef int (*Minecraft_handleBack_t)(unsigned char *minecraft, bool do_nothing);
static uint32_t Minecraft_handleBack_vtable_offset = 0x34; 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_screen_width_property_offset = 0x20; // int32_t
static uint32_t Minecraft_network_handler_property_offset = 0x174; // NetEventCallback * static uint32_t Minecraft_network_handler_property_offset = 0x174; // NetEventCallback *
static uint32_t Minecraft_rak_net_instance_property_offset = 0x170; // RakNetInstance * static uint32_t Minecraft_rak_net_instance_property_offset = 0x170; // RakNetInstance *