From bc442034e2a588e334b64956560bbebf794448e6 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Sat, 21 Nov 2020 00:13:09 -0500 Subject: [PATCH] Add 3D Anaglyph + More Function Controls --- debian/client/common/usr/bin/minecraft-pi | 3 ++- mods/src/compat.c | 12 ++++++++++ mods/src/extra.c | 28 +++++++++++++++++++++++ mods/src/extra.h | 2 ++ 4 files changed, 44 insertions(+), 1 deletion(-) diff --git a/debian/client/common/usr/bin/minecraft-pi b/debian/client/common/usr/bin/minecraft-pi index 497eb2a..de5a47c 100755 --- a/debian/client/common/usr/bin/minecraft-pi +++ b/debian/client/common/usr/bin/minecraft-pi @@ -18,7 +18,8 @@ if [ -z "${MCPI_SUBSHELL}" ]; then FALSE 'Peaceful Mode' \ TRUE 'Animated Water' \ TRUE 'Remove Invalid Item Background' \ - TRUE 'Smooth Lighting')" + TRUE 'Smooth Lighting' \ + FALSE '3D Anaglyph')" MCPI_USERNAME="$(zenity --class 'Minecraft - Pi edition' --entry --text 'Minecraft Username:' --entry-text 'StevePi')" fi export MCPI_FEATURES diff --git a/mods/src/compat.c b/mods/src/compat.c index 78f4508..8a0d49c 100644 --- a/mods/src/compat.c +++ b/mods/src/compat.c @@ -104,6 +104,12 @@ static SDLKey glfw_key_to_sdl_key(int key) { // Screenshot case GLFW_KEY_F2: return SDLK_F2; + // Hide GUI + case GLFW_KEY_F1: + return SDLK_F1; + // Third Person + case GLFW_KEY_F5: + return SDLK_F5; // Unknown default: return SDLK_UNKNOWN; @@ -339,6 +345,12 @@ HOOK(SDL_PollEvent, int, (SDL_Event *event)) { } else if (event->key.keysym.sym == SDLK_F2) { screenshot(); handled = 1; + } else if (event->key.keysym.sym == SDLK_F1) { + extra_hide_gui(); + handled = 1; + } else if (event->key.keysym.sym == SDLK_F5) { + extra_third_person(); + handled = 1; } } diff --git a/mods/src/extra.c b/mods/src/extra.c index 4c5d42b..2df9826 100644 --- a/mods/src/extra.c +++ b/mods/src/extra.c @@ -29,6 +29,16 @@ static Player_isUsingItem_t Player_isUsingItem = (Player_isUsingItem_t) 0x8f15c; // Enable Bow & Arrow Fix static int fix_bow = 0; +// Store Function Input +static int hide_gui_toggle = 0; +void extra_hide_gui() { + hide_gui_toggle++; +} +static int third_person_toggle = 0; +void extra_third_person() { + third_person_toggle++; +} + // Handle Input Fixes static void Minecraft_tickInput_injection(unsigned char *minecraft) { // Call Original Method @@ -48,6 +58,19 @@ static void Minecraft_tickInput_injection(unsigned char *minecraft) { // Clear Unused Sign Input extra_clear_input(); + + // Handle Functions + unsigned char *options = minecraft + 0x3c; + if (hide_gui_toggle % 2 != 0) { + // Toggle Hide GUI + *(options + 0xec) = *(options + 0xec) ^ 1; + } + hide_gui_toggle = 0; + if (third_person_toggle % 2 != 0) { + // Toggle Third Person + *(options + 0xed) = *(options + 0xed) ^ 1; + } + third_person_toggle = 0; } typedef void (*Gui_tickItemDrop_t)(unsigned char *); @@ -125,6 +148,7 @@ static Minecraft_init_t Minecraft_init = (Minecraft_init_t) 0x1700c; static int fancy_graphics; static int peaceful_mode; +static int anaglyph; // Configure Options static void Minecraft_init_injection(unsigned char *this) { // Call Original Method @@ -137,6 +161,8 @@ static void Minecraft_init_injection(unsigned char *this) { *(options + 0x105) = 1; // Peaceful Mode *(int32_t *) (options + 0xe8) = peaceful_mode ? 0 : 2; + // 3D Anaglyph + *(options + 0x15) = anaglyph; } // Is Dedicated Server @@ -263,6 +289,8 @@ __attribute__((constructor)) static void init() { fancy_graphics = extra_has_feature("Fancy Graphics"); // Peaceful Mode peaceful_mode = extra_has_feature("Peaceful Mode"); + // 3D Anaglyph + anaglyph = extra_has_feature("3D Anaglyph"); // Set Options overwrite_calls((void *) Minecraft_init, Minecraft_init_injection); diff --git a/mods/src/extra.h b/mods/src/extra.h index 2bb45d4..4cd38c9 100644 --- a/mods/src/extra.h +++ b/mods/src/extra.h @@ -13,6 +13,8 @@ void extra_key_press(char key); void extra_clear_input(); void extra_set_is_right_click(int val); +void extra_hide_gui(); +void extra_third_person(); int extra_get_smooth_lighting();