From 56955ad935078ace5a65251e2bbb2f014878f492 Mon Sep 17 00:00:00 2001 From: Nikita Edel Date: Wed, 11 Mar 2026 03:59:41 +0100 Subject: [PATCH] shift of negative values, added casts --- Minecraft.Client/Textures/Texture.cpp | 9 +++++---- Minecraft.Client/Textures/Textures.cpp | 11 ++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Minecraft.Client/Textures/Texture.cpp b/Minecraft.Client/Textures/Texture.cpp index 7b568f402..b5d9625b9 100644 --- a/Minecraft.Client/Textures/Texture.cpp +++ b/Minecraft.Client/Textures/Texture.cpp @@ -660,10 +660,11 @@ void Texture::transferFromImage(BufferedImage *image) int c3 = data[level - 1]->getInt(((x * 2 + 0) + (y * 2 + 1) * ow) * 4); #ifndef _XBOX // 4J - convert our RGBA texels to ARGB that crispBlend is expecting - c0 = ( ( c0 >> 8 ) & 0x00ffffff ) | ( c0 << 24 ); - c1 = ( ( c1 >> 8 ) & 0x00ffffff ) | ( c1 << 24 ); - c2 = ( ( c2 >> 8 ) & 0x00ffffff ) | ( c2 << 24 ); - c3 = ( ( c3 >> 8 ) & 0x00ffffff ) | ( c3 << 24 ); + // 4jcraft, added uint cast to pervent shift of neg int + c0 = ( ( c0 >> 8 ) & 0x00ffffff ) | ( (unsigned int) c0 << 24 ); + c1 = ( ( c1 >> 8 ) & 0x00ffffff ) | ( (unsigned int) c1 << 24 ); + c2 = ( ( c2 >> 8 ) & 0x00ffffff ) | ( (unsigned int) c2 << 24 ); + c3 = ( ( c3 >> 8 ) & 0x00ffffff ) | ( (unsigned int) c3 << 24 ); #endif int col = crispBlend(crispBlend(c0, c1), crispBlend(c2, c3)); // 4J - and back from ARGB -> RGBA diff --git a/Minecraft.Client/Textures/Textures.cpp b/Minecraft.Client/Textures/Textures.cpp index 0974a3f66..83cb97d44 100644 --- a/Minecraft.Client/Textures/Textures.cpp +++ b/Minecraft.Client/Textures/Textures.cpp @@ -626,15 +626,16 @@ void Textures::loadTexture(BufferedImage *img, int id, bool blur, bool clamp) int c3 = pixels->getInt(((x * 2 + 0) + (y * 2 + 1) * ow) * 4); #ifndef _XBOX // 4J - convert our RGBA texels to ARGB that crispBlend is expecting - c0 = ( ( c0 >> 8 ) & 0x00ffffff ) | ( c0 << 24 ); - c1 = ( ( c1 >> 8 ) & 0x00ffffff ) | ( c1 << 24 ); - c2 = ( ( c2 >> 8 ) & 0x00ffffff ) | ( c2 << 24 ); - c3 = ( ( c3 >> 8 ) & 0x00ffffff ) | ( c3 << 24 ); + // 4jcraft, added uint cast to pervent shift of neg int + c0 = ( ( c0 >> 8 ) & 0x00ffffff ) | ( (unsigned int) c0 << 24 ); + c1 = ( ( c1 >> 8 ) & 0x00ffffff ) | ( (unsigned int) c1 << 24 ); + c2 = ( ( c2 >> 8 ) & 0x00ffffff ) | ( (unsigned int) c2 << 24 ); + c3 = ( ( c3 >> 8 ) & 0x00ffffff ) | ( (unsigned int) c3 << 24 ); #endif int col = Texture::crispBlend(Texture::crispBlend(c0, c1), Texture::crispBlend(c2, c3)); #ifndef _XBOX // 4J - and back from ARGB -> RGBA - col = ( col << 8 ) | (( col >> 24 ) & 0xff); + col = ( (unsigned int) col << 8 ) | (( col >> 24 ) & 0xff); #endif tempData[x + y * ww] = col; }