Jump to content

Recommended Posts

Posted

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 :)

Posted

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?

Long time Bukkit & Forge Programmer

Happy to try and help

Posted

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.

Posted

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.

Long time Bukkit & Forge Programmer

Happy to try and help

Posted

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.

Posted

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.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

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. 

Long time Bukkit & Forge Programmer

Happy to try and help

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

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

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?

Posted

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.

Long time Bukkit & Forge Programmer

Happy to try and help

Posted

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.

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.