gamer1097 Posted October 2, 2013 Posted October 2, 2013 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; } } Quote
gjgfuj Posted October 2, 2013 Posted October 2, 2013 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) Quote
GotoLink Posted October 2, 2013 Posted October 2, 2013 What is the point you can always access the actual list with getSmeltingList() in FurnaceRecipes. Quote
Mazetar Posted October 2, 2013 Posted October 2, 2013 Just wondering, is there an event which fires when stuff is crafted/smelted and can that be used to modify the output result? Quote If you guys dont get it.. then well ya.. try harder...
GotoLink Posted October 2, 2013 Posted October 2, 2013 @Mazetar No events, but an interface: ICraftingHandler Quote
Recommended Posts
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.