Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

THere is no resource directory, they are resource packs.

What YOU want is a config.

Which you're passed the directory in one of the FML init events.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

  • Author

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.

So? Store the config folder somewhere until you need it later.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

  • Author

My God, I am so sorry for being this idiotic! Thank you Lex.

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.