Jump to content

How would i add crafting recipes to a custom crafting table


cammygames

Recommended Posts

ok i have the recipe list, the manager ,inventory,inv result i want to make it so

that when i put a certain recipe in the compactor it shows but all i have at the moment is a blank useless crafting gui inside the compactor what i want to know is how would i register the recipe's to the compactor like make the crafting result display when you put a defined recipe in

Link to comment
Share on other sites

ok i have had a look and changed it to what i think is correct but it gives an error in the Compactor manager this is my code

 

package net.minecraft.src;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

public class CompactorManager
{
    /** The static instance of this class */
    private static final CompactorManager instance = new CompactorManager();

    /** A list of all the recipes added */
    private List recipes = new ArrayList();

    /**
     * Returns the static instance of this class
     */
    public static final CompactorManager getInstance()
    {
        return instance;
    }

    private CompactorManager()
    {
        this.addRecipe(new ItemStack(mod_Blastcraft.blastwall), new Object[]{"@#@","@#@","@#@",Character.valueOf('#'),mod_Blastcraft.rebarmesh,Character.valueOf('@'),Block.brick});       
        System.out.println(this.recipes.size() + " recipes");
    }

    /**
     * Adds a recipe. See spreadsheet on first page for details.
     */
    void addRecipe(ItemStack par1ItemStack, Object ... par2ArrayOfObj)
    {
        String var3 = "";
        int var4 = 0;
        int var5 = 0;
        int var6 = 0;

        if (par2ArrayOfObj[var4] instanceof String[])
        {
            String[] var7 = (String[])((String[])par2ArrayOfObj[var4++]);

            for (int var8 = 0; var8 < var7.length; ++var8)
            {
                String var9 = var7[var8];
                ++var6;
                var5 = var9.length();
                var3 = var3 + var9;
            }
        }
        else
        {
            while (par2ArrayOfObj[var4] instanceof String)
            {
                String var11 = (String)par2ArrayOfObj[var4++];
                ++var6;
                var5 = var11.length();
                var3 = var3 + var11;
            }
        }

        HashMap var12;

        for (var12 = new HashMap(); var4 < par2ArrayOfObj.length; var4 += 2)
        {
            Character var13 = (Character)par2ArrayOfObj[var4];
            ItemStack var14 = null;

            if (par2ArrayOfObj[var4 + 1] instanceof Item)
            {
                var14 = new ItemStack((Item)par2ArrayOfObj[var4 + 1]);
            }
            else if (par2ArrayOfObj[var4 + 1] instanceof Block)
            {
                var14 = new ItemStack((Block)par2ArrayOfObj[var4 + 1], 1, -1);
            }
            else if (par2ArrayOfObj[var4 + 1] instanceof ItemStack)
            {
                var14 = (ItemStack)par2ArrayOfObj[var4 + 1];
            }

            var12.put(var13, var14);
        }

        ItemStack[] var15 = new ItemStack[var5 * var6];

        for (int var16 = 0; var16 < var5 * var6; ++var16)
        {
            char var10 = var3.charAt(var16);

            if (var12.containsKey(Character.valueOf(var10)))
            {
                var15[var16] = ((ItemStack)var12.get(Character.valueOf(var10))).copy();
            }
            else
            {
                var15[var16] = null;
            }
        }

        this.recipes.add(new ShapedRecipes(var5, var6, var15, par1ItemStack));
    }

    public ItemStack findMatchingRecipe(Inventorycompactor par1InventoryCrafting)
    {
        int var2 = 0;
        ItemStack var3 = null;
        ItemStack var4 = null;
        int var5;

        for (var5 = 0; var5 < par1InventoryCrafting.getSizeInventory(); ++var5)
        {
            ItemStack var6 = par1InventoryCrafting.getStackInSlot(var5);

            if (var6 != null)
            {
                if (var2 == 0)
                {
                    var3 = var6;
                }

                if (var2 == 1)
                {
                    var4 = var6;
                }

                ++var2;
            }
        }

        if (var2 == 2 && var3.itemID == var4.itemID && var3.stackSize == 1 && var4.stackSize == 1 && Item.itemsList[var3.itemID].isRepairable())
        {
            Item var11 = Item.itemsList[var3.itemID];
            int var10 = var11.getMaxDamage() - var3.getItemDamageForDisplay();
            int var7 = var11.getMaxDamage() - var4.getItemDamageForDisplay();
            int var8 = var10 + var7 + var11.getMaxDamage() * 10 / 100;
            int var9 = var11.getMaxDamage() - var8;

            if (var9 < 0)
            {
                var9 = 0;
            }

            return new ItemStack(var3.itemID, 1, var9);
        }
        else
        {
            for (var5 = 0; var5 < this.recipes.size(); ++var5)
            {
                IRecipe var12 = (IRecipe)this.recipes.get(var5);

                if (var12.matches(par1InventoryCrafting))
                {
                    return var12.getCraftingResult(par1InventoryCrafting);
                }
            }

            return null;
        }
    }

    /**
     * returns the List<> of all recipes
     */
    public List getRecipeList()
    {
        return this.recipes;
    }
}

 

it give the error at this section of code

                if (var12.matches(par1InventoryCrafting))
                {
                    return var12.getCraftingResult(par1InventoryCrafting);
                }

do i need to make my own IRecipe?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.