Fix "Sleeping Beauty" Bug

This commit is contained in:
TheBrokenRail 2023-10-19 01:46:09 -04:00
parent db03d964de
commit c908d46d54
2 changed files with 26 additions and 0 deletions

View File

@ -45,6 +45,23 @@ static int32_t OptionsScreen_handleBackEvent_injection(unsigned char *screen, bo
return 1; return 1;
} }
// Fix "Sleeping Beaty" Bug
static int32_t InBedScreen_handleBackEvent_injection(unsigned char *screen, bool do_nothing) {
if (!do_nothing) {
// Close Screen
unsigned char *minecraft = *(unsigned char **) (screen + Screen_minecraft_property_offset);
(*Minecraft_setScreen)(minecraft, NULL);
// Stop Sleeping
unsigned char *player = *(unsigned char **) (minecraft + Minecraft_player_property_offset);
if (player != NULL) {
unsigned char *player_vtable = *(unsigned char **) player;
Player_stopSleepInBed_t Player_stopSleepInBed = *(Player_stopSleepInBed_t *) (player_vtable + Player_stopSleepInBed_vtable_offset);
(*Player_stopSleepInBed)(player, 1, 1, 1);
}
}
return 1;
}
// Set Mouse Grab State // Set Mouse Grab State
static int mouse_grab_state = 0; static int mouse_grab_state = 0;
void input_set_mouse_grab_state(int state) { void input_set_mouse_grab_state(int state) {
@ -90,6 +107,8 @@ void _init_misc() {
if (enable_misc) { if (enable_misc) {
// Fix OptionsScreen Ignoring The Back Button // Fix OptionsScreen Ignoring The Back Button
patch_address(OptionsScreen_handleBackEvent_vtable_addr, (void *) OptionsScreen_handleBackEvent_injection); patch_address(OptionsScreen_handleBackEvent_vtable_addr, (void *) OptionsScreen_handleBackEvent_injection);
// Fix "Sleeping Beauty" Bug
patch_address(InBedScreen_handleBackEvent_vtable_addr, (void *) InBedScreen_handleBackEvent_injection);
// Disable Opening Inventory Using The Cursor When Cursor Is Hidden // Disable Opening Inventory Using The Cursor When Cursor Is Hidden
overwrite_calls((void *) Gui_handleClick, (void *) Gui_handleClick_injection); overwrite_calls((void *) Gui_handleClick, (void *) Gui_handleClick_injection);
} }

View File

@ -460,6 +460,9 @@ static uint32_t Player_drop_vtable_offset = 0x208;
static Mob_getWalkingSpeedModifier_t Player_getWalkingSpeedModifier = (Mob_getWalkingSpeedModifier_t) 0x8ea0c; static Mob_getWalkingSpeedModifier_t Player_getWalkingSpeedModifier = (Mob_getWalkingSpeedModifier_t) 0x8ea0c;
typedef void (*Player_stopSleepInBed_t)(unsigned char *player, bool param_1, bool param_2, bool param_3);
static uint32_t Player_stopSleepInBed_vtable_offset = 0x228;
static uint32_t Player_username_property_offset = 0xbf4; // std::string static uint32_t Player_username_property_offset = 0xbf4; // std::string
static uint32_t Player_inventory_property_offset = 0xbe0; // Inventory * static uint32_t Player_inventory_property_offset = 0xbe0; // Inventory *
@ -590,6 +593,10 @@ static FurnaceScreen_handleAddItem_t FurnaceScreen_handleAddItem = (FurnaceScree
static uint32_t FurnaceScreen_tile_entity_property_offset = 0x1d0; // FurnaceTileEntity * static uint32_t FurnaceScreen_tile_entity_property_offset = 0x1d0; // FurnaceTileEntity *
// InBedScreen
static void *InBedScreen_handleBackEvent_vtable_addr = (void *) 0x104614;
// FurnaceTileEntity // FurnaceTileEntity
typedef ItemInstance *(*FurnaceTileEntity_getItem_t)(unsigned char *furnace_tile_entity, int32_t slot); typedef ItemInstance *(*FurnaceTileEntity_getItem_t)(unsigned char *furnace_tile_entity, int32_t slot);