feat: DLC world folder support

This commit is contained in:
Fireblade 2026-05-12 22:11:26 -04:00
parent 00a3be0630
commit 15e4da3308
31 changed files with 60 additions and 19 deletions

View file

@ -23,8 +23,12 @@ ClockTexture::ClockTexture(int iPad, ClockTexture *dataTexture) : StitchedTextur
void ClockTexture::cycleFrames()
{
Minecraft *mc = Minecraft::GetInstance();
int frameCount = getFrames();
if (frameCount <= 0)
{
return;
}
double rott = 0;
if (m_iPad >= 0 && m_iPad < XUSER_MAX_COUNT && mc->level != nullptr && mc->localplayers[m_iPad] != nullptr)
@ -57,10 +61,10 @@ void ClockTexture::cycleFrames()
// 4J Stu - We share data with another texture
if(m_dataTexture != nullptr)
{
int newFrame = static_cast<int>((rot + 1.0) * m_dataTexture->frames->size()) % m_dataTexture->frames->size();
int newFrame = static_cast<int>((rot + 1.0) * frameCount) % frameCount;
while (newFrame < 0)
{
newFrame = (newFrame + m_dataTexture->frames->size()) % m_dataTexture->frames->size();
newFrame = (newFrame + frameCount) % frameCount;
}
if (newFrame != frame)
{
@ -70,10 +74,10 @@ void ClockTexture::cycleFrames()
}
else
{
int newFrame = static_cast<int>((rot + 1.0) * frames->size()) % frames->size();
int newFrame = static_cast<int>((rot + 1.0) * frameCount) % frameCount;
while (newFrame < 0)
{
newFrame = (newFrame + frames->size()) % frames->size();
newFrame = (newFrame + frameCount) % frameCount;
}
if (newFrame != frame)
{

View file

@ -77,13 +77,19 @@ void CompassTexture::updateFromPosition(Level *level, double x, double z, double
rot += rota;
}
int frameCount = getFrames();
if (frameCount <= 0)
{
return;
}
// 4J Stu - We share data with another texture
if(m_dataTexture != nullptr)
{
int newFrame = static_cast<int>(((rot / (PI * 2)) + 1.0) * m_dataTexture->frames->size()) % m_dataTexture->frames->size();
int newFrame = static_cast<int>(((rot / (PI * 2)) + 1.0) * frameCount) % frameCount;
while (newFrame < 0)
{
newFrame = (newFrame + m_dataTexture->frames->size()) % m_dataTexture->frames->size();
newFrame = (newFrame + frameCount) % frameCount;
}
if (newFrame != frame)
{
@ -93,10 +99,10 @@ void CompassTexture::updateFromPosition(Level *level, double x, double z, double
}
else
{
int newFrame = static_cast<int>(((rot / (PI * 2)) + 1.0) * frames->size()) % frames->size();
int newFrame = static_cast<int>(((rot / (PI * 2)) + 1.0) * frameCount) % frameCount;
while (newFrame < 0)
{
newFrame = (newFrame + frames->size()) % frames->size();
newFrame = (newFrame + frameCount) % frameCount;
}
if (newFrame != frame)
{

View file

@ -200,6 +200,8 @@ void PreStitchedTextureMap::stitch()
void PreStitchedTextureMap::makeTextureAnimated(TexturePack *texturePack, StitchedTexture *tex)
{
if(!tex->hasOwnData())
{
animatedTextures.push_back(tex);
@ -212,15 +214,18 @@ void PreStitchedTextureMap::makeTextureAnimated(TexturePack *texturePack, Stitch
if(!animString.empty())
{
wstring filename = path + textureFileName + extension;
// TODO: [EB] Put the frames into a proper object, not this inside out hack
vector<Texture *> *frames = TextureManager::getInstance()->createTextures(filename, m_mipMap);
vector<Texture *> *frames = TextureManager::getInstance()->createTextures(filename, m_mipMap, true);
if (frames == nullptr || frames->empty())
{
return; // Couldn't load a texture, skip it
}
Texture *first = frames->at(0);
#ifndef _CONTENT_PACKAGE
@ -259,7 +264,10 @@ void PreStitchedTextureMap::cycleAnimationFrames()
{
for(StitchedTexture* texture : animatedTextures)
{
texture->cycleFrames();
if (texture != nullptr && texture->getFrames() > 0)
{
texture->cycleFrames();
}
}
}

View file

@ -192,6 +192,11 @@ int StitchedTexture::getSourceHeight() const
void StitchedTexture::cycleFrames()
{
if (frames == nullptr || frames->empty())
{
return;
}
if (frameOverride != nullptr)
{
pair<int, int> current = frameOverride->at(frame);

View file

@ -80,10 +80,13 @@ Stitcher *TextureManager::createStitcher(const wstring &name)
return new Stitcher(name, maxTextureSize, maxTextureSize, true);
}
vector<Texture *> *TextureManager::createTextures(const wstring &filename, bool mipmap)
vector<Texture *> *TextureManager::createTextures(const wstring &filename, bool mipmap, bool forceAnimation)
{
vector<Texture *> *result = new vector<Texture *>();
TexturePack *texturePack = Minecraft::GetInstance()->skins->getSelected();
TexturePack *imagePack = texturePack;
//try {
int mode = Texture::TM_CONTAINER; // Most important -- so it doesn't get uploaded to videoram
int clamp = Texture::WM_WRAP; // 4J Stu - Don't clamp as it causes issues with how we signal non-mipmmapped textures to the pixel shader //Texture::WM_CLAMP;
@ -95,9 +98,9 @@ vector<Texture *> *TextureManager::createTextures(const wstring &filename, bool
wstring drive = L"";
if(texturePack->hasFile(L"res/" + filename,false))
if(imagePack->hasFile(L"res/" + filename,false))
{
drive = texturePack->getPath(true);
drive = imagePack->getPath(true);
}
else
{
@ -108,31 +111,39 @@ vector<Texture *> *TextureManager::createTextures(const wstring &filename, bool
char *pchUsrDir = app.GetBDUsrDirPath(pchTextureName);
wstring wstr (pchUsrDir, pchUsrDir+strlen(pchUsrDir));
drive= wstr + L"\\Common\\res\\TitleUpdate\\";
imagePack = texturePack;
}
else
#endif
{
drive = Minecraft::GetInstance()->skins->getDefault()->getPath(true);
imagePack = Minecraft::GetInstance()->skins->getDefault();
drive = imagePack->getPath(true);
}
}
//BufferedImage *image = new BufferedImage(texturePack->getResource(L"/" + filename),false,true,drive); //ImageIO::read(texturePack->getResource(L"/" + filename));
BufferedImage *image = texturePack->getImageResource(filename, false, true, drive);
BufferedImage *image = imagePack->getImageResource(filename, false, true, drive);
MemSect(0);
int height = image->getHeight();
int width = image->getWidth();
wstring texName = getTextureNameFromPath(filename);
if (isAnimation(filename, texturePack))
if (forceAnimation || isAnimation(filename, texturePack))
{
// TODO: Read this information from the animation file later
int frameWidth = width;
int frameHeight = width;
// This could end as 0 frames
int frameCount = height / frameWidth;
for (int i = 0; i < frameCount; i++)
{
BufferedImage *subImage = image->getSubimage(0, frameHeight * i, frameWidth, frameHeight);
@ -140,6 +151,7 @@ vector<Texture *> *TextureManager::createTextures(const wstring &filename, bool
delete subImage;
result->push_back(texture);
}
}
else
{
@ -147,6 +159,7 @@ vector<Texture *> *TextureManager::createTextures(const wstring &filename, bool
if (width == height)
{
result->push_back(createTexture(texName, mode, width, height, clamp, format, minFilter, magFilter, mipmap || image->getData(1) != nullptr, image));
}
else
{
@ -158,6 +171,8 @@ vector<Texture *> *TextureManager::createTextures(const wstring &filename, bool
}
delete image;
//return result;
//} catch (FileNotFoundException e) {
@ -178,7 +193,10 @@ bool TextureManager::isAnimation(const wstring &filename, TexturePack *texturePa
{
wstring dataFileName = L"/" + filename.substr(0, filename.find_last_of(L'.')) + L".txt";
bool hasOriginalImage = texturePack->hasFile(L"/" + filename, false);
return Minecraft::GetInstance()->skins->getSelected()->hasFile(dataFileName, !hasOriginalImage);
return texturePack->hasFile(dataFileName, !hasOriginalImage);
}
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

@ -29,7 +29,7 @@ public:
void registerTexture(Texture *texture);
void unregisterTexture(const wstring &name, Texture *texture);
Stitcher *createStitcher(const wstring &name);
vector<Texture *> *createTextures(const wstring &filename, bool mipmap); // 4J added mipmap param
vector<Texture *> *createTextures(const wstring &filename, bool mipmap, bool forceAnimation = false); // 4J added mipmap param
private:
wstring getTextureNameFromPath(const wstring &filename);

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 121 KiB

After

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 KiB

After

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 989 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 B