[1.12.2] How to add recipes to Metal Former via api?

  • Hello, I don't know how to add recipes via api. All tutorials are outdated and it isn't working. I have downloaded ic2 api via build.gradle into eclipse

  • The metal former recipes are accessed via three fields in ic2.api.recipe.Recipes: metalformerExtruding, metalformerCutting and metalformerRolling. The method you'll want to be using is

    Java: IMachineRecipeManager
    1. boolean addRecipe(IRecipeInput input, Collection<ItemStack> output, NBTTagCompound metadata, boolean replace);

    The input type you can create using the IRecipeInputFactory instance inputFactory in Recipes, the output is just a list with a single ItemStack for what you want the recipe to produce, metadata can be null for a metal forming recipe, and replace is optional for if you want to override a pre-existing recipe. For a simple example, adding a rolling recipe turning an apple into stone, you'd do:

    1. import java.util.Collections;
    2. import net.minecraft.init.Blocks;
    3. import net.minecraft.init.Items;
    4. import net.minecraft.item.ItemStack;
    5. import ic2.api.recipe.IRecipeInput;
    6. import ic2.api.recipe.Recipes;
    7. IRecipeInput input = Recipes.inputFactory.forStack(new ItemStack(Items.APPLE));
    8. ItemStack output = new ItemStack(Blocks.STONE);
    9. Recipes.metalformerRolling.addRecipe(input, Collections.singletonList(output), null, false);

    For the different input options like ore dictionary support, fluid containers, multiple items per recipe, or various different items to produce the same output, take a look at ic2.api.recipe.IRecipeInputFactory.

    145 Mods isn't too many. 9 types of copper and 8 types of tin aren't too many. 3 types of coffee though?

    I know that you believe that you understood what you think I said, but I am not sure you realise that what you read was not what I meant.

    ---- Minecraft Crash Report ----
    // I just don't know what went wrong :(

    I see this too much.