Jump to content

Custom smelting help


Recommended Posts

Hi guys, im trying to work out how i add a smelting recipe that can do the following. how can i make a recipe that could for say, smelt 9 iron ore into 1 iron block. now, the custom furnace i am making has 2 item inputs excluding the fuel slot




package naturemod.common.recipes;


import java.util.Arrays;

import java.util.HashMap;

import java.util.Map;


import naturemod.common.lib.NatureItems;

import net.minecraft.block.Block;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;


public class LabBenchRecipes


private static final LabBenchRecipes labBenchBase = new LabBenchRecipes();

private Map labBenchList;


public static final LabBenchRecipes labBench()


return labBenchBase;



private LabBenchRecipes()


labBenchList = new HashMap();

//Add a recipe (here: Stone,Grass->1Diamond)


addLabBenchRecipe(Item.lightStoneDust.itemID, NatureItems.ingotStrange.itemID, new ItemStack(Item.enderPearl));

addLabBenchRecipe(NatureItems.acrylicBottle.itemID, Item.diamond.itemID, new ItemStack(Item.ghastTear));

addLabBenchRecipe(NatureItems.oilDrop.itemID, Item.redstone.itemID, new ItemStack(Item.gunpowder));

addLabBenchRecipe(Item.beefRaw.itemID, Block.mushroomBrown.blockID, new ItemStack(Item.rottenFlesh));

addLabBenchRecipe(Item.chickenRaw.itemID, Block.mushroomBrown.blockID, new ItemStack(Item.rottenFlesh));

addLabBenchRecipe(Item.porkRaw.itemID, Block.mushroomBrown.blockID, new ItemStack(Item.rottenFlesh));

addLabBenchRecipe(Item.rottenFlesh.itemID, Item.eyeOfEnder.itemID, new ItemStack(Item.spiderEye));



* puts the recipe into a Hashmap

*@param input1 ItemID of the first item

*@param input2 ItemID of the second item

*@param output the ItemStack which gets created by the recipe


public void addLabBenchRecipe(int input1, int input2, ItemStack output)



StringBuffer sb= new StringBuffer(32);



labBenchList.put(sb.toString(), output);



public ItemStack getLabBenchResult(int input1,int input2)


StringBuffer sb= new StringBuffer(32);



return (ItemStack) labBenchList.get(sb.toString());



public Map getLabBenchList()


return labBenchList;



public Object getLabBenchResult(ItemStack item)


if (item == null)


            return null;


        ItemStack ret = (ItemStack)labBenchList.get(Arrays.asList(item.itemID, item.getItemDamage()));

        if (ret != null)


            return ret;


        return (ItemStack)labBenchList.get(Integer.valueOf(item.itemID));







can anybody help?

Link to comment
Share on other sites

You would have to have coordination between all of your classes of course. This could not be done using vanilla furnaces. You will need to store both the input ID (the id of an iron ore) along with an input quantity (in your case 9) in another hashmap. Then either make a note of when you are adding an iron ore recipe and make it check the quantity in your extra hashmap, or make all of your recipes check the quantity required. Then when you check if an item can be smelted, you have to pass in the itemstack, and if the quantity in that itemstack is larger than the quantity required, it can be smelted. Then when you are actually smelting you need to make a request to your recipe class asking how many of your item you need to perform the smelting operation, then subtract that amount from your input itemstack instead of just subtracting one.


Now I'm sure that didn't make any sense. I hope it did, but if not, I can try to explain better.

Read my thoughts on my summer mod work and tell me what you think!



I absolutely love her when she smiles

Link to comment
Share on other sites

hashmap are simply and purely overpowered...and also super easy to use

see heres how a hashmap work:


HashMap<Key, Storage> asd;

Key and storage are 2 object (such as Block, ItemStack, String wtv )  //note if you want to store primitive, you have to use their Object, int -> Integer, float -> Float etc


hashmap has a 0 argument constructor, you can use it


now here is the beauty of it


when placing stuff in a hashmap you will use the "put" method, it will require 1 Key and 1 Storage

exemple; String, EntityPlayerMP

hashMap.put("hydroflame", player);


the hashmap will place in its own internal structure a way to find the variable player super quickly if you give it "hydroflame"


you do thsi with the method "get(key)"



EntityPlayerMP player = playerMap.get("hydroflame");


in your case you might want to do something like


HashMap<Integer, Integer> smeltMap= new HashMap<Integer, Integer>();

//first integer behing the item id, second behing the amount required to smelt

//so you would add during construction of the smeltMap

smeltMap(Item.iron.id, 9);//note it might not be this exact syntax

//and then whenever someone put an item in your special furnace slot

int id = theIdFromTheSlot();

int qtyRequired = smeltMap.get(id);

if(qtyInSlot >= qtyRequired){





Cheers, welcome to the beautifull world of hashMap


-hydroflame, FRev-

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

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.

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.


  • Create New...

Important Information

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