I'm trying to select specific metadatas from an array for my objects' crafting. I am planning to have a few of these so typing every metadata available in the crafting recipe would be time consuming and bulky, especially if I add more. Basically, I have an item that has damage on it and I want you to be able to use it up to a certain point until it isn't "charged" enough for the recipe. It's kinda weird to explain, so maybe the code will clarify by what it looks like i'm trying to do. So in the example code of mine, I have an orb that crafts stuff and decreases (technically increasing damage) uses on it until it gets to the last use, in which case it is able to be used indefinitely (because of how i coded it). I want to eliminate the last metadata from available crafting recipes so it can't be used in crafting at that state.
int wildcard[] = new int[5];
wildcard[0] = 0;
wildcard[1] = 1;
wildcard[2] = 2;
wildcard[3] = 3;
wildcard[4] = 4;
GameRegistry.addShapelessRecipe(new ItemStack(Items.coal, 1),
new Object[]{new ItemStack(LimpCraft2.orbCarbonLightCharged, 1, wildcard[choose0-5]), LimpCraft2.oreFuzzium, Items.gunpowder});
I admit, I am new to arrays and more technical things in coding and probably should take time to learn more, but I don't want to put halt on my mod while doing that.
EDIT* "I want to eliminate the last metadata from available crafting recipes so it can't be used in crafting at that state." But still have it available to recharge the item!
Hours of googling has led me to no answers... is there even a way to select a certain group of numbers from an array to use as the metadata? I basically want an OR logic in place of the metadata, but can't figure out how to get it there. I want to use item, quantity, META1 or META2 or META3 or META4 or META5 but NOT META6 (my item has only 6 values). I know I can type each one individually, but that takes up a lot of space and is inefficient in the long run, especially when I plan on adding more recipes (ALOT MORE) requiring various metadatas. I could use OreDictionary.WILDCARD_VALUE but I don't want to allow the last value!
Rollback Post to RevisionRollBack
Mod Author and Owner of Blockhole
Owner of other discontinued or status frozen work: LimpCraft2, LimpCore, InventoryCalculator, VillageTech, Bitto'Color.
//Small fixes
//Use i in setting the damage during the creation of the itemstack, not one
// Length-1; don't give a recipe to the last damage
for(int i = 0; i < wildcard.length-1, i++) {
GameRegistry.addShapelessRecipe(new ItemStack(Items.coal, 1), new ItemStack(LimpCraft2.orbCarbonLightCharged, i, wildcard), LimpCraft2.oreFuzzium, Items.gunpowder);
}
//Small fixes
//Use i in setting the damage during the creation of the itemstack, not one
// Length-1; don't give a recipe to the last damage
for(int i = 0; i < wildcard.length-1, i++) {
GameRegistry.addShapelessRecipe(new ItemStack(Items.coal, 1), new ItemStack(LimpCraft2.orbCarbonLightCharged, i, wildcard), LimpCraft2.oreFuzzium, Items.gunpowder);
}
for(int i = 0; i < (wildcard.length - 1), i++) {
GameRegistry.addShapelessRecipe(new ItemStack(Items.coal, 1), new ItemStack(LimpCraft2.orbCarbonLightCharged, 1, i), LimpCraft2.oreFuzzium, Items.gunpowder);
}
Use a for loop. Note, this does everything existing in the array wildcard.
for(int i = 0; i < wildcard.length, i++) {
GameRegistry.addShapelessRecipe(new ItemStack(Items.coal, 1), new ItemStack(LimpCraft2.orbCarbonLightCharged, 1, wildcard), LimpCraft2.oreFuzzium, Items.gunpowder);
}
Thank you so much master801, this worked perfectly (except there needed a semicolon after length instead of comma :D) Such a simple tool in java to get exactly what I wanted to get done, done! Now I can continue with all the similar recipes
Rollback Post to RevisionRollBack
Mod Author and Owner of Blockhole
Owner of other discontinued or status frozen work: LimpCraft2, LimpCore, InventoryCalculator, VillageTech, Bitto'Color.
Thank you so much master801, this worked perfectly (except there needed a semicolon after length instead of comma :D) Such a simple tool in java to get exactly what I wanted to get done, done! Now I can continue with all the similar recipes
I admit, I am new to arrays and more technical things in coding and probably should take time to learn more, but I don't want to put halt on my mod while doing that.
EDIT* "I want to eliminate the last metadata from available crafting recipes so it can't be used in crafting at that state." But still have it available to recharge the item!
Mod Author and Owner of Blockhole
Owner of other discontinued or status frozen work: LimpCraft2, LimpCore, InventoryCalculator, VillageTech, Bitto'Color.
Mod Author and Owner of Blockhole
Owner of other discontinued or status frozen work: LimpCraft2, LimpCore, InventoryCalculator, VillageTech, Bitto'Color.
Thank you so much master801, this worked perfectly (except there needed a semicolon after length instead of comma :D) Such a simple tool in java to get exactly what I wanted to get done, done! Now I can continue with all the similar recipes
Mod Author and Owner of Blockhole
Owner of other discontinued or status frozen work: LimpCraft2, LimpCore, InventoryCalculator, VillageTech, Bitto'Color.
I was close though.