Jump to content

Item damage on crafting


mydeblob

Recommended Posts

Ya ya, im sure you get ton of these threads, but for some reason this isn't working. Im using forge 1.6.2, and I want an item to take 1 damage out of 64 when used to craft something. I made some code for it but I can only use it 3 times before it won't let me craft anymore but the item still has durability. Thanks for your help.

Base Mod class (the knife item is the one that should be able to be used more than once)

 

package mydeblob.mineedibles;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemSeeds;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.PostInit;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;

@Mod(modid="mineedibles", name="MineEdibles", version="1.0.0")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class MineEdibles {


        // The instance of your mod that Forge uses.
        @Instance("Sandwich")
        public static MineEdibles instance;
        private static Item breadslice;
        private static Item chickensandwich;
        private static Item steaksandwich;
        private static Item hamsandwich;
        private static Item supersandwich;
        private static Item chickenbit;
        private static Item steakbit;
        private static Item porkbit;
        public static Item tomatoseeds;
        public static Item tomatofruit;
        public static Block tomatocrop;
        public static Item rawbacon;
        private static Item cookedbacon;
        private static Item rawchickenbit;
        private static Item rawsteakbit;
        private static Item rawporkbit;
        public static Item knife;
        
        //Item Ids for the config file
        int breadsliceID;
        int chickensandwichID;
        int steaksandwichID;
        int hamsandwichID;
        int supersandwichID;
        int chickenbitID;
        int steakbitID;
        int porkbitID;
        int tomatoseedsID;
        int tomatocropID;
        int tomatofruitID;
        int rawbaconID;
        int cookedbaconID;
        int rawchickenbitID;
        int rawsteakbitID;
        int rawporkbitID;
        int knifeID;

        
        // Says where the client and server 'proxy' code is loaded.
        @SidedProxy(clientSide="mydeblob.mineedibles.client.ClientProxy", serverSide="mydeblob.mineedibles.CommonProxy")
        public static CommonProxy proxy;
        
        @EventHandler
        public void preInit(FMLPreInitializationEvent event) {
        	//Basic Configuration file
        	Configuration config = new Configuration(event.getSuggestedConfigurationFile());
        	config.load();
        	breadsliceID = config.get("Item IDs", "Bread Slice", 5000).getInt();
        	chickensandwichID = config.get("Item IDs", "Chicken Sandwich", 5001).getInt();
        	steaksandwichID = config.get("Item IDs", "Steak Sandwich", 5002).getInt();
        	hamsandwichID = config.get("Item IDs", "Ham Sandwich", 5003).getInt();
        	supersandwichID = config.get("Item IDs", "Super Sandwich", 5004).getInt();
        	chickenbitID = config.get("Item IDs", "Slice of Chicken", 5005).getInt();
        	steakbitID = config.get("Item IDs", "Slice of Steak", 5006).getInt();
        	porkbitID = config.get("Item IDs", "Slice of Pork", 5007).getInt();
        	tomatoseedsID = config.get("Item IDs", "Tomato Seeds", 5008).getInt();
        	tomatofruitID = config.get("Item IDs", "Tomato Fruit", 5009).getInt();
        	rawbaconID = config.get("Item IDs", "Raw Bacon", 50010).getInt();
        	cookedbaconID = config.get("Item IDs", "Cooked Bacon", 5011).getInt();
        	rawchickenbitID = config.get("Item IDs", "Raw Slice of Chicken", 5012).getInt();
        	rawsteakbitID = config.get("Item IDs", "Raw Slice of Beef", 5013).getInt();
        	rawporkbitID = config.get("Item IDs", "Raw Slice of Ham", 5014).getInt();
        	knifeID = config.get("Item IDs", "Knife", 5015).getInt();
        	config.save();
        }
        
        @EventHandler
        public void load(FMLInitializationEvent event) {
                proxy.registerRenderers();
                //Items
               breadslice = new Item(breadsliceID).setUnlocalizedName("breadslice").setMaxStackSize(64).setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:slicebread");
               chickensandwich = new ItemFood(chickensandwichID, 9, 0.8f, false).setPotionEffect(Potion.moveSpeed.id, 4, 0, 0.8f).setUnlocalizedName("chickensandwich").setMaxStackSize(64).setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:chickensandwich");
               steaksandwich = new ItemFood(steaksandwichID, 9, 0.8f, false).setPotionEffect(Potion.moveSpeed.id, 4, 0, 0.8f).setUnlocalizedName("steaksandwich").setMaxStackSize(64).setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:steaksandwich");
               hamsandwich = new ItemFood(hamsandwichID, 9, 0.8f, false).setPotionEffect(Potion.moveSpeed.id, 4, 0, 0.8f).setUnlocalizedName("hamsandwich").setMaxStackSize(64).setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:hamsandwich");
               supersandwich = new ItemFood(supersandwichID, 18, 1.4f, false).setAlwaysEdible().setPotionEffect(Potion.regeneration.id, 6, 1, 0.8f).setPotionEffect(Potion.moveSpeed.id, 6, 1, 0.8f).setUnlocalizedName("supersandwich").setMaxStackSize(64).setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:supersandwich");
               chickenbit = new ItemFood(chickenbitID, 2, 0.4f, false).setUnlocalizedName("chickenbit").setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:chickenbit");
               steakbit = new ItemFood(steakbitID, 2, 0.4f, false).setUnlocalizedName("steakbit").setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:steakbit");
               porkbit = new ItemFood(porkbitID, 2, 0.4f, false).setUnlocalizedName("porkbit").setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:porkbit");
               tomatocrop = new TomatoCrop(tomatocropID).setUnlocalizedName("tomatocrop").func_111022_d("mineedibles:tomatocrop");
               tomatoseeds = new ItemSeeds(tomatoseedsID, tomatocrop.blockID, Block.tilledField.blockID).setUnlocalizedName("tomatoseeds").func_111206_d("mineedibles:tomatoseeds");
               tomatofruit = new ItemFood(tomatofruitID, 6, 0.8f, false).setUnlocalizedName("tomatofruit").func_111206_d("mineedibles:tomatofruit");
               rawbacon = new ItemFood(rawbaconID, 3, 0.3f, false).setUnlocalizedName("baconraw").setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:rawbacon");
               cookedbacon = new ItemFood(cookedbaconID, 7, 0.6f, false).setUnlocalizedName("baconcooked").setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:cookedbacon");
               rawchickenbit = new ItemFood(rawchickenbitID, 1, 0.2f, false).setUnlocalizedName("rawchickenbit").setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:rawchickenbit");
               rawsteakbit = new ItemFood(rawsteakbitID, 1, 0.2f, false).setUnlocalizedName("rawsteakbit").setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:rawsteakbit");
               rawporkbit = new ItemFood(rawporkbitID, 1, 0.2f, false).setUnlocalizedName("rawporkbit").setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:rawporkbit");
               knife = new Item(knifeID).setUnlocalizedName("knife").setMaxDamage(64).setMaxStackSize(1).setCreativeTab(CreativeTabs.tabTools).func_111206_d("mineedibles:knifeBlack");
               MinecraftForge.addGrassSeed(new ItemStack (tomatoseeds), 10);
               gameRegisters();
               languageRegisters();
               craftingRecipes();
               	//Smelting
               GameRegistry.addSmelting(MineEdibles.rawbacon.itemID, new ItemStack(MineEdibles.cookedbacon, 1), 0.1f);
               GameRegistry.addSmelting(MineEdibles.rawchickenbit.itemID, new ItemStack(MineEdibles.chickenbit, 1), 0.1f);
               GameRegistry.addSmelting(MineEdibles.rawsteakbit.itemID, new ItemStack(MineEdibles.steakbit, 1), 0.1f);
               GameRegistry.addSmelting(MineEdibles.rawporkbit.itemID, new ItemStack(MineEdibles.porkbit, 1), 0.1f);




        }

        //Item and Block registeration
        private static void gameRegisters(){
        	GameRegistry.registerItem(breadslice, "Bread Slice");
        	GameRegistry.registerItem(chickensandwich, "Chicken Sandwich");
        	GameRegistry.registerItem(steaksandwich, "Steak Sandwich");
        	GameRegistry.registerItem(hamsandwich, "Ham Sandwich");
        	GameRegistry.registerItem(supersandwich, "Super Sandwich");
        	GameRegistry.registerItem(chickenbit, "Slice of Chicken");
        	GameRegistry.registerItem(steakbit, "Slice of Steak");
        	GameRegistry.registerItem(porkbit, "Slice of Ham");
        	GameRegistry.registerItem(tomatoseeds, "Tomato Seeds");
        	GameRegistry.registerItem(tomatofruit, "Tomato");
        	GameRegistry.registerBlock(tomatocrop, "Tomato Crop");
        	GameRegistry.registerItem(rawbacon, "Raw Bacon");
        	GameRegistry.registerItem(cookedbacon, "Cooked Bacon");
        	GameRegistry.registerItem(rawchickenbit, "Raw Slice of Chicken");
        	GameRegistry.registerItem(rawsteakbit, "Raw Slice of Steak");
        	GameRegistry.registerItem(rawporkbit, "Raw Slice of Ham");
        	GameRegistry.registerItem(knife, "Knife");
        	GameRegistry.registerCraftingHandler(new KnifeCraftingHandler());
        }
        //Item and Block in game name, languageregistry
        private static void languageRegisters(){
        	LanguageRegistry.addName(breadslice, "Bread Slice");
        	LanguageRegistry.addName(chickensandwich, "Chicken Sandwich");
        	LanguageRegistry.addName(steaksandwich, "Steak Sandwich");
        	LanguageRegistry.addName(hamsandwich, "Ham Sandwich");
        	LanguageRegistry.addName(supersandwich, "Super Sandwich");
        	LanguageRegistry.addName(chickenbit, "Slice of Chicken");
        	LanguageRegistry.addName(steakbit, "Slice of Steak");
        	LanguageRegistry.addName(porkbit, "Slice of Ham");
        	LanguageRegistry.addName(tomatoseeds, "Tomato Seeds");
        	LanguageRegistry.addName(tomatofruit, "Tomato");
        	LanguageRegistry.addName(rawbacon, "Raw Bacon");
        	LanguageRegistry.addName(rawchickenbit, "Raw Slice of Chicken");
        	LanguageRegistry.addName(rawsteakbit, "Raw Slice of Steak");
        	LanguageRegistry.addName(rawporkbit, "Raw Slice of Ham");
        	LanguageRegistry.addName(knife, "Knife");
        }
        //Crafting Recipes
        public void craftingRecipes(){
        	//Cooked meat slices
        	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.breadslice, 6), new ItemStack(ItemFood.bread));
        	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.chickenbit, 3), new Object[]{ItemFood.chickenCooked, (new ItemStack(knife, 1, 0 ))});
        	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.steakbit, 3), new Object[]{ItemFood.beefCooked, (new ItemStack(knife, 1, 0))});
        	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.porkbit, 3), new Object[]{ItemFood.porkCooked, (new ItemStack(knife, 1, 0))});
        	//Raw Meat Slices
        	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.rawchickenbit, 3), new Object[]{ItemFood.chickenRaw, (new ItemStack(knife, 1, 0))});
        	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.rawsteakbit, 3), new Object[]{ItemFood.beefRaw, (new ItemStack(knife, 1, 0))});
        	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.rawporkbit, 3), new Object[]{ItemFood.porkRaw, (new ItemStack(knife, 1, 0))});
        	//Sandwiches
        	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.rawchickenbit, 3), new ItemStack(ItemFood.chickenRaw));
        	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.rawsteakbit, 3), new ItemStack(ItemFood.beefRaw));
        	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.rawporkbit, 3), new ItemStack(ItemFood.porkRaw));
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.chickensandwich, 1), new Object[]{" B ", " C ", " B ", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked });
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.steaksandwich, 1), new Object[]{" B ", " S ", " B ", 'B', MineEdibles.breadslice, 'S', ItemFood.beefCooked});
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.hamsandwich, 1), new Object[]{" B ", " P ", " B ", 'B', MineEdibles.breadslice, 'P', ItemFood.porkCooked});
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "CSP", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "SCP", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "PSC", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "SPC", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "PSC", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "CPS", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "CSP", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "CPS", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
        
        	
        }
        @EventHandler
        public void postInit(FMLPostInitializationEvent event) {
                
        }
}

 

CraftingHandlerClass for the Item Knife

 

package mydeblob.mineedibles;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.ICraftingHandler;

public class KnifeCraftingHandler implements ICraftingHandler {

@Override
public void onCrafting(EntityPlayer player, ItemStack item,
		IInventory craftMatrix) {
	for (int i = 0; i < craftMatrix.getSizeInventory(); i++) {

		if (craftMatrix.getStackInSlot(i) != null) {
			ItemStack j = craftMatrix.getStackInSlot(i);

			if (j.getItem() != null && j.getItem() == MineEdibles.knife) {
				ItemStack k = new ItemStack(MineEdibles.knife, 2, (j.getItemDamage() + 1));

				if (k.getItemDamage() >= k.getMaxDamage()) {
					k.stackSize--;
				}
				craftMatrix.setInventorySlotContents(i, k);
			}
		}
	}

}

@Override
public void onSmelting(EntityPlayer player, ItemStack item) {
	// TODO Auto-generated method stub

}

}

 

Link to comment
Share on other sites

No need for a crafting handler. In your ItemKnife.java:

 

@Override
public ItemStack getContainerItemStack(ItemStack itemStack)
{
	int alter = itemStack.getItemDamage() - 1;
	if(alter >= itemStack.getMaxDamage())
	{
		return null;
	}
	itemStack.setItemDamage(alter);
	return itemStack;
}

 

Will return the same stack that was used with the damage minus 1. If the changed damage is greater/equal compared to the maximum allowed damage, will 'break' the item by returning null.

Link to comment
Share on other sites

Ok, I must be doing something wrong... I copied your code, and removed the craftinghandler class and now when I use the knife to craft something it allows me to use it once and then it disappears. Here is the new code

ItemKnife Class

 

package mydeblob.mineedibles;

import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.block.BlockCocoa;
import net.minecraft.block.BlockColored;
import net.minecraft.block.BlockCrops;
import net.minecraft.block.BlockDirectional;
import net.minecraft.block.BlockLog;
import net.minecraft.block.BlockMushroom;
import net.minecraft.block.BlockSapling;
import net.minecraft.block.BlockStem;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.FakePlayerFactory;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.Event.Result;
import net.minecraftforge.event.entity.player.BonemealEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class ItemKnife extends Item
{

public ItemKnife(int par1) {
	super(par1);
	setMaxDamage(64);
	setMaxStackSize(1);
	setCreativeTab(CreativeTabs.tabTools);
}
@Override
public ItemStack getContainerItemStack(ItemStack itemStack)
{
	int alter = itemStack.getItemDamage() - 1;
	if(alter >= itemStack.getMaxDamage())
	{
		return null;
	}
	itemStack.setItemDamage(alter);
	return itemStack;
}
    
}

 

MainClass

 

package mydeblob.mineedibles;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemSeeds;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.PostInit;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;

@Mod(modid="mineedibles", name="MineEdibles", version="1.0.0")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class MineEdibles {


        // The instance of your mod that Forge uses.
        @Instance("Sandwich")
        public static MineEdibles instance;
        private static Item breadslice;
        private static Item chickensandwich;
        private static Item steaksandwich;
        private static Item hamsandwich;
        private static Item supersandwich;
        private static Item chickenbit;
        private static Item steakbit;
        private static Item porkbit;
        public static Item tomatoseeds;
        public static Item tomatofruit;
        public static Block tomatocrop;
        public static Item rawbacon;
        private static Item cookedbacon;
        private static Item rawchickenbit;
        private static Item rawsteakbit;
        private static Item rawporkbit;
        public static Item knife;
        
        //Item Ids for the config file
        int breadsliceID;
        int chickensandwichID;
        int steaksandwichID;
        int hamsandwichID;
        int supersandwichID;
        int chickenbitID;
        int steakbitID;
        int porkbitID;
        int tomatoseedsID;
        int tomatocropID;
        int tomatofruitID;
        int rawbaconID;
        int cookedbaconID;
        int rawchickenbitID;
        int rawsteakbitID;
        int rawporkbitID;
        int knifeID;

        
        // Says where the client and server 'proxy' code is loaded.
        @SidedProxy(clientSide="mydeblob.mineedibles.client.ClientProxy", serverSide="mydeblob.mineedibles.CommonProxy")
        public static CommonProxy proxy;
        
        @EventHandler
        public void preInit(FMLPreInitializationEvent event) {
        	//Basic Configuration file
        	Configuration config = new Configuration(event.getSuggestedConfigurationFile());
        	config.load();
        	breadsliceID = config.get("Item IDs", "Bread Slice", 5000).getInt();
        	chickensandwichID = config.get("Item IDs", "Chicken Sandwich", 5001).getInt();
        	steaksandwichID = config.get("Item IDs", "Steak Sandwich", 5002).getInt();
        	hamsandwichID = config.get("Item IDs", "Ham Sandwich", 5003).getInt();
        	supersandwichID = config.get("Item IDs", "Super Sandwich", 5004).getInt();
        	chickenbitID = config.get("Item IDs", "Slice of Chicken", 5005).getInt();
        	steakbitID = config.get("Item IDs", "Slice of Steak", 5006).getInt();
        	porkbitID = config.get("Item IDs", "Slice of Pork", 5007).getInt();
        	tomatoseedsID = config.get("Item IDs", "Tomato Seeds", 5008).getInt();
        	tomatofruitID = config.get("Item IDs", "Tomato Fruit", 5009).getInt();
        	rawbaconID = config.get("Item IDs", "Raw Bacon", 50010).getInt();
        	cookedbaconID = config.get("Item IDs", "Cooked Bacon", 5011).getInt();
        	rawchickenbitID = config.get("Item IDs", "Raw Slice of Chicken", 5012).getInt();
        	rawsteakbitID = config.get("Item IDs", "Raw Slice of Beef", 5013).getInt();
        	rawporkbitID = config.get("Item IDs", "Raw Slice of Ham", 5014).getInt();
        	knifeID = config.get("Item IDs", "Knife", 5015).getInt();
        	config.save();
        }
        
        @EventHandler
        public void load(FMLInitializationEvent event) {
                proxy.registerRenderers();
                //Items
               breadslice = new Item(breadsliceID).setUnlocalizedName("breadslice").setMaxStackSize(64).setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:slicebread");
               chickensandwich = new ItemFood(chickensandwichID, 9, 0.8f, false).setPotionEffect(Potion.moveSpeed.id, 4, 0, 0.8f).setUnlocalizedName("chickensandwich").setMaxStackSize(64).setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:chickensandwich");
               steaksandwich = new ItemFood(steaksandwichID, 9, 0.8f, false).setPotionEffect(Potion.moveSpeed.id, 4, 0, 0.8f).setUnlocalizedName("steaksandwich").setMaxStackSize(64).setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:steaksandwich");
               hamsandwich = new ItemFood(hamsandwichID, 9, 0.8f, false).setPotionEffect(Potion.moveSpeed.id, 4, 0, 0.8f).setUnlocalizedName("hamsandwich").setMaxStackSize(64).setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:hamsandwich");
               supersandwich = new ItemFood(supersandwichID, 18, 1.4f, false).setAlwaysEdible().setPotionEffect(Potion.regeneration.id, 6, 1, 0.8f).setPotionEffect(Potion.moveSpeed.id, 6, 1, 0.8f).setUnlocalizedName("supersandwich").setMaxStackSize(64).setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:supersandwich");
               chickenbit = new ItemFood(chickenbitID, 2, 0.4f, false).setUnlocalizedName("chickenbit").setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:chickenbit");
               steakbit = new ItemFood(steakbitID, 2, 0.4f, false).setUnlocalizedName("steakbit").setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:steakbit");
               porkbit = new ItemFood(porkbitID, 2, 0.4f, false).setUnlocalizedName("porkbit").setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:porkbit");
               tomatocrop = new TomatoCrop(tomatocropID).setUnlocalizedName("tomatocrop").func_111022_d("mineedibles:tomatocrop");
               tomatoseeds = new ItemSeeds(tomatoseedsID, tomatocrop.blockID, Block.tilledField.blockID).setUnlocalizedName("tomatoseeds").func_111206_d("mineedibles:tomatoseeds");
               tomatofruit = new ItemFood(tomatofruitID, 6, 0.8f, false).setUnlocalizedName("tomatofruit").func_111206_d("mineedibles:tomatofruit");
               rawbacon = new ItemFood(rawbaconID, 3, 0.3f, false).setUnlocalizedName("baconraw").setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:rawbacon");
               cookedbacon = new ItemFood(cookedbaconID, 7, 0.6f, false).setUnlocalizedName("baconcooked").setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:cookedbacon");
               rawchickenbit = new ItemFood(rawchickenbitID, 1, 0.2f, false).setUnlocalizedName("rawchickenbit").setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:rawchickenbit");
               rawsteakbit = new ItemFood(rawsteakbitID, 1, 0.2f, false).setUnlocalizedName("rawsteakbit").setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:rawsteakbit");
               rawporkbit = new ItemFood(rawporkbitID, 1, 0.2f, false).setUnlocalizedName("rawporkbit").setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:rawporkbit");
               knife = new ItemKnife(knifeID).setUnlocalizedName("knife").func_111206_d("mineedibles:knifeBlack");
               MinecraftForge.addGrassSeed(new ItemStack (tomatoseeds), 10);
               gameRegisters();
               languageRegisters();
               craftingRecipes();
               	//Smelting
               GameRegistry.addSmelting(MineEdibles.rawbacon.itemID, new ItemStack(MineEdibles.cookedbacon, 1), 0.1f);
               GameRegistry.addSmelting(MineEdibles.rawchickenbit.itemID, new ItemStack(MineEdibles.chickenbit, 1), 0.1f);
               GameRegistry.addSmelting(MineEdibles.rawsteakbit.itemID, new ItemStack(MineEdibles.steakbit, 1), 0.1f);
               GameRegistry.addSmelting(MineEdibles.rawporkbit.itemID, new ItemStack(MineEdibles.porkbit, 1), 0.1f);




        }

        //Item and Block registeration
        private static void gameRegisters(){
        	GameRegistry.registerItem(breadslice, "Bread Slice");
        	GameRegistry.registerItem(chickensandwich, "Chicken Sandwich");
        	GameRegistry.registerItem(steaksandwich, "Steak Sandwich");
        	GameRegistry.registerItem(hamsandwich, "Ham Sandwich");
        	GameRegistry.registerItem(supersandwich, "Super Sandwich");
        	GameRegistry.registerItem(chickenbit, "Slice of Chicken");
        	GameRegistry.registerItem(steakbit, "Slice of Steak");
        	GameRegistry.registerItem(porkbit, "Slice of Ham");
        	GameRegistry.registerItem(tomatoseeds, "Tomato Seeds");
        	GameRegistry.registerItem(tomatofruit, "Tomato");
        	GameRegistry.registerBlock(tomatocrop, "Tomato Crop");
        	GameRegistry.registerItem(rawbacon, "Raw Bacon");
        	GameRegistry.registerItem(cookedbacon, "Cooked Bacon");
        	GameRegistry.registerItem(rawchickenbit, "Raw Slice of Chicken");
        	GameRegistry.registerItem(rawsteakbit, "Raw Slice of Steak");
        	GameRegistry.registerItem(rawporkbit, "Raw Slice of Ham");
        	GameRegistry.registerItem(knife, "Knife");

        }
        //Item and Block in game name, languageregistry
        private static void languageRegisters(){
        	LanguageRegistry.addName(breadslice, "Bread Slice");
        	LanguageRegistry.addName(chickensandwich, "Chicken Sandwich");
        	LanguageRegistry.addName(steaksandwich, "Steak Sandwich");
        	LanguageRegistry.addName(hamsandwich, "Ham Sandwich");
        	LanguageRegistry.addName(supersandwich, "Super Sandwich");
        	LanguageRegistry.addName(chickenbit, "Slice of Chicken");
        	LanguageRegistry.addName(steakbit, "Slice of Steak");
        	LanguageRegistry.addName(porkbit, "Slice of Ham");
        	LanguageRegistry.addName(tomatoseeds, "Tomato Seeds");
        	LanguageRegistry.addName(tomatofruit, "Tomato");
        	LanguageRegistry.addName(rawbacon, "Raw Bacon");
        	LanguageRegistry.addName(rawchickenbit, "Raw Slice of Chicken");
        	LanguageRegistry.addName(rawsteakbit, "Raw Slice of Steak");
        	LanguageRegistry.addName(rawporkbit, "Raw Slice of Ham");
        	LanguageRegistry.addName(knife, "Knife");
        }
        //Crafting Recipes
        public void craftingRecipes(){
        	//Cooked meat slices
        	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.breadslice, 6), new ItemStack(ItemFood.bread));
        	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.chickenbit, 3), new Object[]{ItemFood.chickenCooked, knife});
        	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.steakbit, 3), new Object[]{ItemFood.beefCooked, (new ItemStack(knife, 1, 0))});
        	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.porkbit, 3), new Object[]{ItemFood.porkCooked, (new ItemStack(knife, 1, 0))});
        	//Raw Meat Slices
        	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.rawchickenbit, 3), new Object[]{ItemFood.chickenRaw, (new ItemStack(knife, 1, 0))});
        	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.rawsteakbit, 3), new Object[]{ItemFood.beefRaw, (new ItemStack(knife, 1, 0))});
        	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.rawporkbit, 3), new Object[]{ItemFood.porkRaw, (new ItemStack(knife, 1, 0))});
        	//Sandwiches
        	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.rawchickenbit, 3), new ItemStack(ItemFood.chickenRaw));
        	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.rawsteakbit, 3), new ItemStack(ItemFood.beefRaw));
        	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.rawporkbit, 3), new ItemStack(ItemFood.porkRaw));
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.chickensandwich, 1), new Object[]{" B ", " C ", " B ", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked });
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.steaksandwich, 1), new Object[]{" B ", " S ", " B ", 'B', MineEdibles.breadslice, 'S', ItemFood.beefCooked});
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.hamsandwich, 1), new Object[]{" B ", " P ", " B ", 'B', MineEdibles.breadslice, 'P', ItemFood.porkCooked});
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "CSP", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "SCP", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "PSC", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "SPC", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "PSC", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "CPS", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "CSP", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "CPS", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
        
        	
        }
        @EventHandler
        public void postInit(FMLPostInitializationEvent event) {
                
        }
}

 

I appreciate your help

Link to comment
Share on other sites

Ok, Its only letting me use it once and then it is braking. Maybe something with the crafting recipes?

Heres the new code:

ItemKnife class

 

package mydeblob.mineedibles;

import net.minecraft.item.ItemStack;

public class ItemKnife extends ItemME{

public ItemKnife(int par1, String par2) {
	super(par1, par2);

}
@Override
public boolean hasContainerItem()
{
     return true;
}
@Override
public ItemStack getContainerItemStack(ItemStack itemStack)
{
	int alter = itemStack.getItemDamage() + 1;
	if(alter >= itemStack.getMaxDamage())
	{
		return null;
	}
	itemStack.setItemDamage(alter);
	return itemStack;
}

}

 

Main class

 

package mydeblob.mineedibles;

import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;

@Mod(modid="mineedibles", name="MineEdibles", version="1.0.0")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class MineEdibles {


// The instance of your mod that Forge uses.
@Instance("Sandwich")
public static MineEdibles instance;
private static Item breadslice;
private static Item chickensandwich;
private static Item steaksandwich;
private static Item hamsandwich;
private static Item supersandwich;
private static Item chickenbit;
private static Item steakbit;
private static Item porkbit;
public static Item tomatoseeds;
public static Item tomatofruit;
public static Block tomatocrop;
public static Item rawbacon;
private static Item cookedbacon;
private static Item rawchickenbit;
private static Item rawsteakbit;
private static Item rawporkbit;
public static Item knife;
public static Item cream;

//Item Ids for the config file
int breadsliceID;
int chickensandwichID;
int steaksandwichID;
int hamsandwichID;
int supersandwichID;
int chickenbitID;
int steakbitID;
int porkbitID;
int tomatoseedsID;
int tomatocropID;
int tomatofruitID;
int rawbaconID;
int cookedbaconID;
int rawchickenbitID;
int rawsteakbitID;
int rawporkbitID;
int knifeID;
int creamID;


// Says where the client and server 'proxy' code is loaded.
@SidedProxy(clientSide="mydeblob.mineedibles.client.ClientProxy", serverSide="mydeblob.mineedibles.CommonProxy")
public static CommonProxy proxy;

@EventHandler
public void preInit(FMLPreInitializationEvent event) {
	//Basic Configuration file
	Configuration config = new Configuration(event.getSuggestedConfigurationFile());
	config.load();
	breadsliceID = config.get("Item IDs", "Bread Slice", 5000).getInt();
	chickensandwichID = config.get("Item IDs", "Chicken Sandwich", 5001).getInt();
	steaksandwichID = config.get("Item IDs", "Steak Sandwich", 5002).getInt();
	hamsandwichID = config.get("Item IDs", "Ham Sandwich", 5003).getInt();
	supersandwichID = config.get("Item IDs", "Super Sandwich", 5004).getInt();
	chickenbitID = config.get("Item IDs", "Slice of Chicken", 5005).getInt();
	steakbitID = config.get("Item IDs", "Slice of Steak", 5006).getInt();
	porkbitID = config.get("Item IDs", "Slice of Pork", 5007).getInt();
	tomatoseedsID = config.get("Item IDs", "Tomato Seeds", 5008).getInt();
	tomatocropID = config.get("Block IDs", "Tomato Crop", 500).getInt();
	tomatofruitID = config.get("Item IDs", "Tomato Fruit", 5009).getInt();
	rawbaconID = config.get("Item IDs", "Raw Bacon", 5010).getInt();
	cookedbaconID = config.get("Item IDs", "Cooked Bacon", 5011).getInt();
	rawchickenbitID = config.get("Item IDs", "Raw Slice of Chicken", 5012).getInt();
	rawsteakbitID = config.get("Item IDs", "Raw Slice of Beef", 5013).getInt();
	rawporkbitID = config.get("Item IDs", "Raw Slice of Ham", 5014).getInt();
	knifeID = config.get("Item IDs", "Knife", 5015).getInt();
	knifeID = config.get("Item IDs", "Bucket of Cream", 5016).getInt();
	config.save();
}

@EventHandler
public void load(FMLInitializationEvent event) {
	proxy.register();
	//Items
	breadslice = new ItemME(breadsliceID, "breadslice").setUnlocalizedName("breadslice").setMaxStackSize(64).setCreativeTab(CreativeTabs.tabFood);
	chickensandwich = new ItemFoodME(chickensandwichID, 9, 0.8f, false, "chickensandwich").setPotionEffect(Potion.moveSpeed.id, 4, 0, 0.8f).setUnlocalizedName("chickensandwich").setMaxStackSize(64).setCreativeTab(CreativeTabs.tabFood);
	steaksandwich = new ItemFoodME(steaksandwichID, 9, 0.8f, false, "steaksandwich").setPotionEffect(Potion.moveSpeed.id, 4, 0, 0.8f).setUnlocalizedName("steaksandwich").setMaxStackSize(64).setCreativeTab(CreativeTabs.tabFood);
	hamsandwich = new ItemFoodME(hamsandwichID, 9, 0.8f, false, "hamsandwich").setPotionEffect(Potion.moveSpeed.id, 4, 0, 0.8f).setUnlocalizedName("hamsandwich").setMaxStackSize(64).setCreativeTab(CreativeTabs.tabFood);
	supersandwich = new ItemFoodME(supersandwichID, 18, 1.4f, false, "supersandwich").setAlwaysEdible().setPotionEffect(Potion.regeneration.id, 6, 1, 0.8f).setPotionEffect(Potion.moveSpeed.id, 6, 1, 0.8f).setUnlocalizedName("supersandwich").setMaxStackSize(64).setCreativeTab(CreativeTabs.tabFood);
	chickenbit = new ItemFoodME(chickenbitID, 2, 0.4f, false, "chickenbit").setUnlocalizedName("chickenbit").setCreativeTab(CreativeTabs.tabFood);
	steakbit = new ItemFoodME(steakbitID, 2, 0.4f, false, "steakbit").setUnlocalizedName("steakbit").setCreativeTab(CreativeTabs.tabFood);
	porkbit = new ItemFoodME(porkbitID, 2, 0.4f, false, "porkbit").setUnlocalizedName("porkbit").setCreativeTab(CreativeTabs.tabFood);
	tomatocrop = new BlockCropME(tomatocropID, "tomatocrop", this.tomatoseedsID, this.tomatocropID).setUnlocalizedName("tomatocrop");
	tomatoseeds = new ItemSeedsME(tomatoseedsID, tomatocrop.blockID, 60).setUnlocalizedName("tomatoseeds").func_111206_d("mineedibles:tomatoseeds");
	tomatofruit = new ItemFoodME(tomatofruitID, 6, 0.8f, false, "tomatofruit").setUnlocalizedName("tomatofruit");
	rawbacon = new ItemFoodME(rawbaconID, 3, 0.3f, false, "rawbacon").setUnlocalizedName("baconraw").setCreativeTab(CreativeTabs.tabFood);
	cookedbacon = new ItemFoodME(cookedbaconID, 7, 0.6f, false, "cookedbacon").setUnlocalizedName("baconcooked").setCreativeTab(CreativeTabs.tabFood);
	rawchickenbit = new ItemFoodME(rawchickenbitID, 1, 0.2f, false, "rawchickenbit").setUnlocalizedName("rawchickenbit").setCreativeTab(CreativeTabs.tabFood);
	rawsteakbit = new ItemFoodME(rawsteakbitID, 1, 0.2f, false, "rawsteakbit").setUnlocalizedName("rawsteakbit").setCreativeTab(CreativeTabs.tabFood);
	rawporkbit = new ItemFoodME(rawporkbitID, 1, 0.2f, false, "rawporkbit").setUnlocalizedName("rawporkbit").setCreativeTab(CreativeTabs.tabFood);
	knife = new ItemME(knifeID, "knifeBlack").setUnlocalizedName("knifeBlack").setMaxDamage(64).setMaxStackSize(1).setCreativeTab(CreativeTabs.tabTools);
	cream = new ItemCream(creamID, "cream").setUnlocalizedName("cream");
	MinecraftForge.addGrassSeed(new ItemStack (tomatoseeds), 10);
	gameRegisters();
	languageRegisters();
	craftingRecipes();
	//Smelting
	GameRegistry.addSmelting(MineEdibles.rawbacon.itemID, new ItemStack(MineEdibles.cookedbacon, 1), 0.1f);
	GameRegistry.addSmelting(MineEdibles.rawchickenbit.itemID, new ItemStack(MineEdibles.chickenbit, 1), 0.1f);
	GameRegistry.addSmelting(MineEdibles.rawsteakbit.itemID, new ItemStack(MineEdibles.steakbit, 1), 0.1f);
	GameRegistry.addSmelting(MineEdibles.rawporkbit.itemID, new ItemStack(MineEdibles.porkbit, 1), 0.1f);




}

//Item and Block registeration
private static void gameRegisters(){
	GameRegistry.registerItem(breadslice, "Bread Slice");
	GameRegistry.registerItem(chickensandwich, "Chicken Sandwich");
	GameRegistry.registerItem(steaksandwich, "Steak Sandwich");
	GameRegistry.registerItem(hamsandwich, "Ham Sandwich");
	GameRegistry.registerItem(supersandwich, "Super Sandwich");
	GameRegistry.registerItem(chickenbit, "Slice of Chicken");
	GameRegistry.registerItem(steakbit, "Slice of Steak");
	GameRegistry.registerItem(porkbit, "Slice of Ham");
	GameRegistry.registerItem(tomatoseeds, "Tomato Seeds");
	GameRegistry.registerItem(tomatofruit, "Tomato");
	GameRegistry.registerBlock(tomatocrop, "Tomato Crop");
	GameRegistry.registerItem(rawbacon, "Raw Bacon");
	GameRegistry.registerItem(cookedbacon, "Cooked Bacon");
	GameRegistry.registerItem(rawchickenbit, "Raw Slice of Chicken");
	GameRegistry.registerItem(rawsteakbit, "Raw Slice of Steak");
	GameRegistry.registerItem(rawporkbit, "Raw Slice of Ham");
	GameRegistry.registerItem(knife, "Knife");

}
//Item and Block in game name, languageregistry
private static void languageRegisters(){
	LanguageRegistry.addName(breadslice, "Bread Slice");
	LanguageRegistry.addName(chickensandwich, "Chicken Sandwich");
	LanguageRegistry.addName(steaksandwich, "Steak Sandwich");
	LanguageRegistry.addName(hamsandwich, "Ham Sandwich");
	LanguageRegistry.addName(supersandwich, "Super Sandwich");
	LanguageRegistry.addName(chickenbit, "Slice of Chicken");
	LanguageRegistry.addName(steakbit, "Slice of Steak");
	LanguageRegistry.addName(porkbit, "Slice of Ham");
	LanguageRegistry.addName(tomatoseeds, "Tomato Seeds");
	LanguageRegistry.addName(tomatofruit, "Tomato");
	LanguageRegistry.addName(rawbacon, "Raw Bacon");
	LanguageRegistry.addName(cookedbacon, "Cooked Bacon");
	LanguageRegistry.addName(rawchickenbit, "Raw Slice of Chicken");
	LanguageRegistry.addName(rawsteakbit, "Raw Slice of Steak");
	LanguageRegistry.addName(rawporkbit, "Raw Slice of Ham");
	LanguageRegistry.addName(knife, "Knife");
}
//Crafting Recipes
public void craftingRecipes(){
	//Cooked meat slices
	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.breadslice, 6), new ItemStack(ItemFood.bread));
	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.chickenbit, 3), new Object[]{ItemFood.chickenCooked, (new ItemStack(knife, 1, 0))});
	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.steakbit, 3), new Object[]{ItemFood.beefCooked, (new ItemStack(knife, 1, 0))});
	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.porkbit, 3), new Object[]{ItemFood.porkCooked, (new ItemStack(knife, 1, 0))});
	//Raw Meat Slices
	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.rawchickenbit, 3), new Object[]{ItemFood.chickenRaw, (new ItemStack(knife, 1, 0))});
	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.rawsteakbit, 3), new Object[]{ItemFood.beefRaw, (new ItemStack(knife, 1, 0))});
	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.rawporkbit, 3), new Object[]{ItemFood.porkRaw, (new ItemStack(knife, 1, 0))});
	//Sandwiches
	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.rawchickenbit, 3), new ItemStack(ItemFood.chickenRaw));
	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.rawsteakbit, 3), new ItemStack(ItemFood.beefRaw));
	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.rawporkbit, 3), new ItemStack(ItemFood.porkRaw));
	GameRegistry.addRecipe(new ItemStack(MineEdibles.chickensandwich, 1), new Object[]{" B ", " C ", " B ", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked });
	GameRegistry.addRecipe(new ItemStack(MineEdibles.steaksandwich, 1), new Object[]{" B ", " S ", " B ", 'B', MineEdibles.breadslice, 'S', ItemFood.beefCooked});
	GameRegistry.addRecipe(new ItemStack(MineEdibles.hamsandwich, 1), new Object[]{" B ", " P ", " B ", 'B', MineEdibles.breadslice, 'P', ItemFood.porkCooked});
	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "CSP", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "SCP", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "PSC", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "SPC", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "PSC", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "CPS", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "CSP", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "CPS", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
	//cream
	GameRegistry.addShapelessRecipe(new ItemStack(MineEdibles.cream, 1), new Object []{ItemFood.bucketMilk, ItemFood.sugar});

}
@EventHandler
public void postInit(FMLPostInitializationEvent event) {

}

 

Link to comment
Share on other sites

Your knife has to have a maxDamage lol. In the constructor or the initialization, add:

 

setMaxDamage(maxDmgInteger);

 

Also, unless you make a new IRecipe instance, you'll have to do this to add your recipes:

 

for(int i = 0; i < knife.getMaxDamage(); i++)
{
     GameRegistry.addRecipe(new ItemStack(myCarvedItem), new Object[]
     {
          "top", "mid", "bot", 't', new ItemStack(knife, 1, i)
     });
}

Obviously that wouldn't be your recipe but any character that represents your knife will need to use i as the damage. This will actually add as many recipes as your item has max damage.

 

Remove:

if(alter > stack.getMaxDamage())
{
	return null;
}

Link to comment
Share on other sites

Still doesn't work :/ I have no idea what I'm doing wrong. Spent about a hour looking through my code looking for any error that would cause it to not work. It still only lets me use it once.

ItemKnife Class

 

package mydeblob.mineedibles;

import net.minecraft.item.ItemStack;

public class ItemKnife extends ItemME{

public ItemKnife(int par1, String par2) {
	super(par1, par2);
	this.setMaxDamage(64);


}
@Override
public boolean hasContainerItem()
{
     return true;
}
@Override
public ItemStack getContainerItemStack(ItemStack itemStack)
{
	int alter = itemStack.getItemDamage() + 1;
	itemStack.setItemDamage(alter);
	return itemStack;
}


}

 

Main Class

 

package mydeblob.mineedibles;

import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;

@Mod(modid="mineedibles", name="MineEdibles", version="1.0.0")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class MineEdibles {


// The instance of your mod that Forge uses.
@Instance("Sandwich")
public static MineEdibles instance;
public static Item breadslice;
public static Item chickensandwich;
public static Item steaksandwich;
public static Item hamsandwich;
public static Item supersandwich;
public static Item chickenbit;
public static Item steakbit;
public static Item porkbit;
public static Item tomatoseeds;
public static Item tomatofruit;
public static Block tomatocrop;
public static Item rawbacon;
public static Item cookedbacon;
public static Item rawchickenbit;
public static Item rawsteakbit;
public static Item rawporkbit;
public static Item knife;
public static Item cream;
public static Item lettuceseeds;
public static Item lettuce;
public static Block lettucecrop;
public static Item fertilizer;
public static Item manure;


//Item Ids for the config file
int breadsliceID;
int chickensandwichID;
int steaksandwichID;
int hamsandwichID;
int supersandwichID;
int chickenbitID;
int steakbitID;
int porkbitID;
int tomatoseedsID;
int tomatocropID;
int tomatofruitID;
int rawbaconID;
int cookedbaconID;
int rawchickenbitID;
int rawsteakbitID;
int rawporkbitID;
int knifeID;
int creamID;
int lettuceseedsID;
int lettuceID;
int lettucecropID;
int fertilizerID;
int manureID;

public static CreativeTabs tabMineEdibles = new CreativeTabs("tabMineEdibles")
{
	public ItemStack getIconItemStack()
	{
		return new ItemStack(hamsandwich, 1);
	}
};


// Says where the client and server 'proxy' code is loaded.
@SidedProxy(clientSide="mydeblob.mineedibles.client.ClientProxy", serverSide="mydeblob.mineedibles.CommonProxy")
public static CommonProxy proxy;

@EventHandler
public void preInit(FMLPreInitializationEvent event) {
	//Basic Configuration file
	Configuration config = new Configuration(event.getSuggestedConfigurationFile());
	config.load();
	breadsliceID = config.get("Item IDs", "Bread Slice", 5000).getInt();
	chickensandwichID = config.get("Item IDs", "Chicken Sandwich", 5001).getInt();
	steaksandwichID = config.get("Item IDs", "Steak Sandwich", 5002).getInt();
	hamsandwichID = config.get("Item IDs", "Ham Sandwich", 5003).getInt();
	supersandwichID = config.get("Item IDs", "Super Sandwich", 5004).getInt();
	chickenbitID = config.get("Item IDs", "Slice of Chicken", 5005).getInt();
	steakbitID = config.get("Item IDs", "Slice of Steak", 5006).getInt();
	porkbitID = config.get("Item IDs", "Slice of Pork", 5007).getInt();
	tomatoseedsID = config.get("Item IDs", "Tomato Seeds", 5008).getInt();
	tomatocropID = config.get("Block IDs", "Tomato Crop", 500).getInt();
	tomatofruitID = config.get("Item IDs", "Tomato Fruit", 5009).getInt();
	rawbaconID = config.get("Item IDs", "Raw Bacon", 5010).getInt();
	cookedbaconID = config.get("Item IDs", "Cooked Bacon", 5011).getInt();
	rawchickenbitID = config.get("Item IDs", "Raw Slice of Chicken", 5012).getInt();
	rawsteakbitID = config.get("Item IDs", "Raw Slice of Beef", 5013).getInt();
	rawporkbitID = config.get("Item IDs", "Raw Slice of Ham", 5014).getInt();
	knifeID = config.get("Item IDs", "Knife", 5015).getInt();
	creamID = config.get("Item IDs", "Bucket of Cream", 5016).getInt();
	lettuceseedsID = config.get("Item IDs", "Lettuce Seeds", 5017).getInt();
	lettuceID = config.get("Item IDs", "Lettuce", 5018).getInt();
	lettucecropID = config.get("Block IDs", "Lettuce Crop", 501).getInt();
	fertilizerID = config.get("Item IDs", "Fertilizer", 5019).getInt();
	manureID = config.get("Item IDs", "Manure", 5020).getInt();
	config.save();
}

@EventHandler
public void load(FMLInitializationEvent event) {
	proxy.register();
	//Items
	breadslice = new ItemME(breadsliceID, "breadslice").setUnlocalizedName("breadslice").setMaxStackSize(64).setCreativeTab(tabMineEdibles);
	chickensandwich = new ItemFoodME(chickensandwichID, 9, 0.8f, false, "chickensandwich").setPotionEffect(Potion.moveSpeed.id, 4, 0, 0.8f).setUnlocalizedName("chickensandwich").setMaxStackSize(64).setCreativeTab(tabMineEdibles);
	steaksandwich = new ItemFoodME(steaksandwichID, 9, 0.8f, false, "steaksandwich").setPotionEffect(Potion.moveSpeed.id, 4, 0, 0.8f).setUnlocalizedName("steaksandwich").setMaxStackSize(64).setCreativeTab(tabMineEdibles);
	hamsandwich = new ItemFoodME(hamsandwichID, 9, 0.8f, false, "hamsandwich").setPotionEffect(Potion.moveSpeed.id, 4, 0, 0.8f).setUnlocalizedName("hamsandwich").setMaxStackSize(64).setCreativeTab(tabMineEdibles);
	supersandwich = new ItemFoodME(supersandwichID, 18, 1.4f, false, "supersandwich").setAlwaysEdible().setPotionEffect(Potion.regeneration.id, 6, 1, 0.8f).setPotionEffect(Potion.moveSpeed.id, 6, 1, 0.8f).setUnlocalizedName("supersandwich").setMaxStackSize(64).setCreativeTab(tabMineEdibles);
	chickenbit = new ItemFoodME(chickenbitID, 2, 0.4f, false, "chickenbit").setUnlocalizedName("chickenbit").setCreativeTab(tabMineEdibles);
	steakbit = new ItemFoodME(steakbitID, 2, 0.4f, false, "steakbit").setUnlocalizedName("steakbit").setCreativeTab(tabMineEdibles);
	porkbit = new ItemFoodME(porkbitID, 2, 0.4f, false, "porkbit").setUnlocalizedName("porkbit").setCreativeTab(tabMineEdibles);
	tomatocrop = new BlockCropME(tomatocropID, "tomatocrop", this.tomatoseedsID, this.tomatocropID, .setUnlocalizedName("tomatocrop");
	tomatoseeds = new ItemSeedsME(tomatoseedsID, tomatocrop.blockID, 60, "tomatoseeds").setUnlocalizedName("tomatoseeds").setCreativeTab(tabMineEdibles);
	tomatofruit = new ItemFoodME(tomatofruitID, 6, 0.8f, false, "tomatofruit").setUnlocalizedName("tomatofruit").setCreativeTab(tabMineEdibles);
	rawbacon = new ItemFoodME(rawbaconID, 3, 0.3f, false, "rawbacon").setUnlocalizedName("baconraw").setCreativeTab(tabMineEdibles);
	cookedbacon = new ItemFoodME(cookedbaconID, 7, 0.6f, false, "cookedbacon").setUnlocalizedName("baconcooked").setCreativeTab(tabMineEdibles);
	rawchickenbit = new ItemFoodME(rawchickenbitID, 1, 0.2f, false, "rawchickenbit").setUnlocalizedName("rawchickenbit").setCreativeTab(tabMineEdibles);
	rawsteakbit = new ItemFoodME(rawsteakbitID, 1, 0.2f, false, "rawsteakbit").setUnlocalizedName("rawsteakbit").setCreativeTab(tabMineEdibles);
	rawporkbit = new ItemFoodME(rawporkbitID, 1, 0.2f, false, "rawporkbit").setUnlocalizedName("rawporkbit").setCreativeTab(tabMineEdibles);
	knife = new ItemME(knifeID, "knifeBlack").setUnlocalizedName("knifeBlack").setMaxStackSize(1).setCreativeTab(tabMineEdibles);
	cream = new ItemCream(creamID, "cream").setUnlocalizedName("cream").setCreativeTab(tabMineEdibles);
	lettucecrop = new BlockCropME(lettucecropID, "lettucecrop", this.lettuceseedsID, this.lettucecropID, 5).setUnlocalizedName("lettucecrop");
	lettuceseeds = new ItemSeedsME(lettuceseedsID, lettucecrop.blockID, 60, "lettuceseeds").setUnlocalizedName("lettuceseeds").setCreativeTab(tabMineEdibles);
	lettuce = new ItemFoodME(lettuceID, 6, 0.8f, false, "lettuce").setUnlocalizedName("lettuce").setCreativeTab(tabMineEdibles);
	fertilizer = new ItemFertilizer(fertilizerID, "fertilizer").setUnlocalizedName("fertilizer").setCreativeTab(tabMineEdibles);
	manure = new ItemME(manureID, "manure").setUnlocalizedName("manure").setCreativeTab(tabMineEdibles);
	MinecraftForge.addGrassSeed(new ItemStack (tomatoseeds), 10);
	gameRegisters();
	languageRegisters();
	craftingRecipes();
	//Smelting
	GameRegistry.addSmelting(MineEdibles.rawbacon.itemID, new ItemStack(MineEdibles.cookedbacon, 1), 0.1f);
	GameRegistry.addSmelting(MineEdibles.rawchickenbit.itemID, new ItemStack(MineEdibles.chickenbit, 1), 0.1f);
	GameRegistry.addSmelting(MineEdibles.rawsteakbit.itemID, new ItemStack(MineEdibles.steakbit, 1), 0.1f);
	GameRegistry.addSmelting(MineEdibles.rawporkbit.itemID, new ItemStack(MineEdibles.porkbit, 1), 0.1f);




}

//Item and Block registeration
private static void gameRegisters(){
	GameRegistry.registerItem(breadslice, "Bread Slice");
	GameRegistry.registerItem(chickensandwich, "Chicken Sandwich");
	GameRegistry.registerItem(steaksandwich, "Steak Sandwich");
	GameRegistry.registerItem(hamsandwich, "Ham Sandwich");
	GameRegistry.registerItem(supersandwich, "Super Sandwich");
	GameRegistry.registerItem(chickenbit, "Slice of Chicken");
	GameRegistry.registerItem(steakbit, "Slice of Steak");
	GameRegistry.registerItem(porkbit, "Slice of Ham");
	GameRegistry.registerItem(tomatoseeds, "Tomato Seeds");
	GameRegistry.registerItem(tomatofruit, "Tomato");
	GameRegistry.registerBlock(tomatocrop, "Tomato Crop");
	GameRegistry.registerItem(rawbacon, "Raw Bacon");
	GameRegistry.registerItem(cookedbacon, "Cooked Bacon");
	GameRegistry.registerItem(rawchickenbit, "Raw Slice of Chicken");
	GameRegistry.registerItem(rawsteakbit, "Raw Slice of Steak");
	GameRegistry.registerItem(rawporkbit, "Raw Slice of Ham");
	GameRegistry.registerItem(knife, "Knife");
	GameRegistry.registerItem(lettuceseeds, "Lettuce Seeds");
	GameRegistry.registerItem(lettuce, "Lettuce Fruit");
	GameRegistry.registerBlock(lettucecrop, "Lettuce Crop");
	GameRegistry.registerItem(fertilizer, "Fertilizer");
	GameRegistry.registerItem(manure, "Manure");

}
//Item and Block in game name, language registry
private static void languageRegisters(){
	LanguageRegistry.addName(breadslice, "Bread Slice");
	LanguageRegistry.addName(chickensandwich, "Chicken Sandwich");
	LanguageRegistry.addName(steaksandwich, "Steak Sandwich");
	LanguageRegistry.addName(hamsandwich, "Ham Sandwich");
	LanguageRegistry.addName(supersandwich, "Super Sandwich");
	LanguageRegistry.addName(chickenbit, "Slice of Chicken");
	LanguageRegistry.addName(steakbit, "Slice of Steak");
	LanguageRegistry.addName(porkbit, "Slice of Ham");
	LanguageRegistry.addName(tomatoseeds, "Tomato Seeds");
	LanguageRegistry.addName(tomatofruit, "Tomato");
	LanguageRegistry.addName(rawbacon, "Raw Bacon");
	LanguageRegistry.addName(cookedbacon, "Cooked Bacon");
	LanguageRegistry.addName(rawchickenbit, "Raw Slice of Chicken");
	LanguageRegistry.addName(rawsteakbit, "Raw Slice of Steak");
	LanguageRegistry.addName(rawporkbit, "Raw Slice of Ham");
	LanguageRegistry.addName(knife, "Knife");
	LanguageRegistry.addName(lettuceseeds, "Lettuce Seeds");
	LanguageRegistry.addName(lettuce, "Lettuce");
	LanguageRegistry.addName(fertilizer, "Fertilizer");
	LanguageRegistry.addName(manure, "Manure");
	LanguageRegistry.instance().addStringLocalization("itemGroup.tabMineEdibles", "en_US", "MineEdibles");
}
//Crafting Recipes
public void craftingRecipes(){
	//Cooked meat slices
	for(int i = 0; i < knife.getMaxDamage(); i++)

	{
		GameRegistry.addShapelessRecipe(new ItemStack(MineEdibles.chickenbit, 3), new Object[]{ItemFood.chickenCooked, (new ItemStack(knife, 1, i))});
	}
	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.breadslice, 6), new ItemStack(ItemFood.bread));
	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.chickenbit, 3), new Object[]{ItemFood.chickenCooked, (new ItemStack(knife, 1, 0))});
	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.steakbit, 3), new Object[]{ItemFood.beefCooked, (new ItemStack(knife, 1, 0))});
	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.porkbit, 3), new Object[]{ItemFood.porkCooked, (new ItemStack(knife, 1, 0))});
	//Raw Meat Slices
	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.rawchickenbit, 3), new Object[]{ItemFood.chickenRaw, (new ItemStack(knife, 1, 0))});
	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.rawsteakbit, 3), new Object[]{ItemFood.beefRaw, (new ItemStack(knife, 1, 0))});
	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.rawporkbit, 3), new Object[]{ItemFood.porkRaw, (new ItemStack(knife, 1, 0))});
	//Sandwiches
	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.rawchickenbit, 3), new ItemStack(ItemFood.chickenRaw));
	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.rawsteakbit, 3), new ItemStack(ItemFood.beefRaw));
	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.rawporkbit, 3), new ItemStack(ItemFood.porkRaw));
	GameRegistry.addRecipe(new ItemStack(MineEdibles.chickensandwich, 1), new Object[]{" B ", " C ", " B ", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked });
	GameRegistry.addRecipe(new ItemStack(MineEdibles.steaksandwich, 1), new Object[]{" B ", " S ", " B ", 'B', MineEdibles.breadslice, 'S', ItemFood.beefCooked});
	GameRegistry.addRecipe(new ItemStack(MineEdibles.hamsandwich, 1), new Object[]{" B ", " P ", " B ", 'B', MineEdibles.breadslice, 'P', ItemFood.porkCooked});
	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "CSP", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "SCP", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "PSC", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "SPC", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "PSC", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "CPS", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "CSP", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "CPS", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
	//creamy goodness
	GameRegistry.addShapelessRecipe(new ItemStack(MineEdibles.cream, 1), new Object []{ItemFood.bucketMilk, ItemFood.sugar});
	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.fertilizer), new Object []{ItemFood.fishRaw, MineEdibles.manure});

}
@EventHandler
public void postInit(FMLPostInitializationEvent event) {

}

 

Link to comment
Share on other sites

Guff is right but his code has mistakes!

 

First everything else 1 which is in the Item class is right.

You should change the - into a + (inside of the getContainerItemStack function) or you get problems^^

But eveything else is wrong what he made!

 

So first you register your item like that:

 

public static Item test = new yourItem(ItemID).setContainerItem(test);

 

now the Recipe!

You do not need to make a for loop. That make only lag. (I know it i made with this way about 2Million Recipes)

Its alot easier!

GameRegistry.addRecipe(new ItemStack(Item.diamond), new Object[]{"X", 'X', new ItemStack(test, 1, OreDictionary.WildCardValue)});

 

The WildCardValue or something like that (look inside of forge ordictionary class for the right name).

Is like 1.4.7 new ItemStack(item, 1,-1) this means he uses any damage he gets.

I hope it helps you,

 

Now to Guff.

You can use ForLoops. But at 100.000 Recipes the craftingtable starts to lag everytime you place or drag an item in/out of the craftingtabel.

 

So why don't you change your recipe because the way i explained makes only 1 recipe instead of how many your ItemDamage is.

Good Luck

Link to comment
Share on other sites

Ya ya, im sure you get ton of these threads, but for some reason this isn't working. Im using forge 1.6.2, and I want an item to take 1 damage out of 64 when used to craft something. I made some code for it but I can only use it 3 times before it won't let me craft anymore but the item still has durability. Thanks for your help.

Base Mod class (the knife item is the one that should be able to be used more than once)

 

package mydeblob.mineedibles;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemSeeds;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.PostInit;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;

@Mod(modid="mineedibles", name="MineEdibles", version="1.0.0")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class MineEdibles {


        // The instance of your mod that Forge uses.
        @Instance("Sandwich")
        public static MineEdibles instance;
        private static Item breadslice;
        private static Item chickensandwich;
        private static Item steaksandwich;
        private static Item hamsandwich;
        private static Item supersandwich;
        private static Item chickenbit;
        private static Item steakbit;
        private static Item porkbit;
        public static Item tomatoseeds;
        public static Item tomatofruit;
        public static Block tomatocrop;
        public static Item rawbacon;
        private static Item cookedbacon;
        private static Item rawchickenbit;
        private static Item rawsteakbit;
        private static Item rawporkbit;
        public static Item knife;
        
        //Item Ids for the config file
        int breadsliceID;
        int chickensandwichID;
        int steaksandwichID;
        int hamsandwichID;
        int supersandwichID;
        int chickenbitID;
        int steakbitID;
        int porkbitID;
        int tomatoseedsID;
        int tomatocropID;
        int tomatofruitID;
        int rawbaconID;
        int cookedbaconID;
        int rawchickenbitID;
        int rawsteakbitID;
        int rawporkbitID;
        int knifeID;

        
        // Says where the client and server 'proxy' code is loaded.
        @SidedProxy(clientSide="mydeblob.mineedibles.client.ClientProxy", serverSide="mydeblob.mineedibles.CommonProxy")
        public static CommonProxy proxy;
        
        @EventHandler
        public void preInit(FMLPreInitializationEvent event) {
        	//Basic Configuration file
        	Configuration config = new Configuration(event.getSuggestedConfigurationFile());
        	config.load();
        	breadsliceID = config.get("Item IDs", "Bread Slice", 5000).getInt();
        	chickensandwichID = config.get("Item IDs", "Chicken Sandwich", 5001).getInt();
        	steaksandwichID = config.get("Item IDs", "Steak Sandwich", 5002).getInt();
        	hamsandwichID = config.get("Item IDs", "Ham Sandwich", 5003).getInt();
        	supersandwichID = config.get("Item IDs", "Super Sandwich", 5004).getInt();
        	chickenbitID = config.get("Item IDs", "Slice of Chicken", 5005).getInt();
        	steakbitID = config.get("Item IDs", "Slice of Steak", 5006).getInt();
        	porkbitID = config.get("Item IDs", "Slice of Pork", 5007).getInt();
        	tomatoseedsID = config.get("Item IDs", "Tomato Seeds", 5008).getInt();
        	tomatofruitID = config.get("Item IDs", "Tomato Fruit", 5009).getInt();
        	rawbaconID = config.get("Item IDs", "Raw Bacon", 50010).getInt();
        	cookedbaconID = config.get("Item IDs", "Cooked Bacon", 5011).getInt();
        	rawchickenbitID = config.get("Item IDs", "Raw Slice of Chicken", 5012).getInt();
        	rawsteakbitID = config.get("Item IDs", "Raw Slice of Beef", 5013).getInt();
        	rawporkbitID = config.get("Item IDs", "Raw Slice of Ham", 5014).getInt();
        	knifeID = config.get("Item IDs", "Knife", 5015).getInt();
        	config.save();
        }
        
        @EventHandler
        public void load(FMLInitializationEvent event) {
                proxy.registerRenderers();
                //Items
               breadslice = new Item(breadsliceID).setUnlocalizedName("breadslice").setMaxStackSize(64).setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:slicebread");
               chickensandwich = new ItemFood(chickensandwichID, 9, 0.8f, false).setPotionEffect(Potion.moveSpeed.id, 4, 0, 0.8f).setUnlocalizedName("chickensandwich").setMaxStackSize(64).setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:chickensandwich");
               steaksandwich = new ItemFood(steaksandwichID, 9, 0.8f, false).setPotionEffect(Potion.moveSpeed.id, 4, 0, 0.8f).setUnlocalizedName("steaksandwich").setMaxStackSize(64).setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:steaksandwich");
               hamsandwich = new ItemFood(hamsandwichID, 9, 0.8f, false).setPotionEffect(Potion.moveSpeed.id, 4, 0, 0.8f).setUnlocalizedName("hamsandwich").setMaxStackSize(64).setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:hamsandwich");
               supersandwich = new ItemFood(supersandwichID, 18, 1.4f, false).setAlwaysEdible().setPotionEffect(Potion.regeneration.id, 6, 1, 0.8f).setPotionEffect(Potion.moveSpeed.id, 6, 1, 0.8f).setUnlocalizedName("supersandwich").setMaxStackSize(64).setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:supersandwich");
               chickenbit = new ItemFood(chickenbitID, 2, 0.4f, false).setUnlocalizedName("chickenbit").setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:chickenbit");
               steakbit = new ItemFood(steakbitID, 2, 0.4f, false).setUnlocalizedName("steakbit").setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:steakbit");
               porkbit = new ItemFood(porkbitID, 2, 0.4f, false).setUnlocalizedName("porkbit").setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:porkbit");
               tomatocrop = new TomatoCrop(tomatocropID).setUnlocalizedName("tomatocrop").func_111022_d("mineedibles:tomatocrop");
               tomatoseeds = new ItemSeeds(tomatoseedsID, tomatocrop.blockID, Block.tilledField.blockID).setUnlocalizedName("tomatoseeds").func_111206_d("mineedibles:tomatoseeds");
               tomatofruit = new ItemFood(tomatofruitID, 6, 0.8f, false).setUnlocalizedName("tomatofruit").func_111206_d("mineedibles:tomatofruit");
               rawbacon = new ItemFood(rawbaconID, 3, 0.3f, false).setUnlocalizedName("baconraw").setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:rawbacon");
               cookedbacon = new ItemFood(cookedbaconID, 7, 0.6f, false).setUnlocalizedName("baconcooked").setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:cookedbacon");
               rawchickenbit = new ItemFood(rawchickenbitID, 1, 0.2f, false).setUnlocalizedName("rawchickenbit").setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:rawchickenbit");
               rawsteakbit = new ItemFood(rawsteakbitID, 1, 0.2f, false).setUnlocalizedName("rawsteakbit").setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:rawsteakbit");
               rawporkbit = new ItemFood(rawporkbitID, 1, 0.2f, false).setUnlocalizedName("rawporkbit").setCreativeTab(CreativeTabs.tabFood).func_111206_d("mineedibles:rawporkbit");
               knife = new Item(knifeID).setUnlocalizedName("knife").setMaxDamage(64).setMaxStackSize(1).setCreativeTab(CreativeTabs.tabTools).func_111206_d("mineedibles:knifeBlack");
               MinecraftForge.addGrassSeed(new ItemStack (tomatoseeds), 10);
               gameRegisters();
               languageRegisters();
               craftingRecipes();
               	//Smelting
               GameRegistry.addSmelting(MineEdibles.rawbacon.itemID, new ItemStack(MineEdibles.cookedbacon, 1), 0.1f);
               GameRegistry.addSmelting(MineEdibles.rawchickenbit.itemID, new ItemStack(MineEdibles.chickenbit, 1), 0.1f);
               GameRegistry.addSmelting(MineEdibles.rawsteakbit.itemID, new ItemStack(MineEdibles.steakbit, 1), 0.1f);
               GameRegistry.addSmelting(MineEdibles.rawporkbit.itemID, new ItemStack(MineEdibles.porkbit, 1), 0.1f);




        }

        //Item and Block registeration
        private static void gameRegisters(){
        	GameRegistry.registerItem(breadslice, "Bread Slice");
        	GameRegistry.registerItem(chickensandwich, "Chicken Sandwich");
        	GameRegistry.registerItem(steaksandwich, "Steak Sandwich");
        	GameRegistry.registerItem(hamsandwich, "Ham Sandwich");
        	GameRegistry.registerItem(supersandwich, "Super Sandwich");
        	GameRegistry.registerItem(chickenbit, "Slice of Chicken");
        	GameRegistry.registerItem(steakbit, "Slice of Steak");
        	GameRegistry.registerItem(porkbit, "Slice of Ham");
        	GameRegistry.registerItem(tomatoseeds, "Tomato Seeds");
        	GameRegistry.registerItem(tomatofruit, "Tomato");
        	GameRegistry.registerBlock(tomatocrop, "Tomato Crop");
        	GameRegistry.registerItem(rawbacon, "Raw Bacon");
        	GameRegistry.registerItem(cookedbacon, "Cooked Bacon");
        	GameRegistry.registerItem(rawchickenbit, "Raw Slice of Chicken");
        	GameRegistry.registerItem(rawsteakbit, "Raw Slice of Steak");
        	GameRegistry.registerItem(rawporkbit, "Raw Slice of Ham");
        	GameRegistry.registerItem(knife, "Knife");
        	GameRegistry.registerCraftingHandler(new KnifeCraftingHandler());
        }
        //Item and Block in game name, languageregistry
        private static void languageRegisters(){
        	LanguageRegistry.addName(breadslice, "Bread Slice");
        	LanguageRegistry.addName(chickensandwich, "Chicken Sandwich");
        	LanguageRegistry.addName(steaksandwich, "Steak Sandwich");
        	LanguageRegistry.addName(hamsandwich, "Ham Sandwich");
        	LanguageRegistry.addName(supersandwich, "Super Sandwich");
        	LanguageRegistry.addName(chickenbit, "Slice of Chicken");
        	LanguageRegistry.addName(steakbit, "Slice of Steak");
        	LanguageRegistry.addName(porkbit, "Slice of Ham");
        	LanguageRegistry.addName(tomatoseeds, "Tomato Seeds");
        	LanguageRegistry.addName(tomatofruit, "Tomato");
        	LanguageRegistry.addName(rawbacon, "Raw Bacon");
        	LanguageRegistry.addName(rawchickenbit, "Raw Slice of Chicken");
        	LanguageRegistry.addName(rawsteakbit, "Raw Slice of Steak");
        	LanguageRegistry.addName(rawporkbit, "Raw Slice of Ham");
        	LanguageRegistry.addName(knife, "Knife");
        }
        //Crafting Recipes
        public void craftingRecipes(){
        	//Cooked meat slices
        	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.breadslice, 6), new ItemStack(ItemFood.bread));
        	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.chickenbit, 3), new Object[]{ItemFood.chickenCooked, (new ItemStack(knife, 1, 0 ))});
        	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.steakbit, 3), new Object[]{ItemFood.beefCooked, (new ItemStack(knife, 1, 0))});
        	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.porkbit, 3), new Object[]{ItemFood.porkCooked, (new ItemStack(knife, 1, 0))});
        	//Raw Meat Slices
        	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.rawchickenbit, 3), new Object[]{ItemFood.chickenRaw, (new ItemStack(knife, 1, 0))});
        	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.rawsteakbit, 3), new Object[]{ItemFood.beefRaw, (new ItemStack(knife, 1, 0))});
        	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.rawporkbit, 3), new Object[]{ItemFood.porkRaw, (new ItemStack(knife, 1, 0))});
        	//Sandwiches
        	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.rawchickenbit, 3), new ItemStack(ItemFood.chickenRaw));
        	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.rawsteakbit, 3), new ItemStack(ItemFood.beefRaw));
        	GameRegistry.addShapelessRecipe(new ItemStack (MineEdibles.rawporkbit, 3), new ItemStack(ItemFood.porkRaw));
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.chickensandwich, 1), new Object[]{" B ", " C ", " B ", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked });
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.steaksandwich, 1), new Object[]{" B ", " S ", " B ", 'B', MineEdibles.breadslice, 'S', ItemFood.beefCooked});
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.hamsandwich, 1), new Object[]{" B ", " P ", " B ", 'B', MineEdibles.breadslice, 'P', ItemFood.porkCooked});
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "CSP", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "SCP", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "PSC", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "SPC", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "PSC", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "CPS", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "CSP", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
        	GameRegistry.addRecipe(new ItemStack(MineEdibles.supersandwich, 1), new Object []{"BBB", "CPS", "BBB", 'B', MineEdibles.breadslice, 'C', ItemFood.chickenCooked, 'S', ItemFood.beefCooked, 'P', ItemFood.porkCooked});
        
        	
        }
        @EventHandler
        public void postInit(FMLPostInitializationEvent event) {
                
        }
}

 

CraftingHandlerClass for the Item Knife

 

package mydeblob.mineedibles;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.ICraftingHandler;

public class KnifeCraftingHandler implements ICraftingHandler {

@Override
public void onCrafting(EntityPlayer player, ItemStack item,
		IInventory craftMatrix) {
	for (int i = 0; i < craftMatrix.getSizeInventory(); i++) {

		if (craftMatrix.getStackInSlot(i) != null) {
			ItemStack j = craftMatrix.getStackInSlot(i);

			if (j.getItem() != null && j.getItem() == MineEdibles.knife) {
				ItemStack k = new ItemStack(MineEdibles.knife, 2, (j.getItemDamage() + 1));

				if (k.getItemDamage() >= k.getMaxDamage()) {
					k.stackSize--;
				}
				craftMatrix.setInventorySlotContents(i, k);
			}
		}
	}

}

@Override
public void onSmelting(EntityPlayer player, ItemStack item) {
	// TODO Auto-generated method stub

}

}

 

 

Ok look here buddy. I'm going to rock your world just use this. The code is a bit outdated but it should work mostly. Hope it works!

 

Crafting Handler:

package cyphereion.mods.patches.yogpack;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.ICraftingHandler;

public class CraftingHandler implements ICraftingHandler {
@Override
public void onCrafting(EntityPlayer player, ItemStack item, IInventory craftMatrix) {
	for (int i = 0; i < craftMatrix.getSizeInventory(); i++)
	{
		if (craftMatrix.getStackInSlot(i) != null)
		{
			ItemStack j = craftMatrix.getStackInSlot(i);
			if (j.getItem() != null && j.getItem() == ITEM) 
			{
				ItemStack k = new ItemStack(ITEM, 2, (j.getItemDamage() + 1)); 
				if (k.getItemDamage() >= k.getMaxDamage()) { 
					k.stackSize--; 
				}
				craftMatrix.setInventorySlotContents(i, k);
			}
		}
	}

}


@Override
public void onSmelting(EntityPlayer player, ItemStack item) {
}
}

 

Item Class (Just for reference):

package cyphereion.mods.patches.yogpack;

import java.util.List;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class ItemTransmorgrificationCrystal extends Item {
private int index;
public ItemTransmorgrificationCrystal(int par1, int index)
{
	super(par1);
	this.index = index;
	this.setMaxStackSize(1);
	this.setMaxDamage(150);
	this.setCreativeTab(CreativeTabs.tabMaterials);
}
@SideOnly(Side.CLIENT)
public String getTextureFile(){
	return "/cyphereion/mods/patches/yogpack/Cyphereion.png";
}

public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
	par3List.add("Stone brick to hold it together.");
	par3List.add("Obsidian to make it tough to break");
	par3List.add("Diamond for good looks.");
}

@SideOnly(Side.CLIENT)
public int getIconFromDamage(int i){
	return index;
}

}

 

 

Recipes:

GameRegistry.addShapelessRecipe(new ItemStack(TransmorgrificationCrystal, 1, 0), Block.stoneBrick, Block.stoneBrick, Block.stoneBrick, Block.stoneBrick, Block.obsidian, Block.obsidian, Block.obsidian, Block.obsidian, Item.diamond);

GameRegistry.addRecipe(new ItemStack(Item.blazeRod, 7),new Object[] { "OTG",'O', Block.obsidian, 'G', Block.blockGold, 'T', (new ItemStack(TransmorgrificationCrystal,1,-1))});

Link to comment
Share on other sites

@deadrecon98, did you even read his post? you posted exactly the same code he was already using

 

@OP

just do a combination of what guff and moritz said. don't use a crafting handler since you don't need one. use hasContainerItem and getContainerItemStack like guff said. and like moritz said, you don't need the for loop when registering the recipe. but, you don't need to register the item in the way moritz suggested since you're already overriding getContainerItemStack(ItemStack).

 

anyway, wrote the following to make absolutely sure it works and it does. just replace the stuff there with what you need. if you want it to stay in the crafting grid, use doesContainerItemLeaveCraftingGrid(ItemStack)

 

package pelep.zzzzz;

import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;

@Mod(modid = "ZZZZZ", name = "ZZZZZ", version = "ZZZZZ")

public class ZZZZZ
{
@Instance("ZZZZZ")
public static ZZZZZ instance;

@EventHandler
public void init(FMLInitializationEvent e)
{
	GameRegistry.registerItem(new ItemDamageable(ID), "itemDamageable");
	GameRegistry.addRecipe(new ItemStack(1, 1, 0), new Object[] {"d", 'd', new ItemStack(IDSHIFTEDINDEX, 1, OreDictionary.WILDCARD_VALUE)});
}
}

 

package pelep.zzzzz;

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

public class ItemDamageable extends Item
{
public ItemDamageable(int id)
{
	super(id);
	this.setMaxDamage(64);
}

@Override
public boolean hasContainerItem()
{
	return true;
}

@Override
public ItemStack getContainerItemStack(ItemStack ist)
{
	ist.setItemDamage(ist.getItemDamage() + 1);

	if (ist.getItemDamage() > ist.getMaxDamage())
	{
		ist = null;
	}

	return ist;
}
}

Link to comment
Share on other sites

I did this with an item that has 2048 max damage just to help him, and it doesn't make the crafting table lag. The only time it lags is if you shift-click the output.

 

I Said at 100.000 recipes everything what the craftingManager uses start to lag!

But 2048 recipes are to much!

 

Link to comment
Share on other sites

package pelep.zzzzz;
@Override
public ItemStack getContainerItemStack(ItemStack ist)
{
	ist.setItemDamage(ist.getItemDamage() + 1);

	if (ist.getItemDamage() > ist.getMaxDamage())
	{
		ist = null;
	}

	return ist;
}

Don't return a null itemstack. I attempted that at first but I had him change it since it was giving a NPE. The crafting bench attempts to check for item damage already for some reason, and if you return null and it tries to check it, it doesn't protect itself against NPE. Damaging the item and returning the stack will suffice. If you didn't get a NPE then that's just weird because I had to trace it back to this and remove setting the return to null.

Link to comment
Share on other sites

well, to be honest, i didn't test it all the way until the item went past the max damage.. kinda got too lazy. lol. anyway, just checked it now and you're right.

 

@OP

just take this part out

	if (ist.getItemDamage() > ist.getMaxDamage())
	{
		ist = null;
	}

Link to comment
Share on other sites

well, to be honest, i didn't test it all the way until the item went past the max damage.. kinda got too lazy. lol. anyway, just checked it now and you're right.

 

@OP

just take this part out

	if (ist.getItemDamage() > ist.getMaxDamage())
	{
		ist = null;
	}

 

Yeah lol I kept trying it with something similar and I took it out and it worked.

Link to comment
Share on other sites

@deadrecon98, did you even read his post? you posted exactly the same code he was already using

 

@OP

just do a combination of what guff and moritz said. don't use a crafting handler since you don't need one. use hasContainerItem and getContainerItemStack like guff said. and like moritz said, you don't need the for loop when registering the recipe. but, you don't need to register the item in the way moritz suggested since you're already overriding getContainerItemStack(ItemStack).

 

anyway, wrote the following to make absolutely sure it works and it does. just replace the stuff there with what you need. if you want it to stay in the crafting grid, use doesContainerItemLeaveCraftingGrid(ItemStack)

 

package pelep.zzzzz;

import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;

@Mod(modid = "ZZZZZ", name = "ZZZZZ", version = "ZZZZZ")

public class ZZZZZ
{
@Instance("ZZZZZ")
public static ZZZZZ instance;

@EventHandler
public void init(FMLInitializationEvent e)
{
	GameRegistry.registerItem(new ItemDamageable(ID), "itemDamageable");
	GameRegistry.addRecipe(new ItemStack(1, 1, 0), new Object[] {"d", 'd', new ItemStack(IDSHIFTEDINDEX, 1, OreDictionary.WILDCARD_VALUE)});
}
}

 

package pelep.zzzzz;

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

public class ItemDamageable extends Item
{
public ItemDamageable(int id)
{
	super(id);
	this.setMaxDamage(64);
}

@Override
public boolean hasContainerItem()
{
	return true;
}

@Override
public ItemStack getContainerItemStack(ItemStack ist)
{
	ist.setItemDamage(ist.getItemDamage() + 1);

	if (ist.getItemDamage() > ist.getMaxDamage())
	{
		ist = null;
	}

	return ist;
}
}

 

It doesn't matter how you do it because I know for a fact my way works. It may just take a little tweaking but it is working fine for me.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • crashed with a empty report i tried again and [18jun.2024 04:38:56.251] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--username, 42crowley, --version, 1.20.1-forge-47.3.1, --gameDir, C:\Users\********\curseforge\minecraft\Instances\Mine dos cria, --assetsDir, C:\Users\********\AppData\Roaming\.minecraft\assets, --assetIndex, 5, --uuid, b917df67f6ce3ca4ac9b4e438faa1f85, --accessToken, ????????, --clientId, 0, --xuid, 0, --userType, msa, --versionType, release, --width, 854, --height, 480, --launchTarget, forgeclient, --fml.forgeVersion, 47.3.1, --fml.mcVersion, 1.20.1, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20230612.114412] 2[18jun.2024 04:38:56.263] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 10.0.9 10.0.9 main.dcd20f30 starting: java version 17.0.8 by Microsoft; OS Windows 11 arch amd64 version 10.0 3[18jun.2024 04:38:57.587] [main/INFO] [net.minecraftforge.fml.loading.ImmediateWindowHandler/]: Loading ImmediateWindowProvider fmlearlywindow 4[18jun.2024 04:38:57.967] [main/INFO] [EARLYDISPLAY/]: Trying GL version 4.6 5[18jun.2024 04:38:58.046] [main/INFO] [EARLYDISPLAY/]: Requested GL version 4.6 got version 4.6 6[18jun.2024 04:38:58.464] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.5 Source=union:/C:/Users/********/AppData/Roaming/.minecraft/libraries/org/spongepowered/mixin/0.8.5/mixin-0.8.5.jar#100!/ Service=ModLauncher Env=CLIENT 7[18jun.2024 04:38:58.680] [pool-4-thread-1/INFO] [EARLYDISPLAY/]: GL info: Intel(R) UHD Graphics GL version 4.6.0 - Build 30.0.101.2079, Intel 8[18jun.2024 04:38:59.401] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\********\AppData\Roaming\.minecraft\libraries\net\minecraftforge\fmlcore\1.20.1-47.3.1\fmlcore-1.20.1-47.3.1.jar is missing mods.toml file 9[18jun.2024 04:38:59.407] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\********\AppData\Roaming\.minecraft\libraries\net\minecraftforge\javafmllanguage\1.20.1-47.3.1\javafmllanguage-1.20.1-47.3.1.jar is missing mods.toml file 10[18jun.2024 04:38:59.412] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\********\AppData\Roaming\.minecraft\libraries\net\minecraftforge\lowcodelanguage\1.20.1-47.3.1\lowcodelanguage-1.20.1-47.3.1.jar is missing mods.toml file 11[18jun.2024 04:38:59.418] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\********\AppData\Roaming\.minecraft\libraries\net\minecraftforge\mclanguage\1.20.1-47.3.1\mclanguage-1.20.1-47.3.1.jar is missing mods.toml file 12[18jun.2024 04:39:00.142] [main/WARN] [net.minecraftforge.jarjar.selection.JarSelector/]: Attempted to select two dependency jars from JarJar which have the same identification: Mod File: and Mod File: . Using Mod File: 13[18jun.2024 04:39:00.144] [main/WARN] [net.minecraftforge.jarjar.selection.JarSelector/]: Attempted to select a dependency jar for JarJar which was passed in as source: curios. Using Mod File: C:\Users\********\curseforge\minecraft\Instances\Mine dos cria\mods\curios-forge-5.9.1 1.20.1.jar 14[18jun.2024 04:39:00.145] [main/INFO] [net.minecraftforge.fml.loading.moddiscovery.JarInJarDependencyLocator/]: Found 20 dependencies adding them to mods collection 15[18jun.2024 04:39:05.971] [main/INFO] [mixin/]: Compatibility level set to JAVA_17 16[18jun.2024 04:39:06.966] [main/INFO] [mixin/]: Successfully loaded Mixin Connector [com.sonicether.soundphysics.MixinConnector] 17[18jun.2024 04:39:06.972] [main/INFO] [cpw.mods.modlauncher.LaunchServiceHandler/MODLAUNCHER]: Launching target 'forgeclient' with arguments [--version, 1.20.1-forge-47.3.1, --gameDir, C:\Users\********\curseforge\minecraft\Instances\Mine dos cria, --assetsDir, C:\Users\********\AppData\Roaming\.minecraft\assets, --uuid, b917df67f6ce3ca4ac9b4e438faa1f85, --username, 42crowley, --assetIndex, 5, --accessToken, ????????, --clientId, 0, --xuid, 0, --userType, msa, --versionType, release, --width, 854, --height, 480] 18[18jun.2024 04:39:07.007] [main/WARN] [mixin/]: Reference map 'createdeco-forge-refmap.json' for createdeco.mixins.json could not be read. If this is a development environment you can ignore this message 19[18jun.2024 04:39:07.192] [main/INFO] [ModernFix/]: Loaded configuration file for ModernFix 5.17.0 mc1.20.1: 78 options available, 0 override(s) found 20[18jun.2024 04:39:07.194] [main/INFO] [ModernFix/]: Applying Nashorn fix 21[18jun.2024 04:39:07.223] [main/INFO] [ModernFix/]: Applied Forge config corruption patch 22[18jun.2024 04:39:07.413] [main/WARN] [mixin/]: Reference map 'interiors-forge-refmap.json' for interiors.mixins.json could not be read. If this is a development environment you can ignore this message 23[18jun.2024 04:39:07.477] [main/INFO] [Embeddium/]: Loaded configuration file for Embeddium: 132 options available, 3 override(s) found 24[18jun.2024 04:39:07.480] [main/INFO] [Embeddium-GraphicsAdapterProbe/]: Searching for graphics cards... 25[18jun.2024 04:39:08.097] [main/INFO] [Embeddium-GraphicsAdapterProbe/]: Found graphics card: GraphicsAdapterInfo[vendor=INTEL, name=Intel(R) UHD Graphics, version=DriverVersion=30.0.101.2079] 26[18jun.2024 04:39:08.194] [main/WARN] [mixin/]: Reference map 'yungsextras.refmap.json' for yungsextras.mixins.json could not be read. If this is a development environment you can ignore this message 27[18jun.2024 04:39:08.197] [main/WARN] [mixin/]: Reference map 'yungsextras.refmap.json' for yungsextras_forge.mixins.json could not be read. If this is a development environment you can ignore this message 28[18jun.2024 04:39:08.234] [main/WARN] [mixin/]: Reference map 'nitrogen_internals.refmap.json' for nitrogen_internals.mixins.json could not be read. If this is a development environment you can ignore this message 29[18jun.2024 04:39:08.259] [main/WARN] [mixin/]: Reference map 'octolib.refmap.json' for octolib.mixins.json could not be read. If this is a development environment you can ignore this message 30[18jun.2024 04:39:08.384] [main/WARN] [mixin/]: Reference map 'mes-forge-refmap.json' for mes-forge.mixins.json could not be read. If this is a development environment you can ignore this message 31[18jun.2024 04:39:11.680] [main/WARN] [mixin/]: Error loading class: dev/latvian/mods/kubejs/recipe/RecipesEventJS (java.lang.ClassNotFoundException: dev.latvian.mods.kubejs.recipe.RecipesEventJS) 32[18jun.2024 04:39:11.685] [main/WARN] [mixin/]: @Mixin target dev.latvian.mods.kubejs.recipe.RecipesEventJS was not found sliceanddice.mixins.json:RecipeEventJSMixin 33[18jun.2024 04:39:12.476] [main/WARN] [mixin/]: Error loading class: earth/terrarium/botarium/forge/BotariumForge (java.lang.ClassNotFoundException: earth.terrarium.botarium.forge.BotariumForge) 34[18jun.2024 04:39:12.477] [main/WARN] [mixin/]: @Mixin target earth.terrarium.botarium.forge.BotariumForge was not found create_central_kitchen.mixins.json:common.botarium.BotariumForgeMixin 35[18jun.2024 04:39:12.481] [main/WARN] [mixin/]: Error loading class: dan200/computercraft/shared/integration/MoreRedIntegration (java.lang.ClassNotFoundException: dan200.computercraft.shared.integration.MoreRedIntegration) 36[18jun.2024 04:39:12.482] [main/WARN] [mixin/]: @Mixin target dan200.computercraft.shared.integration.MoreRedIntegration was not found create_central_kitchen.mixins.json:common.computercraft.MoreRedIntegrationMixin 37[18jun.2024 04:39:12.739] [main/WARN] [mixin/]: Error loading class: com/sammy/minersdelight/content/block/copper_pot/CopperPotBlockEntity (java.lang.ClassNotFoundException: com.sammy.minersdelight.content.block.copper_pot.CopperPotBlockEntity) 38[18jun.2024 04:39:12.739] [main/WARN] [mixin/]: @Mixin target com.sammy.minersdelight.content.block.copper_pot.CopperPotBlockEntity was not found create_central_kitchen.mixins.json:common.minersdelight.CopperPotBlockEntityMixin 39[18jun.2024 04:39:12.742] [main/WARN] [mixin/]: Error loading class: com/sammy/minersdelight/content/block/sticky_basket/StickyBasketBlockEntity (java.lang.ClassNotFoundException: com.sammy.minersdelight.content.block.sticky_basket.StickyBasketBlockEntity) 40[18jun.2024 04:39:12.742] [main/WARN] [mixin/]: @Mixin target com.sammy.minersdelight.content.block.sticky_basket.StickyBasketBlockEntity was not found create_central_kitchen.mixins.json:common.minersdelight.StickyBasketBlockEntityAccessor 41[18jun.2024 04:39:12.745] [main/WARN] [mixin/]: Error loading class: com/sammy/minersdelight/content/block/sticky_basket/StickyBasketBlockEntity (java.lang.ClassNotFoundException: com.sammy.minersdelight.content.block.sticky_basket.StickyBasketBlockEntity) 42[18jun.2024 04:39:12.745] [main/WARN] [mixin/]: @Mixin target com.sammy.minersdelight.content.block.sticky_basket.StickyBasketBlockEntity was not found create_central_kitchen.mixins.json:common.minersdelight.StickyBasketBlockEntityMixin 43[18jun.2024 04:39:12.749] [main/WARN] [mixin/]: Error loading class: net/orcinus/overweightfarming/blocks/CropFullBlock (java.lang.ClassNotFoundException: net.orcinus.overweightfarming.blocks.CropFullBlock) 44[18jun.2024 04:39:12.749] [main/WARN] [mixin/]: @Mixin target net.orcinus.overweightfarming.blocks.CropFullBlock was not found create_central_kitchen.mixins.json:common.overweightfarming.CropFullBlockMixin 45[18jun.2024 04:39:13.708] [main/WARN] [Embeddium/]: Force-disabling mixin 'features.render.world.sky.WorldRendererMixin' as rule 'mixin.features.render.world.sky' (added by mods [oculus]) disables it and children 46[18jun.2024 04:39:13.710] [main/WARN] [Embeddium/]: Force-disabling mixin 'features.render.world.sky.ClientWorldMixin' as rule 'mixin.features.render.world.sky' (added by mods [oculus]) disables it and children 47[18jun.2024 04:39:13.711] [main/WARN] [Embeddium/]: Force-disabling mixin 'features.render.world.sky.BackgroundRendererMixin' as rule 'mixin.features.render.world.sky' (added by mods [oculus]) disables it and children 48[18jun.2024 04:39:13.719] [main/WARN] [Embeddium/]: Force-disabling mixin 'features.render.gui.font.GlyphRendererMixin' as rule 'mixin.features.render.gui.font' (added by mods [oculus]) disables it and children 49[18jun.2024 04:39:13.720] [main/WARN] [Embeddium/]: Force-disabling mixin 'features.render.gui.font.FontSetMixin' as rule 'mixin.features.render.gui.font' (added by mods [oculus]) disables it and children 50[18jun.2024 04:39:13.722] [main/WARN] [Embeddium/]: Force-disabling mixin 'features.render.entity.shadows.EntityRenderDispatcherMixin' as rule 'mixin.features.render.entity' (added by mods [oculus]) disables it and children 51[18jun.2024 04:39:13.724] [main/WARN] [Embeddium/]: Force-disabling mixin 'features.render.entity.fast_render.ModelPartMixin' as rule 'mixin.features.render.entity' (added by mods [oculus]) disables it and children 52[18jun.2024 04:39:13.726] [main/WARN] [Embeddium/]: Force-disabling mixin 'features.render.entity.fast_render.CuboidMixin' as rule 'mixin.features.render.entity' (added by mods [oculus]) disables it and children 53[18jun.2024 04:39:13.729] [main/WARN] [Embeddium/]: Force-disabling mixin 'features.render.entity.cull.EntityRendererMixin' as rule 'mixin.features.render.entity' (added by mods [oculus]) disables it and children 54[18jun.2024 04:39:15.111] [main/INFO] [MixinExtras|Service/]: Initializing MixinExtras via com.llamalad7.mixinextras.service.MixinExtrasServiceImpl(version=0.3.6). 55[18jun.2024 04:39:18.941] [pool-6-thread-1/INFO] [net.minecraft.server.Bootstrap/]: ModernFix reached bootstrap stage (29.23 s after launch) 56[18jun.2024 04:39:19.116] [pool-6-thread-1/WARN] [mixin/]: @Final field delegatesByName:Ljava/util/Map; in modernfix-forge.mixins.json:perf.forge_registry_alloc.ForgeRegistryMixin should be final 57[18jun.2024 04:39:19.116] [pool-6-thread-1/WARN] [mixin/]: @Final field delegatesByValue:Ljava/util/Map; in modernfix-forge.mixins.json:perf.forge_registry_alloc.ForgeRegistryMixin should be final [18jun.2024 04:39:21.577] [pool-6-thread-1/INFO] [net.minecraft.server.Bootstrap/]: Vanilla bootstrap took 2632 milliseconds
    • I have a workaround you first go into mods.toml and set ORDERING for the mod to = "BEFORE" just use Java to go into the compressed file using opensource code and you want to replace the texture there and then when minecraft loads or reloads it should be different
    • Get the latest AMD/ATI drivers from their website - do not update via system
  • Topics

×
×
  • Create New...

Important Information

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