From ecbcfb292292a38398f34be8f86ee7c8be558a6b Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Wed, 7 Feb 2024 19:00:55 -0500 Subject: [PATCH] Split Up Animated Textures Into Three Flags --- docs/CHANGELOG.md | 3 ++- launcher/src/client/available-feature-flags | 4 ++- mods/include/mods/bucket/bucket.h | 10 ++++++++ mods/src/bucket/bucket.cpp | 1 + mods/src/textures/lava.cpp | 28 ++++++++++++++++----- mods/src/textures/textures-internal.h | 2 +- mods/src/textures/textures.cpp | 14 +++++++++-- 7 files changed, 51 insertions(+), 11 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index c72a4bbdb..780e7021e 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -6,7 +6,8 @@ * Add Peaceful Mode To Options Screen * Proper Create New World Screen * Proper Chat Screen -* The `Animated Water` Feature Flag Is Now `Animated Water & Lava` +* Add `Animated Lava` Feature Flag (Enabled By Default) +* Add `Animated Fire` Feature Flag (Enabled By Default) * Add `Use Java Beta 1.3 Light Ramp` Feature Flag (Enabled By Default) * Add `Send Full Level When Hosting Game` Feature Flag (Enabled By Default) * Add `Food Overlay` Feature Flag (Disabled By Default) diff --git a/launcher/src/client/available-feature-flags b/launcher/src/client/available-feature-flags index b49f12ddc..2417c4624 100644 --- a/launcher/src/client/available-feature-flags +++ b/launcher/src/client/available-feature-flags @@ -8,7 +8,9 @@ TRUE Fix Sign Placement TRUE Show Block Outlines FALSE Expand Creative Mode Inventory FALSE Remove Creative Mode Restrictions -TRUE Animated Water & Lava +TRUE Animated Water +TRUE Animated Lava +TRUE Animated Fire TRUE Remove Invalid Item Background TRUE Disable "gui_blocks" Atlas TRUE Fix Camera Rendering diff --git a/mods/include/mods/bucket/bucket.h b/mods/include/mods/bucket/bucket.h index 2547d6386..54f34e1f7 100644 --- a/mods/include/mods/bucket/bucket.h +++ b/mods/include/mods/bucket/bucket.h @@ -1,3 +1,13 @@ #pragma once +#include + +#ifdef __cplusplus +extern "C" { +#endif + extern bool buckets_enabled; + +#ifdef __cplusplus +} +#endif diff --git a/mods/src/bucket/bucket.cpp b/mods/src/bucket/bucket.cpp index 22af894c7..b2fa7668f 100644 --- a/mods/src/bucket/bucket.cpp +++ b/mods/src/bucket/bucket.cpp @@ -4,6 +4,7 @@ #include #include #include +#include // Items static FoodItem *bucket = NULL; diff --git a/mods/src/textures/lava.cpp b/mods/src/textures/lava.cpp index edc416d8e..5a048a2e5 100644 --- a/mods/src/textures/lava.cpp +++ b/mods/src/textures/lava.cpp @@ -223,23 +223,39 @@ static DynamicTexture *create_fire_texture(int a2) { texture->m_random.param_1 = 0x271; texture->m_random.param_2 = false; texture->m_random.param_3 = 0; + for (int i = 0; i < 320; i++) { + texture->m_data1[i] = 0.0f; + texture->m_data2[i] = 0.0f; + } // Return return (DynamicTexture *) texture; } // Add Textures +static bool animated_water = false; +static bool animated_lava = false; +static bool animated_fire = false; static void Textures_addDynamicTexture_injection(Textures *textures, DynamicTexture *dynamic_texture) { // Call Original Method - Textures_addDynamicTexture(textures, dynamic_texture); + if (animated_water) { + Textures_addDynamicTexture(textures, dynamic_texture); + } // Add Lava - Textures_addDynamicTexture(textures, create_lava_texture()); - Textures_addDynamicTexture(textures, create_lava_side_texture()); - Textures_addDynamicTexture(textures, create_fire_texture(0)); - Textures_addDynamicTexture(textures, create_fire_texture(1)); + if (animated_lava) { + Textures_addDynamicTexture(textures, create_lava_texture()); + Textures_addDynamicTexture(textures, create_lava_side_texture()); + } + if (animated_fire) { + Textures_addDynamicTexture(textures, create_fire_texture(0)); + Textures_addDynamicTexture(textures, create_fire_texture(1)); + } } // Init -void _init_textures_lava() { +void _init_textures_lava(bool animated_water_param, bool animated_lava_param, bool animated_fire_param) { + animated_water = animated_water_param; + animated_lava = animated_lava_param; + animated_fire = animated_fire_param; overwrite_call((void *) 0x170b4, (void *) Textures_addDynamicTexture_injection); } diff --git a/mods/src/textures/textures-internal.h b/mods/src/textures/textures-internal.h index d19560404..7b4ed7cfb 100644 --- a/mods/src/textures/textures-internal.h +++ b/mods/src/textures/textures-internal.h @@ -1,3 +1,3 @@ #pragma once -__attribute__((visibility("internal"))) void _init_textures_lava(); +__attribute__((visibility("internal"))) void _init_textures_lava(bool animated_water, bool animated_lava, bool animated_fire); diff --git a/mods/src/textures/textures.cpp b/mods/src/textures/textures.cpp index 297fcd63e..6d6d3ceb0 100644 --- a/mods/src/textures/textures.cpp +++ b/mods/src/textures/textures.cpp @@ -214,10 +214,20 @@ static Texture AppPlatform_linux_loadTexture_injection(__attribute__((unused)) A // Init void init_textures() { // Tick Dynamic Textures (Animated Water) - if (feature_has("Animated Water & Lava", server_disabled)) { + bool animated_water = feature_has("Animated Water", server_disabled); + bool animated_lava = feature_has("Animated Lava", server_disabled); + bool animated_fire = feature_has("Animated Fire", server_disabled); + if (animated_water || animated_lava || animated_fire) { + // Tick Dynamic Textures misc_run_on_tick(Minecraft_tick_injection); + // Disable Animated Water If Set + if (!animated_water) { + unsigned char disable_water_patch[4] = {0x00, 0xf0, 0x20, 0xe3}; // "nop" + patch((void *) 0x17094, disable_water_patch); + patch((void *) 0x170b4, disable_water_patch); + } // Animated Lava - _init_textures_lava(); + _init_textures_lava(animated_water, animated_lava, animated_fire); } // Scale Animated Textures