Posted January 3, 20169 yr 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.
January 3, 20169 yr 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
January 3, 20169 yr 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.
January 3, 20169 yr 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
January 3, 20169 yr 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.