Posted March 24, 201411 yr FurnaceRecipes.smelting().getSmeltingList().remove(Blocks.iron_ore); This is how it was in 1.6.4 but then you had to put ".blockID" after iron_ore but now that IDs are not used in code this does not work anymore, if this not how you remove recipes anymore?
March 24, 201411 yr [Okay, while I was typing this, deiseiben07 posted.] FurnaceRecipes.smelting().getSmeltingList().remove(new ItemStack(Blocks.iron_ore)) will not work. The reason is simple if you understand hashmaps. The key is looked up in an array of hash buckets indexed by the hashCode() return value. Then, if the key is not equals(Object o) to the one to remove/add/get the object looks down to list or hash bucket and checks equals() again (some do a rehash, but not this implementation). Now to the actual reason it fails. No two new ItemStacks will generate the same hash (under normal circumstances.) So, every ItemStack will not match an existing key, and since ItemStack does not implement either hashCode() or equals(o), the Object (superclass) methods are used (they amount to the address of the instance as hashCode). If you put an ItemStack in the map, it stays but will never match anything but that exact reference, ever. You therefore must iterate through the recipes, check with ItemStack.areItemStacksEqual(s1, s2) -- yes, really slow... but the only way right now. -S- (if I helped, please click Thank and applaud) http://6upnqa.dm2301.livefilestore.com/y2mtf-vG7Tqq1TiiVpIm53KWj7294NDPoHfSHHb4PzZiMAUfRCfK0UY0MwOu7Q3zTBNVTKqWjr2-xgBfFRpQT5p-QivtvknPpoABMNUw9br9WuZcBFkjePhnAbW500gVm-P/sequiturian.png[/img]
March 24, 201411 yr Author This is what I did for removing crafting recipes static void removeRecipesWithResult(ItemStack resultItem) { ArrayList recipes = (ArrayList) CraftingManager.getInstance().getRecipeList(); for (int scan = 0; scan < recipes.size(); scan++) { IRecipe tmpRecipe = (IRecipe) recipes.get(scan); if (ItemStack.areItemStacksEqual(resultItem, tmpRecipe.getRecipeOutput())) { recipes.remove(scan); }//if }//for }//removeRecipesWithResult This is what I am trying to do for removing furnace recipes, is there a furnace equivalent to IRecipe? static void removeFurnaceRecipeWithResult(ItemStack resultItem) { java.util.Map recipes = FurnaceRecipes.smelting().getSmeltingList(); for (int scan = 0; scan < recipes.size(); scan++) { if (ItemStack.areItemStacksEqual(resultItem, [b][/b]) { recipes.remove(scan); } } }//removeFurnaceRecipeWithResult
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.