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

Hello, I'm in the middle of updating my mod and the furnace seems to be working except for when it comes to the recipes. I'm a little stumped when trying to update this part and I'm not sure what to do since Minecraft now isn't based on IDs and such. Here's the code I'm working with:

package wintercraft.helper.gui;

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

import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

public class FreezerRecipes
{
private static final FreezerRecipes smeltingBase = new FreezerRecipes();
private HashMap<List<Integer>, ItemStack> metaSmeltingList = new HashMap<List<Integer>, ItemStack>();
private Map smeltingList = new HashMap();
private HashMap<List<Integer>, Float> metaExperience = new HashMap<List<Integer>, Float>();

/**
* Used to call methods addInscribing and getInscribingResult.
*/
public static final FreezerRecipes smelting() {
return smeltingBase;
}


/**
* Adds all recipes to the HashMap
*/
private FreezerRecipes()
{
//this.addSmelting(Arrays.asList(Item.sugar.itemID, 0, Item.bucketMilk.itemID, 0), new ItemStack(Items.commonItem.itemID, 4, 1), 0.3F);
//this.addSmelting(Arrays.asList(Items.commonItem.itemID, 1, Item.dyePowder.itemID, 3), new ItemStack(Items.commonItem.itemID, 1, 2), 0.3F);
this.addSmelting(Arrays.asList(Item.bucketWater.itemID, 0, Item.bucketWater.itemID, 0), new ItemStack(Block.ice.blockID, 4, 0), 0.2F);
//this.addSmelting(Arrays.asList(Items.commonItem.itemID, 1, Item.dyePowder.itemID, 1), new ItemStack(Items.commonItem.itemID, 1, 3), 0.3F);
//this.addSmelting(Arrays.asList(Items.commonItem.itemID, 1, Item.cookie.itemID, 0), new ItemStack(Items.commonItem.itemID, 1, 4), 0.3F);
//this.addSmelting(Arrays.asList(Items.commonItem.itemID, 1, Item.magmaCream.itemID, 0), new ItemStack(Items.commonItem.itemID, 1, 5), 0.3F);
//this.addSmelting(Arrays.asList(Items.rockySnowball.itemID, 0, Items.rockySnowball.itemID, 0), new ItemStack(Items.iceBall.itemID, 2, 0), 0.2F);
//this.addSmelting(Arrays.asList(Items.iceChunk.itemID, 0, Items.iceGem.itemID, 0), new ItemStack(Items.iceGem.itemID, 1, 1), 0.7F);
//this.addSmelting(Arrays.asList(Items.iceChunk.itemID, 0, Block.stone.blockID, 0), new ItemStack(Blocks.icedStone.blockID, 1, 0), 0.4F);
//this.addSmelting(Arrays.asList(Items.iceChunk.itemID, 0, Item.ingotIron.itemID, 0), new ItemStack(Items.iceIngot.itemID, 1, 0), 0.4F);
//this.addSmelting(Arrays.asList(Items.iceChunk.itemID, 0, Item.diamond.itemID, 0), new ItemStack(Items.iceCrystal.itemID, 1, 0), 0.4F);
}

public void addSmelting(List<Integer> items, ItemStack out, float experience)
{
metaSmeltingList.put(items, out);
metaExperience.put(Arrays.asList(out.itemID, out.getItemDamage()), experience);
}

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

/**
* Grabs the amount of base experience for this item to give when pulled from the furnace slot.
*/
public float getExperience(ItemStack item)
{
if (item == null || item.getItem() == null)
{
	return 0;
}
float ret = -1; // value returned by "item.getItem().getSmeltingExperience(item);" when item doesn't specify experience to give
if (ret < 0 && metaExperience.containsKey(Arrays.asList(item.itemID, item.getItemDamage())))
{
	ret = metaExperience.get(Arrays.asList(item.itemID, item.getItemDamage()));
}

return (ret < 0 ? 0 : ret);
}

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

 

or here:

http://pastebin.com/RA4BFWwe

 

What I'm really having trouble with is the 'addSmelting' method and how I'd go about fixing that. The rest I can manage.

If you need anything else just say so and thank you for any help that can provided.

  • Author

I do that but then get this error message:

 

The method addSmelting(List<Integer>, ItemStack, float) in the type FreezerRecipes is not applicable for the arguments (List<Object>, ItemStack, float)

 

at:

 

this.addSmelting(Arrays.asList(Item.bucketWater.itemID, 0, Item.bucketWater.itemID, 0), new ItemStack(Block.ice.blockID, 4, 0), 0.2F);

  • Author

I know this doesn't have anything to do with your last response but I have looked into it. Shouldn't this work?

public class FreezerRecipes
{
private static final FreezerRecipes smeltingBase = new FreezerRecipes();
//I changed this List to ItemStack instead of Integer.
private HashMap<List<ItemStack>, ItemStack> metaSmeltingList = new HashMap<List<ItemStack>, ItemStack>();
private Map smeltingList = new HashMap();
private HashMap<List<Integer>, Float> metaExperience = new HashMap<List<Integer>, Float>();


/**
* Used to call methods addInscribing and getInscribingResult.
*/
public static final FreezerRecipes smelting() {
return smeltingBase;
}


/**
* Adds all recipes to the HashMap
*/
private FreezerRecipes()
{
this.addSmelting(Arrays.asList(new ItemStack(Items.water_bucket, 1, 0),new ItemStack(Items.water_bucket, 1, 0)), new ItemStack(Blocks.ice, 4, 0), 0.2F);
}

public void addSmelting(List<ItemStack> items, ItemStack out, float experience)
{
smeltingList.put(items, out);
metaExperience.put(Arrays.asList(Item.getIdFromItem(out.getItem()), out.getItemDamage()), experience);
}

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

/**
* Grabs the amount of base experience for this item to give when pulled from the furnace slot.
*/
public float getExperience(ItemStack item)
{
if (item == null || item.getItem() == null)
{
	return 0;
}
float ret = -1; // value returned by "item.getItem().getSmeltingExperience(item);" when item doesn't specify experience to give
if (ret < 0 && metaExperience.containsKey(Arrays.asList(item, item.getItemDamage())))
{
	ret = metaExperience.get(Arrays.asList(item, item.getItemDamage()));
}

return (ret < 0 ? 0 : ret);
}

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

 

If there is no alternate way of doing this than I will go return to looking further into maps.

  • Author

Yeah true. I'll try reworking this some other way. Thanks for the help/tips though.

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.