From b60c156add10c552860cd67a63e83948e5de28d2 Mon Sep 17 00:00:00 2001 From: haxi0 Date: Thu, 12 Mar 2026 17:40:41 +0300 Subject: [PATCH] removed speaker.png, the game now uses the built-in voiceSpeaking and voiceNotSpeaking images --- Minecraft.Client/Common/Media/media.txt | 4 +- .../Common/res/1_2_2/gui/speaker.png | Bin 334 -> 0 bytes Minecraft.Client/Common/res/gui/speaker.png | 3 - Minecraft.Client/PlayerRenderer.cpp | 98 ++++++++++++++++-- Minecraft.Client/ResourceLocation.h | 6 +- Minecraft.Client/Textures.cpp | 1 - Minecraft.Client/Textures.h | 1 - .../Windows64Media/Media/gui/speaker.png | 3 - 8 files changed, 95 insertions(+), 21 deletions(-) delete mode 100644 Minecraft.Client/Common/res/1_2_2/gui/speaker.png delete mode 100644 Minecraft.Client/Common/res/gui/speaker.png delete mode 100644 Minecraft.Client/Windows64Media/Media/gui/speaker.png diff --git a/Minecraft.Client/Common/Media/media.txt b/Minecraft.Client/Common/Media/media.txt index 2e10707b..59b0fbe1 100644 --- a/Minecraft.Client/Common/Media/media.txt +++ b/Minecraft.Client/Common/Media/media.txt @@ -2,4 +2,6 @@ splashes.txt HTMLColours.col Graphics\SaveChest.png Graphics\MinecraftIcon.png -Graphics\TexturePackIcon.png \ No newline at end of file +Graphics\TexturePackIcon.png +Graphics\InGameInfo\voiceSpeaking.png +Graphics\InGameInfo\voiceNotSpeaking.png diff --git a/Minecraft.Client/Common/res/1_2_2/gui/speaker.png b/Minecraft.Client/Common/res/1_2_2/gui/speaker.png deleted file mode 100644 index ab30c18bee0b7c93605f2694b35f93603304cb83..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 334 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0J3?w7mbKU|e#^NA%C&rs6b?Si}&H|6fVg?3o zVGw3ym^DWND5w?S6XFV_f#CmthM>Tp01yar0s)tRfRLcT5GN-$Cr1wl2L~4ymmQbd zt$|AUN`m}?ff|rNxYunFpv+=V7srr_Imsys3=-@fjS2$$YVzBh*?0D~}n&|anv4g;x12Y(f9KS#CTe6-hd4;ngSHh$(;R+n34;(Z( zSRYmM97~T)yBNl}`Cz7Z@*FqENWiBK79hs$nv1)lm< z%QiA~EHdU%D=@ou$G4cZdEp$F&|?M*xF#Ir2xMT;*nZowcbl{p$kU##elF{r5}E*8 CT5kCO diff --git a/Minecraft.Client/Common/res/gui/speaker.png b/Minecraft.Client/Common/res/gui/speaker.png deleted file mode 100644 index dd9d8872..00000000 --- a/Minecraft.Client/Common/res/gui/speaker.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c357a4e7ca1ae6e96805b2e1ce3dd46499f3f6ee92db5ab349c543728623e523 -size 334 diff --git a/Minecraft.Client/PlayerRenderer.cpp b/Minecraft.Client/PlayerRenderer.cpp index 61d52d55..1278dbf3 100644 --- a/Minecraft.Client/PlayerRenderer.cpp +++ b/Minecraft.Client/PlayerRenderer.cpp @@ -8,6 +8,9 @@ #include "LocalPlayer.h" #include "MultiPlayerLocalPlayer.h" #include "entityRenderDispatcher.h" +#include "BufferedImage.h" +#include "..\Minecraft.World\File.h" +#include "..\Minecraft.World\InputOutputStream.h" #include "..\Minecraft.World\net.minecraft.world.entity.h" #include "..\Minecraft.World\net.minecraft.world.entity.player.h" #include "..\Minecraft.World\net.minecraft.world.item.h" @@ -54,6 +57,74 @@ static unsigned int nametagColorForIndex(int index) return 0xFF000000; //Fallback if exceeds 256 somehow } +namespace +{ + static const float VOICE_ICON_HALF_HEIGHT = 8.0f; + static const float VOICE_ICON_HALF_WIDTH = VOICE_ICON_HALF_HEIGHT * (60.0f / 40.0f); + + BufferedImage *LoadVoiceIndicatorImage(bool speaking) + { + const wchar_t *filePath = speaking + ? L"Common\\Media\\Graphics\\InGameInfo\\voiceSpeaking.png" + : L"Common\\Media\\Graphics\\InGameInfo\\voiceNotSpeaking.png"; + File file(filePath); + if (file.exists()) + { + byteArray imageBytes(static_cast(file.length())); + FileInputStream stream(file); + const int bytesRead = stream.read(imageBytes); + stream.close(); + if (bytesRead > 0) + { + imageBytes.length = static_cast(bytesRead); + BufferedImage *image = new BufferedImage(imageBytes.data, imageBytes.length); + delete[] imageBytes.data; + return image; + } + delete[] imageBytes.data; + } + + const wchar_t *archivePath = speaking + ? L"Graphics\\InGameInfo\\voiceSpeaking.png" + : L"Graphics\\InGameInfo\\voiceNotSpeaking.png"; + if (!app.hasArchiveFile(archivePath)) + { + return nullptr; + } + + byteArray imageBytes = app.getArchiveFile(archivePath); + if (imageBytes.data == nullptr || imageBytes.length == 0) + { + return nullptr; + } + + BufferedImage *image = new BufferedImage(imageBytes.data, imageBytes.length); + delete[] imageBytes.data; + return image; + } + + int GetVoiceIndicatorTextureId(Textures *textures, bool speaking) + { + static int s_voiceSpeakingTextureId = -1; + static int s_voiceNotSpeakingTextureId = -1; + + int &textureId = speaking ? s_voiceSpeakingTextureId : s_voiceNotSpeakingTextureId; + if (textureId >= 0) + { + return textureId; + } + + BufferedImage *image = LoadVoiceIndicatorImage(speaking); + if (image == nullptr) + { + return -1; + } + + textureId = textures->getTexture(image, C4JRender::TEXTURE_FORMAT_RxGyBzAw, false); + return textureId; + } +} + ResourceLocation PlayerRenderer::DEFAULT_LOCATION = ResourceLocation(TN_MOB_CHAR); PlayerRenderer::PlayerRenderer() : LivingEntityRenderer( new HumanoidModel(0), 0.5f ) @@ -473,9 +544,10 @@ void PlayerRenderer::additionalRendering(shared_ptr _mob, float a) void PlayerRenderer::renderNameTags(shared_ptr player, double x, double y, double z, const wstring &msg, float scale, double dist) { - // Voice chat speaking indicator - if (player != nullptr && VoiceChatManager::getInstance().isEntitySpeaking(player->entityId)) + // Voice chat indicator + if (player != nullptr) { + const bool isSpeaking = VoiceChatManager::getInstance().isEntitySpeaking(player->entityId); glPushMatrix(); // Position above the head (slightly higher than the name tag) glTranslatef(static_cast(x), static_cast(y) + player->bbHeight + 0.75f, static_cast(z)); @@ -493,16 +565,22 @@ void PlayerRenderer::renderNameTags(shared_ptr player, double x, d glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(1, 1, 1, 1); - ResourceLocation speakerLoc(TN_GUI_SPEAKER); - bindTexture(&speakerLoc); + const int voiceIndicatorTextureId = GetVoiceIndicatorTextureId(entityRenderDispatcher->textures, isSpeaking); + if (voiceIndicatorTextureId < 0) + { + glPopMatrix(); + LivingEntityRenderer::renderNameTags(player, x, y, z, msg, scale, dist); + return; + } + + entityRenderDispatcher->textures->bind(voiceIndicatorTextureId); Tesselator* t = Tesselator::getInstance(); t->begin(); - // 16x16 icon coordinates - t->vertexUV(-8, -8, 0, 0, 0); - t->vertexUV(-8, 8, 0, 0, 1); - t->vertexUV( 8, 8, 0, 1, 1); - t->vertexUV( 8, -8, 0, 1, 0); + t->vertexUV(-VOICE_ICON_HALF_WIDTH, -VOICE_ICON_HALF_HEIGHT, 0, 0, 0); + t->vertexUV(-VOICE_ICON_HALF_WIDTH, VOICE_ICON_HALF_HEIGHT, 0, 0, 1); + t->vertexUV( VOICE_ICON_HALF_WIDTH, VOICE_ICON_HALF_HEIGHT, 0, 1, 1); + t->vertexUV( VOICE_ICON_HALF_WIDTH, -VOICE_ICON_HALF_HEIGHT, 0, 1, 0); t->end(); glPopMatrix(); @@ -617,4 +695,4 @@ ResourceLocation *PlayerRenderer::getTextureLocation(shared_ptr entity) { shared_ptr player = dynamic_pointer_cast(entity); return new ResourceLocation(static_cast<_TEXTURE_NAME>(player->getTexture())); -} \ No newline at end of file +} diff --git a/Minecraft.Client/ResourceLocation.h b/Minecraft.Client/ResourceLocation.h index 1274b25a..91947985 100644 --- a/Minecraft.Client/ResourceLocation.h +++ b/Minecraft.Client/ResourceLocation.h @@ -12,6 +12,7 @@ private: public: ResourceLocation() { + m_texture = textureNameArray(); m_preloaded = false; m_path = L""; } @@ -25,6 +26,7 @@ public: ResourceLocation(wstring path) { + m_texture = textureNameArray(); m_path = path; m_preloaded = false; } @@ -41,7 +43,7 @@ public: ~ResourceLocation() { - delete m_texture.data; + delete[] m_texture.data; } _TEXTURE_NAME getTexture() @@ -68,4 +70,4 @@ public: { return m_preloaded; } -}; \ No newline at end of file +}; diff --git a/Minecraft.Client/Textures.cpp b/Minecraft.Client/Textures.cpp index 162ace1d..ba7c0282 100644 --- a/Minecraft.Client/Textures.cpp +++ b/Minecraft.Client/Textures.cpp @@ -246,7 +246,6 @@ const wchar_t *Textures::preLoaded[TN_COUNT] = L"/AH_0008", L"/AH_0009",*/ - L"gui/speaker", L"gui/items", L"terrain", }; diff --git a/Minecraft.Client/Textures.h b/Minecraft.Client/Textures.h index b6904462..1fca5610 100644 --- a/Minecraft.Client/Textures.h +++ b/Minecraft.Client/Textures.h @@ -228,7 +228,6 @@ typedef enum _TEXTURE_NAME TN_AH_0008, TN_AH_0009,*/ - TN_GUI_SPEAKER, TN_GUI_ITEMS, TN_TERRAIN, diff --git a/Minecraft.Client/Windows64Media/Media/gui/speaker.png b/Minecraft.Client/Windows64Media/Media/gui/speaker.png deleted file mode 100644 index dd9d8872..00000000 --- a/Minecraft.Client/Windows64Media/Media/gui/speaker.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c357a4e7ca1ae6e96805b2e1ce3dd46499f3f6ee92db5ab349c543728623e523 -size 334