Jump to content

Recommended Posts

Posted

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

Posted

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.

Posted

It doesn't look like you're calling

craftingmanager.removeRecipe

anywhere.

Because that doesn't exist maybe? :D 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.

Posted

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

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.

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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