Help adding recipes to GregTech machines

  • Ok, so I am a complete noob in terms of modding MC or Java coding. I spent the entirety of last night trying to figure this out and am completely lost and confused.


    All I want to do is add some recipes to the machines in GregTech using items from GregTech, IC2, and Metallurgy 2. I'm not adding anything new, no new items or anything, just new recipes. Just as an example, I would like to be able to throw some Hepatizon dust from Metallurgy 2 into a GregTech Industrial Centrifuge to get a Carbon Cell. I've spent hours reading and watching tutorials but am just not understanding it. I'm not sure I've got MCP set up properly, and I know I'm not getting the syntax for the actual code right, but I can't figure out what I'm doing wrong and need help.


    So far I've followed the directions for installing MCP with forge and an external API. I have gotten the IC2 api to work (I think), but I keep getting around 80 errors when I try to do it with the GregTech API.


    Here's what I'm doing step by step, please let me know if I'm messing any of this up:



    So far I've just been trying to add a regular macerator recipe just to figure out how to add recipes using items from a mod. I have been stuck on that all night.
    Here is the code I've been trying to use:



    Clearly, I have no idea what I'm doing despite using the MineCraftForge Wiki tutorials and IC2 API information on http://ic2api.player.to.


    So, the questions I have right now are:


    1. Am I installing mcp with the APIs correctly? If not, what am I doing wrong?
    2. How do I correctly add a macerator recipe to IC2 using items from IC2?
    3. How do I add a recipe to the GregTech Industrial Centrifuge (or any of the other GregTech machines) using items from IC2 & GregTech?
    4. How do I use items from Metallurgy 2, or any other mod, in recipes for IC2 and/or GregTech machines?


    I am really at my wits end with this and will be eternally grateful to anyone who can help me out.

    • Official Post

    Disclaimer: I will use [SENTENCE_IN_ALLCAPS] as placeholder for your Numbers. (It's not really Allcaps as I hold the Shift-Key)


    Okay, now for the first mistake.

    Code
    ItemStack stack1 = new ItemStack(ic2.api.Items.getItem(resin));


    That's wrong, It's actually:

    Code
    ItemStack stack1 = ic2.api.Items.getItem("resin").copy();
    stack1.stackSize = [INSERT_AMOUNT_OF_RESIN_HERE];


    The IC²-API gives you directly an ItemStack, you dont have to make a new one.


    Now to my API. This simple call is for adding the Centrifuge Recipe of your Hepatizon Dust to Carbon Cells:


    Code
    int duration = [INSERT_HOW_LONG_IT_AHOULD_TAKE_HERE];
    int amountOfCarbonCells = [INSERT_AMOUNT_OF_CARBON_CELLS_HERE];
    int amountOfHepazitonDust = [INSERT_AMOUNT_OF_HEPATIZON_DUST_HERE];
    ItemStack output = gregtechmod.api.GregTech_API.getGregTechItem(2, amountOfCarbonCells, 8);
    for (ItemStack input : OreDictionary.getOres("dustHepatizon"))  {
    input = input.copy();
    input.stackSize = amountOfHepazitonDust;
    gregtechmod.api.GregTech_API.addCentrifugeRecipe(ItemStack input, amountOfCarbonCells, output, null, null, null, duration);
    }


    I'm aware that my API is currently not easy to use, as you have to correct some Errors in the Code (missing Functions), but it works.


  • actually, the copy method makes a new itemstack anyway, so he might as well make his own,
    in fact, using the ItemStack(Item, int) constructor, he could specify the stacksize too,
    which be more concise than your method (1 line instead of 2)

  • Thank you both for the help! That has allowed me to at least write the code without Eclipse giving me errors.


    Now I'm running into another problem though. When I run recompile I wind up getting more errors and it tells me, "Can not find server sources, try decompiling." And then if I run reobfuscate I get more errors and it says, "can not find client bins, try recompiling." and "can not find server md5s". After this there is nothing in the reobf directory.


    This makes me wonder if I'm still not setting up my MCP directory/install correctly? What am I missing here? I followed all the directions I could find to set it up, and the code seems to work in Eclipse, so what am I messing up now? I'm using Wuppy's tutorials on how to make a forge mod. As I understand it, once I write the code and save the files, I should just have to run recompile, then reobfuscate, and everything I need should wind up in the reobf directory right?


    Just in case I'm still messing up the code, here's what I've got so far:


    For the IC2 macerator test recipe:


    And for the GregTech Industrial Centrifuge test recipe:


    Again, thanks for the help guys. :)

    • Official Post

    actually, the copy method makes a new itemstack anyway, so he might as well make his own,
    in fact, using the ItemStack(Item, int) constructor, he could specify the stacksize too,
    which be more concise than your method (1 line instead of 2)

    There is no ItemStack(ItemStack, int) Method. The thing you get from the IC²-API is an ItemStack and not an Item. And with the IC²-API you also get the correspondend Damage Value of the Item inside the Stack.



    Code
    Can not find server sources, try decompiling.


    That's no Error, it always tells you that (They should remove that useless Log).

    Quote

    This makes me wonder if I'm still not setting up my MCP directory/install correctly? What am I missing here? I followed all the directions I could find to set it up, and the code seems to work in Eclipse, so what am I messing up now? I'm using Wuppy's tutorials on how to make a forge mod. As I understand it, once I write the code and save the files, I should just have to run recompile, then reobfuscate, and everything I need should wind up in the reobf directory right?

    Yes, it should give you only the changed/added Files to the reobf-Folder.


    What did you do to install it? I do something like the following:
    1. unpack MCP-Folder somewhere.
    2. unpack Forge-Folder so that there is a Folder called forge inside the MCP-Main-Directory.
    3. throw the bin-Folder of Minecraft and the minecraft_server.jar into the jars-Folder.
    4. run install.cmd inside the Forge-Folder.
    5. open eclipse and select the .eclipse-Folder inside the MCP-Main-Directory as workspace.
    6. Now you should have one Project-Folder with the Name "Minecraft" in it.
    7. Place now all your Files, API's and Packages inside the src-Folder. Since 1.4.6 its the src-Folder instead of the common-Folder
    8. Now that you coded your Mod, run Recompile and then Reobfuscate, grab your Mod from the reobf Folder, zip it and try to throw it into your mods Folder.

  • Ok, that must be what I'm doing wrong. I described what I did to set up everything in my first post and this is what I was doing:



    In your install steps I have everything up until step 6. The "Minecraft" project folder you're talking about is "mcp/Eclipse/Minecraft"? Or is it "mcp/src/Minecraft"?


    On step 7 which src folder are you talking about? The directions I found by Wuppy, and others, said there should be a mcp/forge/src directory, but there isn't. Am I supposed to just create that directory and throw the APIs in there instead of mcp/forge/client and mcp/forge/common? Or are you talking about the mcp/src directory and just put the APIs in there after running install?


    Is there anything other than the APIs for IC2, GregTech, and Metallurgy 2, that I need to put in there?



    I just tested your install method and it seemed to work perfectly for getting everything set up, but I still got the same errors when I tried to recompile and reobfuscate. Still nothing in the reobf directory afterwards.


    My exact steps:


    1. unpack mcp725.zip to it's own directory
    2. copy the "bin" and "resources" directories from a clean MC 1.4.6 install into mcp/jars
    3. copy minecraft_server.jar into mcp/jars
    4. unpack the forge source zip into mcp/forge
    5. ran mcp/forge/install.cmd (This completed with no errors)
    6. ran Eclipse and selected mcp/eclipse as my workspace
    7. closed Eclipse
    8. placed the IC2 API in mcp/src/minecraft/ic2
    9. placed the GregTech API in mcp/src/minecraft/gregtechmod
    10. ran Eclipse again, noticed that it had the ic2.api and gregtechmod.api packages as I assume it should at this point
    Also noticed that there were some errors in the gregtechmod.api package, didn't touch them as I probably don't understand enough of this to make those errors go away.
    11. created a new package and class
    12. pasted my code into the new class and saved everything
    13. closed Eclipse and tried to run recompile and reobfuscate. Got the same errors and result as before.


    Please tell me there's something I'm doing wrong in there somewhere and it's an easy fix.


    Again, thank you for all the help. I would never have been able to get even this far without you guys explaining it to me.

    • Official Post

    10. ran Eclipse again, noticed that it had the ic2.api and gregtechmod.api packages as I assume it should at this point
    Also noticed that there were some errors in the gregtechmod.api package, didn't touch them as I probably don't understand enough of this to make those errors go away.

    You haveto resolve all the Errors in eclipse before recompiling! Eclipse tells you what is wrong. Just remove the red underlined lines of errored Code, eclipse is complaining about.

  • It's really ok to just remove them? That won't mess up your mod? It seems like a lot of code to just delete.


    EDIT: Ok, that did work and now the recipes are working as well. I am very happy right now. ^^


    Thank you for all the help!


    And by the way, GregTech is one of my favorite mods. It's just freaking awesome! :)



    EDIT2: Ok, so some of the recipes are working. Any idea why recipes using ore dictionary entries from Metallurgy 2 wouldn't show up in game? What I mean is I added a recipe using "dustManganese" which is in the ore dictionary, now in the game the recipe doesn't show up for the Metallurgy 2 Manganese dust, but it does show up for the GregTech Manganese dust. This is confusing to me because they're both in the ore dictionary with the same name "dustManganese". So what gives?


    This happens no matter what dust I use from Metallurgy 2, even when it's the only one of it's type in the ore dictionary, like the dustHepatizon. In that case the recipe just doesn't show up in game at all (since the Metallurgy 2 dust is the only one there). Am I doing something wrong again? *bangs head against wall*


    Also, I'm trying to add wolframium as a fuel for the semifluid generator and the recipe isn't showing up in game. So what am I doing wrong in this code:


    • Official Post

    Oops, Your Fuel isn't showing, because I derped with the Description. You need Type 3 and not Type 4 for the Fuel Function. (Type 4 = Plasma, and thats not implemented yet).


    Do you have NEI installed? If not then get NEI and install also mistaqurs NEI-Plugins, then go into the NEI-Config and set "mistaqur.enableDebug" to true. Then you can see if the Metallurgy Dust is correctly registered, by using the "Usage"-Key on the Dust.

  • Ok! Now the fuel recipes are working also. :)


    After setting the debug mode on for NEI I do see the "Ore Dictionary" page along with everything else. The only difference I see there is that your dust has a second "itemDustManganese" entry, and his only has the "dustManganese" entry. Is that the problem?

    • Official Post

    Ok! Now the fuel recipes are working also. :)


    After setting the debug mode on for NEI I do see the "Ore Dictionary" page along with everything else. The only difference I see there is that your dust has a second "itemDustManganese" entry, and his only has the "dustManganese" entry. Is that the problem?

    The second "itemDust"-Entry is for depricated Mods, I removed it in recent Versions. If both dusts have "dustManganese" then it should work.



    AHHH, I see whats the Problem. You register the Recipes in the @Init-Function, you need to do that in the @PostInit-Function, otherwise some Items are not registered, when your Mod gets loaded.

  • Hmm, well I tried making it run @PostInit, but then none of the recipes show up in game. And that's literally the only change I made, @Init to @PostInit.
    Also tried both with, and without, the (FMLInitializationEvent event) in the public void load line. No difference either way.


    Edit to add the code:



    EDIT2:


    Ok, nevermind, I see what I did wrong there and it's working now. Needed the (FMLPostInitializationEvent event), derp. :)


    So now I think everything is working as it should. Again, thank you very much for the help and great mod!

  • Starting a new thread for such a minor issue seems trivial, seeing as this is a fairly minor (and relevant) issue.
    If I'm coding using the GregTech API (or any API besides Forestry), the updatemd5 script in MCP fails. Functionally everything is perfect, however. Is there any particular reason for this?

    • Official Post

    Starting a new thread for such a minor issue seems trivial, seeing as this is a fairly minor (and relevant) issue.
    If I'm coding using the GregTech API (or any API besides Forestry), the updatemd5 script in MCP fails. Functionally everything is perfect, however. Is there any particular reason for this?

    Why do you use updatemd5? It messes around with the obfuscation, and causes Errors as soon as you change something in the wrong way.

  • Because I generally haven't used an API with MCP before, so I had no idea what I was doing :P On the other hand, everything seems to have installed correctly, and deobf/reobf's correctly, so either way it's working :)

  • As far as I can tell, AEtherchild, all you have to do is install MCP without any APIs and then put whatever API you want to use in the mcp/src/minecraft directory afterwards. See some of the previous posts in this thread for a specific list of steps. If I'm wrong on this please correct me GregoriusT. :)


    Also, I ran into another question for you that I can't find an answer to. What is the syntax for adding a shaped crafting recipe to IC2? All the wiki, or the API, says is, "addCraftingRecipe (ItemStack result, Object...args)". So I don't understand how to write out that bit. I tried the code below thinking maybe the args it wanted were basically just the items for each slot when crafting, but it crashed while loading saying there was an IC2 crafting recipe error.


    Here's the code I tried:


    • Official Post

    The Crafting System is more like a Blueprint. See how one can use it here:


    (Result, new Object[] {"XXX", "XAX", "XXX", false, 'X', new ItemStack(Item.redstone, 1), 'A', "gemRuby"})
    (Result, new Object[] {"XXX", "XAX", "XXX", false, 'X', new ItemStack(Item.redstone, 1), 'A', "gemSapphire"})
    (Result, new Object[] {"XXX", "XAX", "XXX", false, 'X', new ItemStack(Item.redstone, 1), 'A', "gemGreenSapphire"})
    (Result, new Object[] {"XXX", "XAX", "XXX", false, 'X', new ItemStack(Item.redstone, 1), 'A', "gemOlivine"})


    These four are the ones you are looking for. The Parameters inside the Array are:


    "XXX", "XAX" and "XXX" = The shape on the Crafting Table (Blueprint). In this Case for your Energy Crystal
    false = This Recipe is not hidden like the UUM-Recipes, set that to true if you shouldnt see this Recipe in NEI or Craftguide
    'X' = What the X inside the Blueprint means
    new ItemStack(Item.redstone, 1) = The Redstone. I disrecommend using "dustRedstone" as that is just a Part of my Addon (makes many things easier for me)
    'A' = What the A inside the Blueprint means
    "gemRuby", "gemSapphire", "gemGreenSapphire" and "gemOlivine", those are the OreDict-Based names for the Gems you wanna use. These Strings are enough, no need to iterate for that sake.

  • So more like this?



    EDIT:


    Not like that I take it, as it's still not working. Sorry I'm not picking up on this better, I just don't have any experience coding and just thought it would be fun to try my hand at it. Thanks for your help and for being patient with me. :)

  • Ok, thank you. Again, sorry for not getting it as quickly as maybe I should. Like I said, I have absolutely no experience in coding and am just doing this because I thought it'd be fun. So thank you for the help and for being patient with me.