Jump to content

[1.7.2][Unsolved]Getting direct texture locations


SoBiohazardous

Recommended Posts

Hello all,

I need to get the direct location of a mods assets folder on the user's computer. I know that Minecraft.getMinecraft().mcDataDir will get where minecraft is located, however i'm not sure to get the assets of mod as well. Any help would be appreciated, thanks.

 

Here is my method that needs it, in case you where wondering. It is supposed to return all the textures in a folder.

/**
 * Returns all of the textures with the material prefix and the type in an array. used for metadata material blocks
 * @param matPrefix
 * @param type
 * @return
 */
public static String[] getMaterialStringArray(String id, String matPrefix, String type)
{
	List<String> textures = new ArrayList<>();
	try
	{
		String path = new ResourceLocation("extradecor:/textures/blocks/stoneCutter/").getResourcePath();
		File textureDir = new File(path);

		for(int i = 0; i < textureDir.list().length; i++)
		{
			if(textureDir.list()[i].startsWith(matPrefix + "_" + type))
			{
				textures.add(id + ":/stoneCutter/" + textureDir.list()[i].replaceAll(".png", "")); 
			}
		}

	}

	catch(Exception e)
	{

	} 

	//convert the list to an array
	String[] result = new String[textures.size()];
	for(int i = 0; i < textures.size(); i++)
	{
		result[i] = textures.get(i);
	}
	return result;
}

Link to comment
Share on other sites

Hi

 

Sorry, I should have been a bit clearer; what I meant was that you can use that as a starting point to figure out where the directory is coming from.  To be honest I don't know exactly the answer to your question.

 

The following is based on 1.6.4 but I imagine it's similar for 1.7.2

 

The base path is stored in the FolderResourcePack or the FileResourcePack depending on whether your assets are in a directory or in a zip.

 

So you need to find the file that is passed to their constructor.  If you put a breakpoint in the constructor, you should be able to trace back to the caller and hopefully figure out where the base path is coming from, or alternatively a way for you to access it.

 

(It looks to me like they are contained in ResourcePackRepository, which gives you access to getDirResourcepacks and getResourcePackFiles()

from Minecraft.getMinecraft().getResourcePackRepository, but I'm not sure exactly how forge inserts your mod packs into that.)

 

-TGG

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.