fix: dlc animated textures

This commit is contained in:
Fireblade 2026-05-30 16:06:56 -04:00
parent e8b66c62d7
commit 8d86287e5e
No known key found for this signature in database
5 changed files with 41 additions and 22 deletions

View file

@ -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 )

View file

@ -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;
}

View file

@ -235,7 +235,7 @@ Texture *StitchedTexture::getSource()
Texture *StitchedTexture::getFrame(int i)
{
return frames->at(0);
return frames->at(i);
}
int StitchedTexture::getFrames()

View file

@ -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)

View file

@ -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;