Posted August 9, 201510 yr Over some time now, I have been learning java coding and been working on a mod for Minecraft 1.7.10. Every thing is working find and I understand most of it, but for some reason does my code, which should remove recipes from Minecraft, not work. Hope anyone can help me import java.util.Iterator; import java.util.List; import com.fantasymod.Item.ItemCreator; import com.fantasymod.blocks.BlockCreator; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.IRecipe; import cpw.mods.fml.common.registry.GameRegistry; public class craftingmanager { public static void mainRegistry(){ addCraftingRec(); addSmeltingRec(); } public static void addCraftingRec(){ //shaped GameRegistry.addRecipe(new ItemStack(BlockCreator.bronzeblock, 1), new Object[]{"XXX","XXX","XXX", 'X', ItemCreator.bronzeingot}); GameRegistry.addRecipe(new ItemStack(Blocks.wool, 1), new Object[]{"XX ","XX "," ", 'X', ItemCreator.cotton}); GameRegistry.addRecipe(new ItemStack(ItemCreator.bronzehelmet, 1), new Object[]{"XXX","X X"," ", 'X', ItemCreator.bronzeingot}); GameRegistry.addRecipe(new ItemStack(ItemCreator.bronzechest, 1), new Object[]{"X X","XXX","XXX", 'X', ItemCreator.bronzeingot}); GameRegistry.addRecipe(new ItemStack(ItemCreator.bronzepants, 1), new Object[]{"XXX","X X","X X", 'X', ItemCreator.bronzeingot}); GameRegistry.addRecipe(new ItemStack(ItemCreator.bronzeboots, 1), new Object[]{" ","X X","X X", 'X', ItemCreator.bronzeingot}); //shapeless } public static void addSmeltingRec(){ GameRegistry.addSmelting(BlockCreator.bronzeore, new ItemStack(ItemCreator.bronzeingot, 1), 0.0f); } public static void removeRecipe(){ Iterator<IRecipe> remover = CraftingManager.getInstance().getRecipeList().iterator(); while(remover.hasNext()){ ItemStack itemstack = remover.next().getRecipeOutput(); if(itemstack.getItem() == Item.getItemFromBlock(Blocks.furnace)){ remover.remove(); }else if (itemstack.getItem() == Items.bread){ remover.remove(); } } } } this package is being called from my main package with @EventHandler public static void Load(FMLInitializationEvent event){ craftingmanager.mainRegistry(); }
August 9, 201510 yr It doesn't look like you're calling craftingmanager.removeRecipe anywhere. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
August 9, 201510 yr It doesn't look like you're calling craftingmanager.removeRecipe anywhere. Because that doesn't exist maybe? Removing from the Iterator changes the underlying List, so this should work just fine. I'm talking about the removeRecipe method in the code the OP posted, not the vanilla CraftingManager class. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
August 9, 201510 yr Author so it crashed, but after adding "itemstack != null" in my if statement, the problem solved and it is working fine now. Thank you for pointing it out, I can't believe I missed that if(itemstack != null && itemstack.getItem() == Item.getItemFromBlock(Blocks.furnace)){ remover.remove(); }else if (itemstack != null && itemstack.getItem() == Items.bread){ remover.remove(); }
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.