Jump to content

Recommended Posts

Posted

In my attempt to make a mod for configuring the CraftingManager's recipe list from the convenience of a configuration file, I've repeatedly worked around less than ideal circumstances. However, I find myself stuck on an especially cantankerous problem.

 

Parsing data from the Configuration file to fill a recipe list is trivial compared to putting information there representing the initial state. Attempts at crawling through the recipe list, with the intent to build a string encoding the recipe instance's field values in a way that allows me to construct them, is hacky, but worse I have been unable to make it work.

 

If one could magically get the argument values for the constructors, that would be perfect. In lieu of that ideal scenario, I figured getting the field values from instances would make a fine alternative, given that most of the IRecipe-implementing classes plop their constructor arguments into their field members. Ugly, but doable; even the OreRecipes comply. Fields can't be relied upon to be public, constructors aren't magic, so I'm left with reflection.

 

And here, I plant my face into a wall. Making a class field crawler both generic and useful has worn on my patience. I seek suggestions on how I might solve the problem; perhaps I've overlooked a more elegant solution, or maybe someone can elucidate on how I might crawl the class fields. If not, I'll be forced to resort to a less savory approach like not dumping the initial recipe list to the configuration file.

Posted

If you only want the user to add recipes I would suggest using XML or JSON rather than an configuration file, as deleting recipes would be more work.

No 5 row long documentation = account on the help forums

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.