Fix Weird Shading

This commit is contained in:
TheBrokenRail 2022-06-26 22:01:31 -04:00
parent bfa0567ac9
commit 329f92c0a4

View File

@ -38,35 +38,24 @@ static void ItemRenderer_renderGuiItemCorrect_injection(unsigned char *font, uns
// Fix Translucent Preview Items In Furnace UI Being Fully Opaque When The gui_blocks Atlas Is Disabled // Fix Translucent Preview Items In Furnace UI Being Fully Opaque When The gui_blocks Atlas Is Disabled
static int item_color_fix_mode = 0; static int item_color_fix_mode = 0;
#define FURNACE_ITEM_TRANSPARENCY 0x33 #define POTENTIAL_FURNACE_ITEM_TRANSPARENCY 0x33
#define INVALID_FURNACE_ITEM_VALUE 0x40 #define INVALID_FURNACE_ITEM_MULTIPLIER 0.25f
#define FURNACE_ITEM_DEFAULT_COLOR 0x33ffffff static void Tesselator_color_injection(unsigned char *tesselator, int32_t r, int32_t g, int32_t b, int32_t a) {
#define INVALID_FURNACE_ITEM_DEFAULT_COLOR 0xff404040
static void Tesselator_colorABGR_injection(unsigned char *tesselator, int32_t color) {
// Fix Furnace UI // Fix Furnace UI
if (item_color_fix_mode != 0) { if (item_color_fix_mode != 0) {
int32_t a;
int32_t b;
int32_t g;
int32_t r;
// Force Translucent // Force Translucent
if (item_color_fix_mode == 1) { if (item_color_fix_mode == 1) {
a = FURNACE_ITEM_TRANSPARENCY; a = POTENTIAL_FURNACE_ITEM_TRANSPARENCY;
b = (color & 0x00ff0000) >> 16;
g = (color & 0x0000ff00) >> 8;
r = (color & 0x000000ff) >> 0;
} else { } else {
a = 0xff; static double multiplier = INVALID_FURNACE_ITEM_MULTIPLIER;
b = INVALID_FURNACE_ITEM_VALUE; b *= multiplier;
g = INVALID_FURNACE_ITEM_VALUE; g *= multiplier;
r = INVALID_FURNACE_ITEM_VALUE; r *= multiplier;
} }
// New Color
color = r | (g << 8) | (b << 16) | (a << 24);
} }
// Call Original Method // Call Original Method
(*Tesselator_colorABGR)(tesselator, color); (*Tesselator_color)(tesselator, r, g, b, a);
} }
static void Tesselator_begin_injection(unsigned char *tesselator, int32_t mode) { static void Tesselator_begin_injection(unsigned char *tesselator, int32_t mode) {
// Call Original Method // Call Original Method
@ -75,26 +64,9 @@ static void Tesselator_begin_injection(unsigned char *tesselator, int32_t mode)
// Fix Furnace UI // Fix Furnace UI
if (item_color_fix_mode != 0) { if (item_color_fix_mode != 0) {
// Implict Translucent // Implict Translucent
(*Tesselator_colorABGR_injection)(tesselator, item_color_fix_mode == 1 ? FURNACE_ITEM_DEFAULT_COLOR : INVALID_FURNACE_ITEM_DEFAULT_COLOR); (*Tesselator_color_injection)(tesselator, 0xff, 0xff, 0xff, 0xff);
} }
} }
static void Tesselator_color_injection(unsigned char *tesselator, int32_t r, int32_t g, int32_t b, int32_t a) {
// Fix Furnace UI
if (item_color_fix_mode != 0) {
// Force Translucent
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 void InventoryPane_renderBatch_Tesselator_color_injection(unsigned char *tesselator, int32_t r, int32_t g, int32_t b) { static void InventoryPane_renderBatch_Tesselator_color_injection(unsigned char *tesselator, int32_t r, int32_t g, int32_t b) {
// Call Original Method // Call Original Method
(*Tesselator_color)(tesselator, r, g, b, 0xff); (*Tesselator_color)(tesselator, r, g, b, 0xff);
@ -129,7 +101,6 @@ void init_atlas() {
// Fix Grass And Leaves Inventory Rendering When The gui_blocks Atlas Is Disabled // Fix Grass And Leaves Inventory Rendering When The gui_blocks Atlas Is Disabled
overwrite_calls((void *) ItemRenderer_renderGuiItemCorrect, (void *) ItemRenderer_renderGuiItemCorrect_injection); overwrite_calls((void *) ItemRenderer_renderGuiItemCorrect, (void *) ItemRenderer_renderGuiItemCorrect_injection);
// Fix Furnace UI // Fix Furnace UI
overwrite_calls((void *) Tesselator_colorABGR, (void *) Tesselator_colorABGR_injection);
overwrite_calls((void *) Tesselator_begin, (void *) Tesselator_begin_injection); overwrite_calls((void *) Tesselator_begin, (void *) Tesselator_begin_injection);
overwrite_calls((void *) Tesselator_color, (void *) Tesselator_color_injection); overwrite_calls((void *) Tesselator_color, (void *) Tesselator_color_injection);
overwrite_call((void *) 0x32324, (void *) FurnaceScreen_render_ItemRenderer_renderGuiItem_one_injection); overwrite_call((void *) 0x32324, (void *) FurnaceScreen_render_ItemRenderer_renderGuiItem_one_injection);