From 6378a18494e0223878bb182ef4f5ab7fa381b433 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Wed, 21 Sep 2022 18:40:09 -0400 Subject: [PATCH] Add 3D Anaglyph To In-Game Options --- launcher/src/client/available-feature-flags | 1 - mods/src/options/options.c | 5 ---- mods/src/options/options.cpp | 31 ++++++++++++++++----- symbols/include/symbols/minecraft.h | 2 ++ 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/launcher/src/client/available-feature-flags b/launcher/src/client/available-feature-flags index 4bc5500e5..19f8e03e2 100644 --- a/launcher/src/client/available-feature-flags +++ b/launcher/src/client/available-feature-flags @@ -11,7 +11,6 @@ FALSE Remove Creative Mode Restrictions TRUE Animated Water TRUE Remove Invalid Item Background TRUE Disable "gui_blocks" Atlas -FALSE 3D Anaglyph TRUE Fix Camera Rendering TRUE Implement Chat FALSE Hide Chat Messages diff --git a/mods/src/options/options.c b/mods/src/options/options.c index e5b068c16..44218c104 100644 --- a/mods/src/options/options.c +++ b/mods/src/options/options.c @@ -44,7 +44,6 @@ __attribute__((destructor)) static void _free_safe_username() { free(safe_username); } -static int anaglyph; static int render_distance; // Configure Options unsigned char *stored_options = NULL; @@ -68,8 +67,6 @@ static void Minecraft_init_injection(unsigned char *minecraft) { unsigned char *options = minecraft + Minecraft_options_property_offset; // Enable Crosshair In Touch GUI *(options + Options_split_controls_property_offset) = 1; - // 3D Anaglyph - *(options + Options_3d_anaglyph_property_offset) = anaglyph; // Render Distance *(int32_t *) (options + Options_render_distance_property_offset) = render_distance; } @@ -90,8 +87,6 @@ void init_options() { overwrite((void *) LevelData_getSpawnMobs, (void *) LevelData_getSpawnMobs_injection); } - // 3D Anaglyph - anaglyph = feature_has("3D Anaglyph", server_disabled); // Render Distance render_distance = get_render_distance(); DEBUG("Setting Render Distance: %i", render_distance); diff --git a/mods/src/options/options.cpp b/mods/src/options/options.cpp index f11831c9d..13ebea796 100644 --- a/mods/src/options/options.cpp +++ b/mods/src/options/options.cpp @@ -33,6 +33,9 @@ static void Options_save_Options_addOptionToSaveOutput_injection(unsigned char * // Save Fancy Graphics (*Options_addOptionToSaveOutput)(options, data, "gfx_fancygraphics", *(options + Options_fancy_graphics_property_offset)); + // Save 3D Anaglyph + (*Options_addOptionToSaveOutput)(options, data, "gfx_anaglyph", *(options + Options_3d_anaglyph_property_offset)); + // Save File unsigned char *options_file = options + Options_options_file_property_offset; (*OptionsFile_save)(options_file, data); @@ -117,6 +120,11 @@ static void OptionsPane_unknown_toggle_creating_function_injection(unsigned char // Call Original Method (*OptionsPane_unknown_toggle_creating_function)(options_pane, group_id, new_name, option); + + // Add 3D Anaglyph + if (option == Options_Option_GRAPHICS) { + (*OptionsPane_unknown_toggle_creating_function)(options_pane, group_id, "3D Anaglyph", Options_Option_ANAGLYPH); + } } // Add Missing Options To Options::getBooleanValue @@ -213,18 +221,27 @@ void _init_options_cpp() { // Replace "feedback_vibration" Loading/Saving With "gfx_ao" { // Replace String - static const char *new_feedback_vibration_options_txt_nam = "gfx_ao"; - patch_address((void *) feedback_vibration_options_txt_name_1, (void *) &new_feedback_vibration_options_txt_nam); - patch_address((void *) feedback_vibration_options_txt_name_2, (void *) &new_feedback_vibration_options_txt_nam); + static const char *new_feedback_vibration_options_txt_name = "gfx_ao"; + patch_address((void *) feedback_vibration_options_txt_name_1, (void *) &new_feedback_vibration_options_txt_name); + patch_address((void *) feedback_vibration_options_txt_name_2, (void *) &new_feedback_vibration_options_txt_name); // Loading - unsigned char gfx_ao_loading_patch[4] = {(unsigned char) Options_ambient_occlusion_property_offset, 0x10, 0x84, 0xe2}; // "add param_2, r4, #OFFSET" + unsigned char gfx_ao_loading_patch[4] = {(unsigned char) Options_ambient_occlusion_property_offset, 0x10, 0x84, 0xe2}; // "add r1, r4, #OFFSET" patch((void *) 0x193b8, gfx_ao_loading_patch); // Saving unsigned char gfx_ao_saving_patch[4] = {(unsigned char) Options_ambient_occlusion_property_offset, 0x30, 0xd4, 0xe5}; // "ldrb r3, [r4, #OFFSET]" patch((void *) 0x197f8, gfx_ao_saving_patch); } - // Disable "gfx_lowquality" Loading - patch((void *) 0x19414, nop_patch); - patch((void *) 0x1941c, nop_patch); + // Replace "gfx_lowquality" Loading With "gfx_anaglyph" + { + // Replace String + static const char *new_gfx_lowquality_options_txt_name = "gfx_anaglyph"; + patch_address((void *) gfx_lowquality_options_txt_name, (void *) &new_gfx_lowquality_options_txt_name); + // Loading + unsigned char gfx_anaglyph_loading_patch[4] = {(unsigned char) Options_3d_anaglyph_property_offset, 0x10, 0x84, 0xe2}; // "add r1, r4, #OFFSET" + patch((void *) 0x19400, gfx_anaglyph_loading_patch); + // Disable Loading Side Effects + patch((void *) 0x19414, nop_patch); + patch((void *) 0x1941c, nop_patch); + } } diff --git a/symbols/include/symbols/minecraft.h b/symbols/include/symbols/minecraft.h index c3354f508..6877ae2d4 100644 --- a/symbols/include/symbols/minecraft.h +++ b/symbols/include/symbols/minecraft.h @@ -31,6 +31,7 @@ static char **options_txt_path = (char **) 0x19bc8; // options.txt static char **options_txt_fopen_mode_when_loading = (char **) 0x19d24; // w static char ***feedback_vibration_options_txt_name_1 = (char ***) 0x198a0; // feedback_vibration static char ***feedback_vibration_options_txt_name_2 = (char ***) 0x194bc; // feedback_vibration +static char ***gfx_lowquality_options_txt_name = (char ***) 0x194c4; // gfx_lowquality static unsigned char **Material_stone = (unsigned char **) 0x180a9c; // Material @@ -68,6 +69,7 @@ static float *InvGuiScale = (float *) 0x135d98; static unsigned char *Options_Option_GRAPHICS = (unsigned char *) 0x136c2c; // Option static unsigned char *Options_Option_AMBIENT_OCCLUSION = (unsigned char *) 0x136c38; // Option +static unsigned char *Options_Option_ANAGLYPH = (unsigned char *) 0x136c08; // Option static bool *Minecraft_useAmbientOcclusion = (bool *) 0x136b90;