1. Forum
  2. Wiki
  3. Bugtracker
  4. Blog
  5. Members
    1. Recent Activities
    2. Users Online
    3. Team
    4. Search Members
  • Login
  • Register
  • Search
This Thread
  • Everywhere
  • This Thread
  • This Forum
  • Forum
  • Pages
  • More Options
  1. IC² Forum
  2. Forum
  3. Archive
  4. IndustrialCraft²
IC2 Experimental builds (jenkins):
v2.0/2.1/2.2 / 2.3 / 2.5 / 2.6 / 2.7 / 2.8 (For Minecraft 1.6.4/1.7.2/1.7.10 / 1.8.9 / 1.9.4 / 1.10 / 1.11 / 1.12)
IndustrialCraft² recent version: v1.117!

Api Recipe Crash?

  • artman41
  • September 29, 2013 at 9:46 PM
1st Official Post
  • artman41
    Tree Cutter
    Posts
    4
    Location
    England, United Kingdom
    • September 29, 2013 at 9:46 PM
    • #1

    well, I'm currently trying to add in a recipe for a circuit for my mod. I want it to be able to create 2 circuits in the normal circuit recipe, replacing refined iron with rubies. However, I can't seem to get the output to be more than one and the code ALWAYS errors whenever I try and use .getitem() for insulated Copper Cable. Here is my code:

    Display Spoiler

    http://pastebin.com/Jkig9aRx

    Any help whatsoever would be helpful! Also, if you wish to be an even greater help, here is the Github Repo link: https://github.com/artman41/ICE

    • Quote
  • AGKz
    Lazer Technician
    Reactions Received
    3
    Posts
    54
    • September 29, 2013 at 10:24 PM
    • #2

    Correct me if I am wrong, but I do not think that is the correct way to add a recipe. What you are doing (simplified) is this:

    GameRegistry.addRecipe(outputItemStack, 2, intputObjects); That 2 is what is causing your problems. Remove it, and add this line of code:

    ItemStack circuit = new ItemStack(Items.getItem("electronicCircuit").getItem(), 2);

    Basically, we are extracting the item from IC2's ItemStack and then creating our own itemstack with 2 items in it.


    I have not tried this code, but it should work. Let me know

    So ya. Thats 'bout it.

    • Quote
  • AGKz
    Lazer Technician
    Reactions Received
    3
    Posts
    54
    • September 29, 2013 at 10:34 PM
    • #3

    Oh, I also just noticed you are putting your CopperCable into the crafting recipe as an ItemStack. It should be an Item. Just do CopperCable.getItem()

    I am using the experimental API, and it appears you have the CopperCable Item name incorrect. For my version (2.0.157 ex) it should be: insulatedCopperCableItem

    Here is the full code, tested this time:

    Code
    ItemStack circuit = new ItemStack(Items.getItem("electronicCircuit").getItem(), 2);
    	ItemStack CopperCable = Items.getItem("insulatedCopperCableItem");
    
    //      Creates a Electronic Circuit
            GameRegistry.addRecipe(circuit, new Object[]{
                "XXX",
                "RCR",
                "XXX",
                'C', Item.diamond, 'R', Item.redstone, 'X', CopperCable.getItem()
            });

    So ya. Thats 'bout it.

    • Quote
  • GregoriusT
    inactive IC² and GT Dev
    Reactions Received
    184
    Posts
    6,253
    Location
    not here anymore
    • September 29, 2013 at 10:36 PM
    • Official Post
    • #4

    As soon as Thunderdark makes Curcuits Metadata based, your Code wouldnt work AGKz.

    This is how you have to do it properly:

    ItemStack tStack = Items.getItem("electronicCircuit").copy(); // <-- The copy() is important!
    tStack.stackSize = 2;

    And then use the Stack.

    • Next Official Post
    • Quote
  • AGKz
    Lazer Technician
    Reactions Received
    3
    Posts
    54
    • September 29, 2013 at 10:38 PM
    • #5

    I was actually thinking about doing it that way, but thought the way I did it would be a little more simple and compact. Was not aware he was going to make it metadata based, good to know.

    So ya. Thats 'bout it.

    • Quote
  • GregoriusT
    inactive IC² and GT Dev
    Reactions Received
    184
    Posts
    6,253
    Location
    not here anymore
    • September 29, 2013 at 10:54 PM
    • Official Post
    • #6
    Quote from AGKz

    I was actually thinking about doing it that way, but thought the way I did it would be a little more simple and compact. Was not aware he was going to make it metadata based, good to know.

    It is just an assumption that he will do it, as he already did it to the other Resource Items.

    • Previous Official Post
    • Next Official Post
    • Quote
  • RawCode
    Lead Miner
    Reactions Received
    3
    Posts
    1,377
    • September 30, 2013 at 5:18 AM
    • #7

    there is no reason to use metadata for items, they have 32000 slots...

    as for code, Item and ItemStack is different classes, you cant typecast them directly, to evoid issues with API updates, i suggest to switch to reflections or reflection wrapper or unsafe (bad plan), since your imported API will cause issues after some time.

    • Quote
  • SpwnX
    Now busy with GTNH
    Reactions Received
    9
    Posts
    5,044
    Location
    Somewhere on Brazil
    • September 30, 2013 at 5:33 AM
    • Official Post
    • #8

    With 90+ mods adding thousands of items, i think metadata is really needed.
    What if BC decided to add its hundres of facades as one ID each, Forestry farm hatches, IC/GT plates ingots and blocks, and so on...

    rVhj4Q

    We need people to document GregTech, help us by joining the FTB wiki team: http://ftb.gamepedia.com/GregTech_6

    • Previous Official Post
    • Next Official Post
    • Quote
  • RawCode
    Lead Miner
    Reactions Received
    3
    Posts
    1,377
    • September 30, 2013 at 9:20 AM
    • #9

    it OK to add facades or similar items as single item with metadata, but not really good to merge completely different items into single ID.

    also merging items into single ID source is human factor errors, personally i see this as overcomplication.

    • Quote
  • SpwnX
    Now busy with GTNH
    Reactions Received
    9
    Posts
    5,044
    Location
    Somewhere on Brazil
    • September 30, 2013 at 9:55 AM
    • Official Post
    • #10

    Mostly, merged items are either just crafting components or have very similar functions.

    rVhj4Q

    We need people to document GregTech, help us by joining the FTB wiki team: http://ftb.gamepedia.com/GregTech_6

    • Previous Official Post
    • Quote
  • Epic Lulz
    Copper Miner
    Posts
    1,102
    Location
    The land of Hayo
    • September 30, 2013 at 11:28 AM
    • #11

    It would also be easier on the modpackers to change IDs, but that will not be a worry when 1.7 hits.

    • Quote
  • artman41
    Tree Cutter
    Posts
    4
    Location
    England, United Kingdom
    • September 30, 2013 at 3:46 PM
    • #12

    thanks for the help guys! Really Did help me with the error :D

    • Quote

Users Viewing This Thread

  • 1 Guest
  1. Privacy Policy
Powered by WoltLab Suite™