Lately I've been doing some modding for a game called Minecraft which requires some programming in Java. I've been doing a lot of research but because I can't think of a simplified version of my questions it's hard to get any results from Google. So I'm hoping someone could answer these for me. If you can't, I would even appreciate being pointed in the right direction or led to some reading material that would answer these questions for me.
1) How can I add the value of a variable onto the name of another variable.
For instance, I have this line of code
Code:
EntityItem entityitem = new EntityItem(world, (float)i + f2, (float)j + f3, (float)k + f4, new ItemStack(Item.ingotIron));
and this variable that will always be a number
Code:
private int numberA;
I would like to add the value of numberA onto entityitem. So if numberA was 1 entityitem would become entityitem1.
2) What is the best variable type to store values such as Item.coal, which is an object within the game? Would a String type suffice?
3) Using the same code above:
Code:
EntityItem entityitem = new EntityItem(world, (float)i + f2, (float)j + f3, (float)k + f4, new ItemStack(Item.ingotIron));
How could I use a variable's value where Item.ingotIron is? I tried some different things but the compiler threw "ItemStack doesn't exist" or some error along those lines at me.
For instance if variableA's value is Item.coal, how could I use that variables value where Item.ingotIron is.
Code:
EntityItem entityitem = new EntityItem(world, (float)i + f2, (float)j + f3, (float)k + f4, new ItemStack(variableA));
I appreciate your time and help on this issue and anything you can provide will be greatly appreciated.