Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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;
    }
}

 

 

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)

Just wondering, is there an event which fires when stuff is crafted/smelted and can that be used to modify the output result?

If you guys dont get it.. then well ya.. try harder...

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.