Jump to content

[1.8][SOLVED] Trouble finding the resource directory


HappyKiller1O1

Recommended Posts

So, here is what I am trying to do: I need to create a custom file using the File class within java. Trouble is, I can't figure out how to get the resource directory of Minecraft. Here is my code:

public static void createJSON() throws IOException {
	Gson json = new GsonBuilder().setPrettyPrinting().create();

	File jsonFile = new File(whatdoIputhere + "WeightLimit.json");

	if(!jsonFile.exists()) {
		jsonFile.createNewFile();
	}else {
		Writer jsonFileWriter = new FileWriter("/assets/utils/WeightLimit.json");

		FMLControlledNamespacedRegistry<Item> itemRegistry = GameData.getItemRegistry();

		for(Item item : itemRegistry.typeSafeIterable()) {
			String name = itemRegistry.getNameForObject(item).toString();

			json.toJson(name, jsonFileWriter);

			//System.out.println(json.toJson(name).toString());
		}

		jsonFileWriter.close();
	}
}

 

Mainly take a look at where I'm trying to create the file (third line in the method). All I need is the resource directory so I can create the file, but also create it on the server if present. Any help would be appreciated!

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Link to comment
Share on other sites

I do know where the config directory method is (the preInit). But, I run through the ItemRegistry to add every item of every mod loaded to this json file. In order to do this, I believe I'd have to create it in postInit, or risk missing some of the items.

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

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.