From 71946d2087b0fe1ccae13788e6898588a1677d9c Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Wed, 18 Dec 2024 02:20:07 -0500 Subject: [PATCH] Some Fixes --- docs/CHANGELOG.md | 2 + .../util/env/flags/available-feature-flags | 9 +++-- mods/src/misc/misc.cpp | 39 +++++++++++++++++++ symbols/CMakeLists.txt | 1 + symbols/src/gui/screens/TextEditScreen.def | 3 +- symbols/src/tile/ChestTile.def | 3 ++ symbols/src/tile/entity/SignTileEntity.def | 2 + 7 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 symbols/src/tile/ChestTile.def diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 818ec23b40..aeb41d42fe 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -55,6 +55,8 @@ * `Fix Reloading Textures On Resize` (Enabled By Default) * `Improved UI Scaling` (Enabled By Default) * `Text Rendering Fixes` (Enabled By Default) + * `Close Editor When Sign Is Destroyed` (Enabled By Default) + * `Remove Chest Placement Restrictions` (Enabled By Default) * Existing Functionality (All Enabled By Default) * `Fix Screen Rendering When Hiding HUD` * `Sanitize Usernames` diff --git a/libreborn/src/util/env/flags/available-feature-flags b/libreborn/src/util/env/flags/available-feature-flags index 4e98931ae6..3e349c36a3 100644 --- a/libreborn/src/util/env/flags/available-feature-flags +++ b/libreborn/src/util/env/flags/available-feature-flags @@ -22,7 +22,6 @@ CATEGORY User Interface TRUE Add Reborn Info To Options TRUE Force Touch UI Inventory TRUE Fix Pause Menu - TRUE Close Current Screen On Death TRUE Implement Create World Dialog TRUE Display Date In Select World Screen TRUE Add Welcome Screen @@ -130,7 +129,10 @@ CATEGORY Bug Fixes TRUE Fix Fire Immunity TRUE Fix Sunlight Not Properly Setting Mobs On Fire TRUE Fix Transferring Durability When Using Items - TRUE Fix Crash When Generating Certain Seeds + CATEGORY Crashes + TRUE Fix Crash When Generating Certain Seeds + TRUE Close Editor When Sign Is Destroyed + TRUE Close Current Screen On Death TRUE Fix Reloading Textures On Resize TRUE Fix options.txt Loading/Saving CATEGORY Logging @@ -143,4 +145,5 @@ CATEGORY Miscellaneous TRUE Always Save Chest Tile Entities TRUE Screenshot Support TRUE Add Camera Functionality - TRUE Update Default Options \ No newline at end of file + TRUE Update Default Options + TRUE Remove Chest Placement Restrictions \ No newline at end of file diff --git a/mods/src/misc/misc.cpp b/mods/src/misc/misc.cpp index 5c06903bfd..10859883f4 100644 --- a/mods/src/misc/misc.cpp +++ b/mods/src/misc/misc.cpp @@ -442,6 +442,32 @@ static Item *Item_initItems_Item_handEquipped_injection(Item *self) { return self; } +// Chest Placement +static bool ChestTile_mayPlace_injection(__attribute__((unused)) ChestTile_mayPlace_t original, __attribute__((unused)) ChestTile *self, __attribute__((unused)) Level *level, __attribute__((unused)) int x, __attribute__((unused)) int y, __attribute__((unused)) int z, __attribute__((unused)) uchar face) { + return true; +} + +// Fix Sign Crash +static TextEditScreen *current_sign_screen = nullptr; +static void Minecraft_setScreen_injection(Minecraft_setScreen_t original, Minecraft *self, Screen *screen) { + // Call Original Method + original(self, screen); + // Track + current_sign_screen = nullptr; + if (screen != nullptr && screen->vtable == (Screen_vtable *) TextEditScreen_vtable::base) { + current_sign_screen = (TextEditScreen *) screen; + } +} +static SignTileEntity *SignTileEntity_destructor_injection(SignTileEntity_destructor_complete_t original, SignTileEntity *self) { + // Close Screen + if (current_sign_screen != nullptr && current_sign_screen->sign == self) { + current_sign_screen->sign = nullptr; + current_sign_screen->minecraft->setScreen(nullptr); + } + // Call Original Method + return original(self); +} + // Init void init_misc() { // Sanitize Username @@ -597,6 +623,19 @@ void init_misc() { overwrite_call((void *) 0x976f8, Item_handEquipped, Item_initItems_Item_handEquipped_injection); } + // Chest Placement + if (feature_has("Remove Chest Placement Restrictions", server_enabled)) { + overwrite_calls(ChestTile_mayPlace, ChestTile_mayPlace_injection); + unsigned char skip_neighbor_check_patch[4] = {0x01, 0x30, 0xa0, 0xe3}; // "mov r3, #0x1" + patch((void *) 0xcfaf8, skip_neighbor_check_patch); + } + + // Fix TextEditScreen Crashing After Sign Is Destroyed + if (feature_has("Close Editor When Sign Is Destroyed", server_disabled)) { + overwrite_calls(Minecraft_setScreen, Minecraft_setScreen_injection); + overwrite_calls(SignTileEntity_destructor_complete, SignTileEntity_destructor_injection); + } + // Disable overwrite_calls() After Minecraft::init misc_run_on_init([](__attribute__((unused)) Minecraft *minecraft) { thunk_enabler = [](__attribute__((unused)) void *a, __attribute__((unused)) void *b) -> void * { diff --git a/symbols/CMakeLists.txt b/symbols/CMakeLists.txt index 51a2a9ea58..5836429c1c 100644 --- a/symbols/CMakeLists.txt +++ b/symbols/CMakeLists.txt @@ -165,6 +165,7 @@ set(SRC src/tile/EntityTile.def src/tile/Bush.def src/tile/CropTile.def + src/tile/ChestTile.def src/misc/Strings.def src/misc/I18n.def src/misc/SimpleFoodData.def diff --git a/symbols/src/gui/screens/TextEditScreen.def b/symbols/src/gui/screens/TextEditScreen.def index b27e6ba7ba..2ecf806a4f 100644 --- a/symbols/src/gui/screens/TextEditScreen.def +++ b/symbols/src/gui/screens/TextEditScreen.def @@ -1,7 +1,8 @@ extends Screen; size 0xac; - vtable 0x105308; constructor (SignTileEntity *sign) = 0x3a840; + +property SignTileEntity *sign = 0x4c; \ No newline at end of file diff --git a/symbols/src/tile/ChestTile.def b/symbols/src/tile/ChestTile.def new file mode 100644 index 0000000000..98bcc3c70d --- /dev/null +++ b/symbols/src/tile/ChestTile.def @@ -0,0 +1,3 @@ +extends EntityTile; + +vtable 0x110ea8; \ No newline at end of file diff --git a/symbols/src/tile/entity/SignTileEntity.def b/symbols/src/tile/entity/SignTileEntity.def index f25f52d7ec..069f50eec4 100644 --- a/symbols/src/tile/entity/SignTileEntity.def +++ b/symbols/src/tile/entity/SignTileEntity.def @@ -1 +1,3 @@ +vtable 0x115d08; + extends TileEntity;