RecipeManager

The Recipe Manager Class is used to manage your recipe handlers, and should be one of the 2 main classes you use in this mod. The recipe manager has 10 methods which I will go over on this page.

String generateID(ItemStack[] Inputs)
generateID(Inputs) is a utillity method used to generate a recipe id based off of the ItemStack passed to the function. While this provides a quick fix for some, it is generaly better to come up with your own recipe id, especialy for longer recipes as th id generated can get pretty long.

boolean isRecipeHandler(String Name)
isRecipeHandler(Name) check if a recipe hander of the given name has been created.

boolean isMachineRegistered(ItemStack Machine)
isMachineRegistered(Machine) check if a Machine has been registered as using a recipe handler.

IRecipeHandler newRecipeHandler(String Name)
newRecipeHandler(Name) is used to create a new recipe handler using the given name. newRecipeHandler(Name) will only create a new recipe handler if there is NOT alreadt a recipe handler using the given name. If newRecipeHandler(Name) were to be called using the name of a previously registered recipe handler then it will Log an error reporting the attempt to create a recipe handler using a previously registered recipe handler's name, and instead of thowing an execption will return the recipe handler already registered with the given name.

It is typicaly wise to call isRecipeHandler(Name) before attempting to create a recipe handler.

A list of recipe handlers modders used can be found here. Please add any recipe handlers you create to this list as well.

IRecipeHandler getRecipeHandler(String Name)
getRecipeHandler(Name) returns the recipe handler of the given name if one exists. If no such recipe handler existe the method will Log an error reporting such and return null instead of thowing an exception.

It is typicaly wise to call isRecipeHandler(Name) before attempting to get a recipe handler

IRecipeHandler tieMachineToHandler(ItemStack Machine, String Name)
tieMachineToHandler(Machine, Name) registers the Machine as using the recipe handler of the given Name. If there is no recipe handler of the given name then the method will Log an error reporting such and retrun null instead of thowing an exception. If the Machine is already registered as using a recipe handler then the methos will Log an error reporting such and return the recipe handler that is already registered to the Machine.

It is typicaly wise to call isRecipeHandler(Name) and isMachineRegistered(Machine) before attempting to register a Machine to a recipe handler.

IRecipeHandler getHandlerForMachine(ItemStack Machine)
getHandlerForMachine(Machine) return the recipe handler for the given Machine. If the Machine has not be registered to use a recipe handler then this method will Log an error reporting such an return null instead of throwing an exception.

It is typicaly wise to call isMachineRegistered(Machine) before attempting to get a recipe handler attached to a Machine

ArrayList getMachinesUsing(String Name)
getMachinesUsing(Name) returns an ArrayList of the ItemStacks for all Machines registered as using the recipe handler of the given Name. If there is no recipe handler using the given Name then the method will Log an error reporting so and return null instead of throwing an exception.

it is typicaly wise to call isRecipeHandler(Name) before calling the method.

ArrayList,ArrayList> getAllRecipeHandlers
getAllRecipeHandlers returns 2 ArrayLlists. The first is an ArrayList conatining the names for the recipe handler of the same index. The second is an ArrayList conatining the recipe handlers for the name of the same index. Both recipe list will be returned as generic ArrayList<>s, as such you will either need to convert the ArrayList<>s to an ArrayList or ArrayList appropriately, or convert the individual componets of the ArrayList<>s to a String or IRecipeHandler appropriately.

Examples:
//A method that converts the ArrayLists public void example1{ /*As a rule of thumb you should attach any returns to a variable, and the * variable in this case needs to be an ArrayList as that is     * what will acctualy be returned by the method.*/ ArrayList eLORH = RecipeManager.getAllRecipeHandlers; /*This line converts the ArrayList at eLORH's index of 0 to an     * ArrayList, because the first ArrayList returned by this method * will always be an ArrayList in generic form.*/ ArrayList eLORHNames = eLORH.get(0); /*This line convets the ArrayList at eLORH's index of 1 to an     * ArrayList, because the second ArrayList returned by this * method will always ne an ArrayList in generic form*/ ArrayList eLORHHandlers = eLORH.get(1); /*Assaigns the value of an index to a variable of the correct type without * casting */ String exampleName = eLORHNames.get(0); IRecipeHandler exampleHandler = eLORHHandlers.get(0); } //A methof that converts the individual components public void example2{ /*As a rule of thumb you should attache any returns to a variable and the * variable in this case needs to be an ArrayList as that is     * what will acctualy be returned from the method. */     ArrayList<ArrayList> eLORH = RecipeManager.getAllRecipeHandlers; /*Casts a value at an index of the ArrayList at eLORH's index of 0 to a     * String, because the first ArrayList returned by this method will always * be an ArrayList<String> in generic form so a value from that * ArrayList<String> must be a String as an Object. */     String exampleName = (String)eLORH.get(0).get(0); /*Casts a value at an index of the ArrayList at eLORH's index of 1 to a     * IRecipeHandler, beacuse the second ArrayList returned be this method * will always be an ArrayLisr<IRecipeHandler> in generic form so a value * from that ArrayList<IRecipeHandler> must be an IRecipeHandler as an     * Object. */     IRecipeHandler exampleHandler = (IRecipeHandler)eLORH.get(1).get(0); }

ArrayList<ArrayList<ItemStack>, ArrayList<String>, ArrayList<IRecipeHandler>> getAllMachineMappings
getAllMachineMappings returns 3 ArrayLists. The first ArrayList is an ArrayList<ItemStack> containing the ItemStacks of the machines registerd to the recipe handler of the same index. The second ArrayList is an ArrayList<String> containg the names for the recipe handler of the same index. The third and last ArrayList is an ArrayList<IRecipeHandler> containng the recipe handlers mapped to the machine ItemStack of the same index. These ArrayLists are returned as gerneric ArrayList and thus you must convert either the ArrayLista to an ArrayList<ItemStack>, ArrayList<String>, or ArrayList<IRecipeHandler> accordingly, or the individual components of the ArrayLists to an ItemStack, String, or IRecipeHandler accordingly.

Examples:
//A method that converts the ArrayLists public void example1{ /*As a rule of thumb you should attach any returns to a variable, and the * variable in this case needs to be an ArrayList<ArrayList> as that is     * what will acctualy be returned by the method.*/ ArrayList<ArrayList> eMM = RecipeManager.getAllMachineMappings; /*This line converts the ArrayList at eMM's index of 0 to an      * ArrayList<ItemStack>, beacue the first ArrayList returned by this method * will always be an ArrayList<ItemStack in generic form> ArrayList<ItemStack> eMMMachines = eMM.get(0); /*This line converts the ArrayList at eMM's index of 1 to an     * ArrayList<String>, because the second ArrayList returned by this method * will always be an ArrayList<String> in generic form.*/ ArrayList<String> eMMNames = eMM.get(1); /*This line convets the ArrayList at eLORH's index of 2 to an     * ArrayList<IRecipeHandler>, because the third ArrayList returned by this * method will always ne an ArrayList<IRecipeHandler> in generic form*/ ArrayList<IRecipeHandler> eMMHandlers = eMM.get(2); /*Assaigns the value of an index to a variable of the correct type without * casting */ ItemStack exampleItemStack = eMMMachines.get(0); String exampleName = eMMNames.get(0); IRecipeHandler exampleHandler = eMMHandlers.get(0); } //A methof that converts the individual components public void example2{ /*As a rule of thumb you should attache any returns to a variable and the * variable in this case needs to be an ArrayList<ArrayList> as that is     * what will acctualy be returned from the method. */     ArrayList<ArrayList> eMM = RecipeManager.getAllMachineMappings; /*Casta a value at an index of the ArrayList at eMM's index of 0 to a     * ItemStack, because the first ArrayList returned by this method will * always be an ArrayList<ItemStack> in generic form so a value from that * ArrayList<ItemStack> must be an ItemStack as an Object. */     ItemStack exampleStack = (ItemStack)eMM.get(0).get(0); /*Casts a value at an index of the ArrayList at eMM's index of 1 to a     * String, because the second ArrayList returned by this method will always * be an ArrayList<String> in generic form so a value from that * ArrayList<String> must be a String as an Object. */     String exampleName = (String)eMM.get(1).get(0); /*Casts a value at an index of the ArrayList at eMM's index of 2 to a     * IRecipeHandler, beacuse the thrid ArrayList returned be this method * will always be an ArrayLisr<IRecipeHandler> in generic form so a value * from that ArrayList<IRecipeHandler> must be an IRecipeHandler as an     * Object. */     IRecipeHandler exampleHandler = (IRecipeHandler)eMM.get(2).get(0); }