Compare commits

...

2 Commits

Author SHA1 Message Date
4a69d38e35 Add "Close Current Screen On Death"
All checks were successful
minecraft-pi-reborn/pipeline/head This commit looks good
2022-01-02 15:26:56 -05:00
5636abc051 Fix More Furnace UI 2022-01-01 19:04:58 -05:00
7 changed files with 90 additions and 34 deletions

View File

@ -1 +1 @@
2.2.10
2.2.11

View File

@ -1,5 +1,9 @@
# Changelog
**2.2.11**
* Add "Close Current Screen On Death" Feature Flag (Enabled By Default) To Prevent Bugs
* Fix More Furnace UI Bugs When Using "Disable 'gui_blocks' Atlas"
**2.2.10**
* Fix Bug With Picking Up Items In "Remove Creative Mode Restrictions" Mode

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View File

@ -28,3 +28,4 @@ TRUE Render Selected Item Text
TRUE External Server Support
TRUE Load Language Files
TRUE Implement Sound Engine
TRUE Close Current Screen On Death

View File

@ -7,7 +7,7 @@
#include "../init/init.h"
// Fix Grass And Leaves Inventory Rendering When The gui_blocks Atlas Is Disabled
static float ItemRenderer_renderGuiItemCorrect_injection(unsigned char *font, unsigned char *textures, ItemInstance *item_instance, int32_t param_1, int32_t param_2) {
static void ItemRenderer_renderGuiItemCorrect_injection(unsigned char *font, unsigned char *textures, ItemInstance *item_instance, int32_t param_1, int32_t param_2) {
int32_t leaves_id = *(int32_t *) (*Tile_leaves + Tile_id_property_offset);
int32_t grass_id = *(int32_t *) (*Tile_grass + Tile_id_property_offset);
// Replace Rendered Item With Carried Variant
@ -28,28 +28,39 @@ static float ItemRenderer_renderGuiItemCorrect_injection(unsigned char *font, un
glDisable(GL_DEPTH_TEST);
// Call Original Method
float ret = (*ItemRenderer_renderGuiItemCorrect)(font, textures, use_carried ? &carried_item_instance : item_instance, param_1, param_2);
(*ItemRenderer_renderGuiItemCorrect)(font, textures, use_carried ? &carried_item_instance : item_instance, param_1, param_2);
// Revert GL State Changes
if (depth_test_was_enabled) {
glEnable(GL_DEPTH_TEST);
}
// Return
return ret;
}
// Fix Translucent Preview Items In Furnace UI Being Fully Opaque When The gui_blocks Atlas Is Disabled
static bool use_furnace_fix = false;
static int item_color_fix_mode = 0;
#define FURNACE_ITEM_TRANSPARENCY 0x33
#define INVALID_FURNACE_ITEM_VALUE 0x40
#define FURNACE_ITEM_DEFAULT_COLOR 0x33ffffff
#define INVALID_FURNACE_ITEM_DEFAULT_COLOR 0xff404040
static void Tesselator_colorABGR_injection(unsigned char *tesselator, int32_t color) {
// Fix Furnace UI
if (use_furnace_fix) {
if (item_color_fix_mode != 0) {
int32_t a;
int32_t b;
int32_t g;
int32_t r;
// Force Translucent
int32_t a = FURNACE_ITEM_TRANSPARENCY;
int32_t b = (color & 0x00ff0000) >> 16;
int32_t g = (color & 0x0000ff00) >> 8;
int32_t r = (color & 0x000000ff) >> 0;
if (item_color_fix_mode == 1) {
a = FURNACE_ITEM_TRANSPARENCY;
b = (color & 0x00ff0000) >> 16;
g = (color & 0x0000ff00) >> 8;
r = (color & 0x000000ff) >> 0;
} else {
a = 0xff;
b = INVALID_FURNACE_ITEM_VALUE;
g = INVALID_FURNACE_ITEM_VALUE;
r = INVALID_FURNACE_ITEM_VALUE;
}
// New Color
color = r | (g << 8) | (b << 16) | (a << 24);
}
@ -62,37 +73,55 @@ static void Tesselator_begin_injection(unsigned char *tesselator, int32_t mode)
(*Tesselator_begin)(tesselator, mode);
// Fix Furnace UI
if (use_furnace_fix) {
if (item_color_fix_mode != 0) {
// Implict Translucent
(*Tesselator_colorABGR_injection)(tesselator, 0xffffffff);
(*Tesselator_colorABGR_injection)(tesselator, item_color_fix_mode == 1 ? FURNACE_ITEM_DEFAULT_COLOR : INVALID_FURNACE_ITEM_DEFAULT_COLOR);
}
}
static void Tesselator_color_injection(unsigned char *tesselator, int32_t r, int32_t g, int32_t b, int32_t a) {
// Fix Furnace UI
if (use_furnace_fix) {
if (item_color_fix_mode != 0) {
// Force Translucent
a = FURNACE_ITEM_TRANSPARENCY;
if (item_color_fix_mode == 1) {
a = FURNACE_ITEM_TRANSPARENCY;
} else {
a = 0xff;
b = INVALID_FURNACE_ITEM_VALUE;
g = INVALID_FURNACE_ITEM_VALUE;
r = INVALID_FURNACE_ITEM_VALUE;
}
}
// Call Original Method
(*Tesselator_color)(tesselator, r, g, b, a);
}
static float FurnaceScreen_render_ItemRenderer_renderGuiItem_injection(unsigned char *font, unsigned char *textures, ItemInstance *item_instance, float param_1, float param_2, bool param_3) {
// Enable Furnace UI Fix
use_furnace_fix = true;
static void InventoryPane_renderBatch_Tesselator_color_injection(unsigned char *tesselator, int32_t r, int32_t g, int32_t b) {
// Call Original Method
(*Tesselator_color)(tesselator, r, g, b, 0xff);
// Enable Item Color Fix
item_color_fix_mode = 2;
}
static void ItemRenderer_renderGuiItem_two_injection(unsigned char *font, unsigned char *textures, ItemInstance *item_instance, float param_1, float param_2, float param_3, float param_4, bool param_5) {
// Call Original Method
(*ItemRenderer_renderGuiItem_two)(font, textures, item_instance, param_1, param_2, param_3, param_4, param_5);
// Disable Item Color Fix
item_color_fix_mode = 0;
}
static void FurnaceScreen_render_ItemRenderer_renderGuiItem_one_injection(unsigned char *font, unsigned char *textures, ItemInstance *item_instance, float param_1, float param_2, bool param_3) {
// Enable Item Color Fix
item_color_fix_mode = 1;
// Call Original Method
float ret = (*ItemRenderer_renderGuiItem)(font, textures, item_instance, param_1, param_2, param_3);
// Disable Furnace UI Fix
use_furnace_fix = false;
// Return
return ret;
(*ItemRenderer_renderGuiItem_one)(font, textures, item_instance, param_1, param_2, param_3);
}
// Init
void init_atlas() {
// Add Better NULL-Check (And More UI Fixes When The gui_blocks Atlas Is Disabled)
overwrite_calls((void *) ItemRenderer_renderGuiItem_two, (void *) ItemRenderer_renderGuiItem_two_injection);
// Disable The gui_blocks Atlas Which Contains Pre-Rendered Textures For Blocks In The Inventory
if (feature_has("Disable \"gui_blocks\" Atlas", 0)) {
unsigned char disable_gui_blocks_atlas_patch[4] = {0x00, 0xf0, 0x20, 0xe3}; // "nop"
@ -103,6 +132,7 @@ void init_atlas() {
overwrite_calls((void *) Tesselator_colorABGR, (void *) Tesselator_colorABGR_injection);
overwrite_calls((void *) Tesselator_begin, (void *) Tesselator_begin_injection);
overwrite_calls((void *) Tesselator_color, (void *) Tesselator_color_injection);
overwrite_call((void *) 0x32324, (void *) FurnaceScreen_render_ItemRenderer_renderGuiItem_injection);
overwrite_call((void *) 0x32324, (void *) FurnaceScreen_render_ItemRenderer_renderGuiItem_one_injection);
overwrite_call((void *) 0x1e21c, (void *) InventoryPane_renderBatch_Tesselator_color_injection);
}
}

View File

@ -135,10 +135,20 @@ static unsigned char *RakNetInstance_injection(unsigned char *rak_net_instance)
return result;
}
// Close Current Screen On Death To Prevent Bugs
static void LocalPlayer_die_injection(unsigned char *entity, unsigned char *cause) {
// Close Screen
unsigned char *minecraft = *(unsigned char **) (entity + LocalPlayer_minecraft_property_offset);
(*Minecraft_setScreen)(minecraft, NULL);
// Call Original Method
(*LocalPlayer_die)(entity, cause);
}
// Init
void init_misc() {
// Remove Invalid Item Background (A Red Background That Appears For Items That Are Not Included In The gui_blocks Atlas)
if (feature_has("Remove Invalid Item Background", 0)) {
// Remove Invalid Item Background (A Red Background That Appears For Items That Are Not Included In The gui_blocks Atlas)
unsigned char invalid_item_background_patch[4] = {0x00, 0xf0, 0x20, 0xe3}; // "nop"
patch((void *) 0x63c98, invalid_item_background_patch);
}
@ -162,6 +172,11 @@ void init_misc() {
// Fix Bug Where RakNetInstance Starts Pinging Potential Servers Before The "Join Game" Screen Is Opened
overwrite_calls((void *) RakNetInstance, (void *) RakNetInstance_injection);
// Close Current Screen On Death To Prevent Bugs
if (feature_has("Close Current Screen On Death", 0)) {
patch_address(LocalPlayer_die_vtable_addr, (void *) LocalPlayer_die_injection);
}
// Init C++ And Logging
_init_misc_cpp();
_init_misc_logging();

View File

@ -268,9 +268,6 @@ static ItemInstance_constructor_extra_t ItemInstance_constructor_item_extra = (I
// Entity
typedef void (*Entity_die_t)(unsigned char *entity, unsigned char *cause);
static uint32_t Entity_die_vtable_offset = 0x130;
static uint32_t Entity_x_property_offset = 0x4; // float
static uint32_t Entity_y_property_offset = 0x8; // float
static uint32_t Entity_z_property_offset = 0xc; // float
@ -288,6 +285,9 @@ static uint32_t Mob_actuallyHurt_vtable_offset = 0x16c;
typedef float (*Mob_getWalkingSpeedModifier_t)(unsigned char *entity);
typedef void (*Mob_die_t)(unsigned char *entity, unsigned char *cause);
static uint32_t Mob_die_vtable_offset = 0x130;
static uint32_t Mob_health_property_offset = 0xec; // int32_t
// Player
@ -310,6 +310,9 @@ static void *LocalPlayer_actuallyHurt_vtable_addr = (void *) 0x10639c;
static void *LocalPlayer_openTextEdit_vtable_addr = (void *) 0x106460;
static Mob_die_t LocalPlayer_die = (Mob_die_t) 0x45078;
static void *LocalPlayer_die_vtable_addr = (void *) 0x106360;
static uint32_t LocalPlayer_minecraft_property_offset = 0xc90; // Minecraft *
// ServerPlayer
@ -567,10 +570,13 @@ static uint32_t TileEntity_id_property_offset = 0x18; // int32_t
// ItemRenderer
typedef float (*ItemRenderer_renderGuiItem_t)(unsigned char *font, unsigned char *textures, ItemInstance *item_instance, float param_1, float param_2, bool param_3);
static ItemRenderer_renderGuiItem_t ItemRenderer_renderGuiItem = (ItemRenderer_renderGuiItem_t) 0x63e58;
typedef void (*ItemRenderer_renderGuiItem_one_t)(unsigned char *font, unsigned char *textures, ItemInstance *item_instance, float param_1, float param_2, bool param_3);
static ItemRenderer_renderGuiItem_one_t ItemRenderer_renderGuiItem_one = (ItemRenderer_renderGuiItem_one_t) 0x63e58;
typedef float (*ItemRenderer_renderGuiItemCorrect_t)(unsigned char *font, unsigned char *textures, ItemInstance *item_instance, int32_t param_1, int32_t param_2);
typedef void (*ItemRenderer_renderGuiItem_two_t)(unsigned char *font, unsigned char *textures, ItemInstance *item_instance, float param_1, float param_2, float param_3, float param_4, bool param_5);
static ItemRenderer_renderGuiItem_two_t ItemRenderer_renderGuiItem_two = (ItemRenderer_renderGuiItem_two_t) 0x63be0;
typedef void (*ItemRenderer_renderGuiItemCorrect_t)(unsigned char *font, unsigned char *textures, ItemInstance *item_instance, int32_t param_1, int32_t param_2);
static ItemRenderer_renderGuiItemCorrect_t ItemRenderer_renderGuiItemCorrect = (ItemRenderer_renderGuiItemCorrect_t) 0x639a0;
// Tesselator