kenny2810 Posted May 30, 2014 Share Posted May 30, 2014 Is there a method or any way to store the information in a config file into an array list? My mod is going to randomly give the player a random item which he will list in the config in the form: item.ingotIron Here is how the config will look: item.ingotIron item.ingotGold item.diamond etc Basically I want to be able to load those into an array list, and the rest has already been taken care of. Is it possible to do this using config files? Thanks in advance Quote Link to comment Share on other sites More sharing options...
kenny2810 Posted May 30, 2014 Author Share Posted May 30, 2014 Does it store all of them or do I have to run it for each one? Quote Link to comment Share on other sites More sharing options...
kenny2810 Posted May 30, 2014 Author Share Posted May 30, 2014 What I want is to store the strings from the config file into an array list. Does that method do that? Quote Link to comment Share on other sites More sharing options...
kenny2810 Posted May 30, 2014 Author Share Posted May 30, 2014 Cheers. Ive never used config files before, so I am not sure how its methods works. Thanks again Quote Link to comment Share on other sites More sharing options...
delpi Posted May 30, 2014 Share Posted May 30, 2014 What are you going to do with that string once you get it into your Array? How are you going to take that and translate it into an item? Quote Long time Bukkit & Forge Programmer Happy to try and help Link to comment Share on other sites More sharing options...
kenny2810 Posted May 30, 2014 Author Share Posted May 30, 2014 What are you going to do with that string once you get it into your Array? How are you going to take that and translate it into an item? I will be using an arraylist, not an array if I can. Quote Link to comment Share on other sites More sharing options...
larsgerrits Posted May 30, 2014 Share Posted May 30, 2014 He means that how you are gonna get the item from the string in the value? Quote Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/ Link to comment Share on other sites More sharing options...
delpi Posted May 30, 2014 Share Posted May 30, 2014 What larsgerrits said. Someone out there might know a method, but I haven't found one yet that works. If you don't have one, you will need to look at a different method. Quote Long time Bukkit & Forge Programmer Happy to try and help Link to comment Share on other sites More sharing options...
kenny2810 Posted May 30, 2014 Author Share Posted May 30, 2014 Hmm Im testing it right now to see if it works. Ill post back as soon as I know more. I have considered an alternate method, but it is a lot more complex and frankly not worth the extra effort. Quote Link to comment Share on other sites More sharing options...
GotoLink Posted May 30, 2014 Share Posted May 30, 2014 GameData.itemRegistry.getObjectByName(String) Quote Link to comment Share on other sites More sharing options...
kenny2810 Posted May 30, 2014 Author Share Posted May 30, 2014 That may work; If I can store that data into the arraylist then I should have no issues Quote Link to comment Share on other sites More sharing options...
jabelar Posted May 30, 2014 Share Posted May 30, 2014 What larsgerrits said. Someone out there might know a method, but I haven't found one yet that works. If you don't have one, you will need to look at a different method. Delpi, the whole point of moving away from ID numbering is that you can now look up registered items, entities, etc. by name String. Like GoToLink says there is a registry method getObjectByName(). Basically the ItemRegistry, BlockRegistry, are FMLControlledNamespacedRegistry class which has the set and get object methods. Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/ Link to comment Share on other sites More sharing options...
delpi Posted May 31, 2014 Share Posted May 31, 2014 Hopefully he has better luck. I tried using this for blocks and couldn't get it to work. No matter how I put in the name, it wouldn't get the block. Eventually I resorted to ID's again. Quote Long time Bukkit & Forge Programmer Happy to try and help Link to comment Share on other sites More sharing options...
jabelar Posted May 31, 2014 Share Posted May 31, 2014 I tried using this for blocks and couldn't get it to work. No matter how I put in the name, it wouldn't get the block. I'll have to look at this sometime. But I usually debug it by turning it around and instead of looking for a key I hope is there, instead try reading through the map and output all the keys that are there. Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/ Link to comment Share on other sites More sharing options...
kenny2810 Posted May 31, 2014 Author Share Posted May 31, 2014 GameData.itemRegistry.getObjectByName(String) I seem to be getting an error with the itemRegistry; Here is the error: itemRegistry cannot be resolved or is not a field Any idea what could be causing this? Quote Link to comment Share on other sites More sharing options...
delpi Posted May 31, 2014 Share Posted May 31, 2014 Hopefully, Jabelar or someone else can help you. I've tried it and gotten a long range of errors. I did a pretty robust error log grabbing the name out of blocks I clicked on, then automatically tried about 10 variations to regrab the block from that name. Nada. I'm assuming the same issue with items. I'm all ears, cause this would be far easier than the bs required to work in ID's now. Quote Long time Bukkit & Forge Programmer Happy to try and help Link to comment Share on other sites More sharing options...
kenny2810 Posted May 31, 2014 Author Share Posted May 31, 2014 At this point im willing to try anything. Also I am doing this in 1.6.4, sorry I didnt clarify earlier, butI mostly work on the code late at night and it kept slipping my mind. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.