Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Java] How do I convert a string into code?
#5
(07-11-2012, 03:37 PM)noob007 Wrote: Then you can either use an array/map of functions that return a new instance of ItemStacks using a similar pattern to the accepted answer to this question: http://stackoverflow.com/questions/42807...of-methods

or you could just have an array/map full of different instances of ItemStacks, depending on your needs.

Here's what I think I'm going to do. I think it's pretty inefficient, but since it's only going to be run once at start-up I don't think it's too much of an issue.

Every item is given a String name parameter. In the main Item class, there is an array that every item gets added to. It's 32,000 long. My code will skim through the array, and if there is an item in that slot, it checks to see if the name parameter of the Item matches the given string. Because some items have a metadata or damage value (like dyes) in one Item object, I'll also manually add in a list for certain names. It'll then take that Item and add it to the recipe array as an ItemStack.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)