From 6d4ff44092ffa8b7def92105e21891f1cf67b2c5 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Wed, 31 Jan 2024 23:44:04 -0500 Subject: [PATCH] Java Light Ramp (Also From ReMCPE) --- launcher/src/client/available-feature-flags | 1 + mods/src/misc/misc.c | 17 +++++++++++++++++ symbols/CMakeLists.txt | 2 ++ symbols/src/level/Dimension.def | 5 +++++ symbols/src/level/Level.def | 2 +- symbols/src/level/MultiPlayerLevel.def | 3 +++ symbols/src/level/ServerLevel.def | 2 +- 7 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 symbols/src/level/Dimension.def create mode 100644 symbols/src/level/MultiPlayerLevel.def diff --git a/launcher/src/client/available-feature-flags b/launcher/src/client/available-feature-flags index feba5ff8..838422a5 100644 --- a/launcher/src/client/available-feature-flags +++ b/launcher/src/client/available-feature-flags @@ -51,3 +51,4 @@ TRUE Disable Hostile AI In Creative Mode TRUE Load Custom Skins TRUE 3D Chest Model TRUE Replace Block Highlight With Outline +TRUE Use Java Beta 1.3 Light Ramp diff --git a/mods/src/misc/misc.c b/mods/src/misc/misc.c index 0063997e..4b37ead2 100644 --- a/mods/src/misc/misc.c +++ b/mods/src/misc/misc.c @@ -545,6 +545,18 @@ static int FurnaceTileEntity_getLitProgress_injection(FurnaceTileEntity *furnace return ret; } +// Java Light Ramp +static void Dimension_updateLightRamp_injection(Dimension *self) { + // https://github.com/ReMinecraftPE/mcpe/blob/d7a8b6baecf8b3b050538abdbc976f690312aa2d/source/world/level/Dimension.cpp#L92-L105 + for (int i = 0; i <= 15; i++) { + float f1 = 1.0f - (((float) i) / 15.0f); + self->light_ramp[i] = ((1.0f - f1) / (f1 * 3.0f + 1.0f)) * (1.0f - 0.1f) + 0.1f; + // Default Light Ramp: + // float fVar4 = 1.0 - ((float) i * 0.0625); + // self->light_ramp[i] = ((1.0 - fVar4) / (fVar4 * 3.0 + 1.0)) * 0.95 + 0.15; + } +} + // Init static void nop() { } @@ -731,6 +743,11 @@ void init_misc() { unsigned char mov_r3_ff[4] = {0xff, 0x30, 0xa0, 0xe3}; // "mov r3, #0xff" patch((void *) 0x7178c, mov_r3_ff); + // Java Light Ramp + if (feature_has("Use Java Beta 1.3 Light Ramp", server_disabled)) { + overwrite((void *) Dimension_updateLightRamp_non_virtual, (void *) Dimension_updateLightRamp_injection); + } + // Init C++ And Logging _init_misc_cpp(); _init_misc_logging(); diff --git a/symbols/CMakeLists.txt b/symbols/CMakeLists.txt index 005dec37..d24b5aef 100644 --- a/symbols/CMakeLists.txt +++ b/symbols/CMakeLists.txt @@ -74,6 +74,8 @@ set(SRC src/level/LevelData.def src/level/LevelSettings.def src/level/ServerLevel.def + src/level/Dimension.def + src/level/MultiPlayerLevel.def src/item/ItemRenderer.def src/item/ItemInHandRenderer.def src/item/AuxDataTileItem.def diff --git a/symbols/src/level/Dimension.def b/symbols/src/level/Dimension.def new file mode 100644 index 00000000..ee73739c --- /dev/null +++ b/symbols/src/level/Dimension.def @@ -0,0 +1,5 @@ +vtable 0x110370; + +virtual-method void updateLightRamp() = 0x28; + +property float light_ramp[16] = 0x10; diff --git a/symbols/src/level/Level.def b/symbols/src/level/Level.def index 0411c97b..15220bc8 100644 --- a/symbols/src/level/Level.def +++ b/symbols/src/level/Level.def @@ -1,6 +1,6 @@ extends LevelSource; -vtable 0x108de0; +vtable 0x10fcf0; method void saveLevelData() = 0xa2e94; method void setTileAndData(int x, int y, int z, int id, int data) = 0xa38b4; diff --git a/symbols/src/level/MultiPlayerLevel.def b/symbols/src/level/MultiPlayerLevel.def new file mode 100644 index 00000000..0b204a8e --- /dev/null +++ b/symbols/src/level/MultiPlayerLevel.def @@ -0,0 +1,3 @@ +extends Level; + +vtable 0x108de0; diff --git a/symbols/src/level/ServerLevel.def b/symbols/src/level/ServerLevel.def index c2c36e3d..5416505a 100644 --- a/symbols/src/level/ServerLevel.def +++ b/symbols/src/level/ServerLevel.def @@ -2,4 +2,4 @@ extends Level; size 0xb80; -constructor (uchar *storage, uchar *name, LevelSettings *settings, int param_4, uchar *dimension) = 0x7692c; +constructor (uchar *storage, uchar *name, LevelSettings *settings, int param_4, Dimension *dimension) = 0x7692c;