From 8d86287e5e9ce6e6b99f891268f5b2a0e1e21625 Mon Sep 17 00:00:00 2001 From: Fireblade <72758695+Firebladedoge229@users.noreply.github.com> Date: Sat, 30 May 2026 16:06:56 -0400 Subject: [PATCH] fix: dlc animated textures --- Minecraft.Client/BufferedImage.cpp | 24 +++++++++++++++++++++--- Minecraft.Client/DLCTexturePack.cpp | 5 +++++ Minecraft.Client/StitchedTexture.cpp | 2 +- Minecraft.Client/TextureManager.cpp | 14 +++++++++----- Minecraft.Client/TextureMap.cpp | 18 +++++------------- 5 files changed, 41 insertions(+), 22 deletions(-) diff --git a/Minecraft.Client/BufferedImage.cpp b/Minecraft.Client/BufferedImage.cpp index 844f4bd3..aa214e15 100644 --- a/Minecraft.Client/BufferedImage.cpp +++ b/Minecraft.Client/BufferedImage.cpp @@ -209,16 +209,34 @@ BufferedImage::BufferedImage(DLCPack *dlcPack, const wstring& File, bool filenam { mipMapPath = L"MipMapLevel" + std::to_wstring(l+1); } + wstring basePath; if( filenameHasExtension ) { - name = L"res" + filePath.substr(0,filePath.length()); + basePath = filePath; } else { - name = L"res" + filePath.substr(0,filePath.length()-4) + mipMapPath + L".png"; + basePath = filePath.substr(0,filePath.length()-4) + mipMapPath + L".png"; } - if(!dlcPack->doesPackContainFile(DLCManager::e_DLCType_All, name)) + wstring candidates[2] = + { + L"res" + basePath, + L"x16Data/res" + basePath + }; + + bool found = false; + for (const auto &candidate : candidates) + { + if (dlcPack->doesPackContainFile(DLCManager::e_DLCType_All, candidate)) + { + name = candidate; + found = true; + break; + } + } + + if(!found) { // 4J - If we haven't loaded the non-mipmap version then exit the game if( l == 0 ) diff --git a/Minecraft.Client/DLCTexturePack.cpp b/Minecraft.Client/DLCTexturePack.cpp index 19327ece..6b935a89 100644 --- a/Minecraft.Client/DLCTexturePack.cpp +++ b/Minecraft.Client/DLCTexturePack.cpp @@ -200,6 +200,11 @@ wstring DLCTexturePack::getAnimationString(const wstring &textureName, const wst } } + if(result.empty() && fallback != nullptr) + { + result = fallback->getAnimationString(textureName, path, true); + } + return result; } diff --git a/Minecraft.Client/StitchedTexture.cpp b/Minecraft.Client/StitchedTexture.cpp index aca2c7cc..049fb574 100644 --- a/Minecraft.Client/StitchedTexture.cpp +++ b/Minecraft.Client/StitchedTexture.cpp @@ -235,7 +235,7 @@ Texture *StitchedTexture::getSource() Texture *StitchedTexture::getFrame(int i) { - return frames->at(0); + return frames->at(i); } int StitchedTexture::getFrames() diff --git a/Minecraft.Client/TextureManager.cpp b/Minecraft.Client/TextureManager.cpp index eeba43bd..428279f6 100644 --- a/Minecraft.Client/TextureManager.cpp +++ b/Minecraft.Client/TextureManager.cpp @@ -191,12 +191,16 @@ wstring TextureManager::getTextureNameFromPath(const wstring &filename) bool TextureManager::isAnimation(const wstring &filename, TexturePack *texturePack) { - wstring dataFileName = L"/" + filename.substr(0, filename.find_last_of(L'.')) + L".txt"; - bool hasOriginalImage = texturePack->hasFile(L"/" + filename, false); + File file(filename); + wstring textureName = file.getName(); + size_t extensionPos = textureName.find_last_of(L'.'); + if (extensionPos != wstring::npos) + { + textureName = textureName.substr(0, extensionPos); + } - - - return texturePack->hasFile(dataFileName, !hasOriginalImage); + wstring path = filename.substr(0, filename.length() - file.getName().length()); + return !texturePack->getAnimationString(textureName, path, true).empty(); } Texture *TextureManager::createTexture(const wstring &name, int mode, int width, int height, int wrap, int format, int minFilter, int magFilter, bool mipmap, BufferedImage *image) diff --git a/Minecraft.Client/TextureMap.cpp b/Minecraft.Client/TextureMap.cpp index e329a532..561005cc 100644 --- a/Minecraft.Client/TextureMap.cpp +++ b/Minecraft.Client/TextureMap.cpp @@ -154,20 +154,12 @@ void TextureMap::stitch() { animatedTextures.push_back(stored); - wstring animationDefinitionFile = textureName + L".txt"; - TexturePack *texturePack = Minecraft::GetInstance()->skins->getSelected(); - bool requiresFallback = !texturePack->hasFile(L"\\" + textureName + L".png", false); - InputStream *fileStream = texturePack->getResource(L"\\" + path + animationDefinitionFile, requiresFallback); - - //Minecraft::getInstance()->getLogger().info("Found animation info for: " + animationDefinitionFile); -#ifndef _CONTENT_PACKAGE - wprintf(L"Found animation info for: %ls\n", animationDefinitionFile.c_str() ); -#endif - InputStreamReader isr(fileStream); - BufferedReader br(&isr); - stored->loadAnimationFrames(&br); - delete fileStream; + wstring animationString = texturePack->getAnimationString(textureName, path, true); + if (!animationString.empty()) + { + stored->loadAnimationFrames(animationString); + } } } delete areas;