From a15447b2323083836095409ce8ffa3510e94b22b Mon Sep 17 00:00:00 2001 From: Bigjango13 Date: Sun, 30 Jun 2024 01:58:30 +0000 Subject: [PATCH] Hide crosshair in third person --- mods/src/input/toggle.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/mods/src/input/toggle.cpp b/mods/src/input/toggle.cpp index 1b88ed40..d3bcd229 100644 --- a/mods/src/input/toggle.cpp +++ b/mods/src/input/toggle.cpp @@ -47,7 +47,8 @@ static void revert_rotation(Entity *entity) { entity->old_pitch = -entity->old_pitch; } } -static int is_front_facing = 0; +static bool is_front_facing = false; +static bool is_third_person = false; static LocalPlayer *stored_player = nullptr; static void GameRenderer_setupCamera_injection(GameRenderer_setupCamera_t original, GameRenderer *game_renderer, float param_1, int param_2) { // Get Objects @@ -57,6 +58,7 @@ static void GameRenderer_setupCamera_injection(GameRenderer_setupCamera_t origin // Check If In Third-Person Options *options = &minecraft->options; is_front_facing = (options->third_person == 2); + is_third_person = options->third_person != 0; // Invert Rotation if (is_front_facing) { @@ -86,6 +88,13 @@ static void ParticleEngine_render_injection(ParticleEngine_render_t original, Pa } } +// Hide crosshairs in 3rd person mode +static void Gui_renderProgressIndicator_GuiComponent_blit_injection(GuiComponent *self, int x1, int y1, int x2, int y2, int w1, int h1, int w2, int h2) { + if (!is_third_person) { + GuiComponent_blit(self, x1, y1, x2, y2, w1, h1, w2, h2); + } +} + // Init void _init_toggle() { if (feature_has("Bind Common Toggleable Options To Function Keys", server_disabled)) { @@ -96,4 +105,7 @@ void _init_toggle() { overwrite_calls(GameRenderer_setupCamera, GameRenderer_setupCamera_injection); overwrite_calls(ParticleEngine_render, ParticleEngine_render_injection); } + + // Hide crosshair in 3rd person + overwrite_call((void *) 0x261b8, (void *) Gui_renderProgressIndicator_GuiComponent_blit_injection); }