Jump to content

Trying to double all smelting recipes including modded items help!


gamer1097

Recommended Posts

Ok basically my problem is that i'm trying to double all smelted items output. This code I have works for all vanilla items. But doesn't seem to work for modded items even though I'm getting a instance FurnaceRecipes and that is what Mod others use to make new smelting recipes.

 

 

Heres my code

 

 

 

package mods.gamersmods.fuelresourceful.Recipes;

import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import mods.gamersmods.fuelresourceful.block.BlockManager;
import mods.gamersmods.fuelresourceful.item.ItemManager;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraftforge.oredict.OreDictionary;

public class SmelteryRecipes
{
    private static final SmelteryRecipes smeltingBase = new SmelteryRecipes();

    /** The list of smelting results. */
    private Map smeltingList = new HashMap();
    private HashMap<List<Integer>, ItemStack> metaSmeltingList = new HashMap<List<Integer>, ItemStack>();

    /**
     * Used to call methods addSmelting and getSmeltingResult.
     */
    public static final SmelteryRecipes smelting()
    {
        return smeltingBase;
    }
    
    public void addAllRecipes()
    {
    	Map smelt = FurnaceRecipes.smelting().getSmeltingList();
    	
    	for(int i = 0; i < smelt.size(); i++)
    	{
    		if(smelt.get(i) != null)
    		{
    			ItemStack stack = ((ItemStack) smelt.get(i)).copy();
    			stack.stackSize *= 2;
    			smeltingList.put(i, stack);
    		}
    	}
    }

    /**
     * Adds a smelting recipe.
     */
    public void addSmelting(int par1, ItemStack par2ItemStack, float par3)
    {
        this.smeltingList.put(Integer.valueOf(par1), par2ItemStack);
    }

    /**
     * Returns the smelting result of an item.
     * Deprecated in favor of a metadata sensitive version
     */
    @Deprecated
    public ItemStack getSmeltingResult(int par1)
    {
        return (ItemStack)this.smeltingList.get(Integer.valueOf(par1));
    }

    public Map getSmeltingList()
    {
        return this.smeltingList;
    }

    /**
     * A metadata sensitive version of adding a furnace recipe.
     */
    public void addSmelting(int itemID, int metadata, ItemStack itemstack, float experience)
    {
        metaSmeltingList.put(Arrays.asList(itemID, metadata), itemstack);
    }

    /**
     * Used to get the resulting ItemStack form a source ItemStack
     * @param item The Source ItemStack
     * @return The result ItemStack
     */
    public ItemStack getSmeltingResult(ItemStack item) 
    {
        if (item == null)
        {
            return null;
        }
        ItemStack ret = (ItemStack)metaSmeltingList.get(Arrays.asList(item.itemID, item.getItemDamage()));
        if (ret != null) 
        {
            return ret;
        }
        return (ItemStack)smeltingList.get(Integer.valueOf(item.itemID));
    }

    public Map<List<Integer>, ItemStack> getMetaSmeltingList()
    {
        return metaSmeltingList;
    }
}

 

 

Link to comment
Share on other sites

where are you calling addAllRecipes? because you'll probably want to call that in your mod's post init method so other mods can register their recipes before you add them. Or, a better approach would be to access the FurnaceRecipes from the getFurnaceResult. get the result from FurnaceRecipes, double the stack size, then return it. use the exact code from the for loop in your addAllRecipes method, but instead of getting the recipe from the list, call

FurnaceRecipes.smelting().getSmeltingResult(itemStack)

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.