Jump to content

Metadata group taking over all others


gellegbs

Recommended Posts

I have several food items (I haven't finished all my item classes), but the ones i do have running are being overwritten by my ItemFoodUtil class(I think the issue is metadata). Currently trying to get ItemSandwich and ItemSoup to work. Anyways.

 

 

Main Class

 

[embed=425,349]package foodstuffs;

 

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 foodstuffs.handlers.ConfigHandler;

import foodstuffs.items.Items;

import foodstuffs.lib.Reference;

import foodstuffs.proxy.CommonProxy;

 

 

       

 

 

       

 

 

        @Mod(modid = Reference.ID, name = Reference.NAME, version = Reference.VERSION)

        //for multiplayer ability

        @NetworkMod(channels = {Reference.CHANNEL}, clientSideRequired = true, serverSideRequired = false)

 

public class FoodStuffs {       

               

                //mod instance

        @Instance(Reference.ID)

        public static FoodStuffs instance;

 

        //note the proxy classes locations are added

        @SidedProxy(clientSide = "foodstuffs.proxy.ClientProxy", serverSide = "foodstuffs.proxy.CommonProxy" )

        public static CommonProxy proxy;

 

        //new to 1.6 annotation eventhandler

        @EventHandler

        public void preInit(FMLPreInitializationEvent event){

          //ConfigHandler.init(event.getSuggestedConfigurationFile());

          Items.init();

          // Blocks.init();

           

               

               

                }

        @EventHandler

        public void init(FMLInitializationEvent event){       

       

        // Blocks.addNames();

        Items.registerRecipes();

        // Blocks.registerTileEntities();

               

               

        }

        @EventHandler

        public void postInit(FMLPostInitializationEvent event){

               

               

                }

        }

[/embed]

 

 

ItemIds Class

 

[embed=425,349]package foodstuffs.items;

 

public class ItemIds {

 

       

        public static final String TEXTURE_LOCATION = "fm";

       

       

        public static int SANDWICH_ID;

        public static final String SANDWICH_KEY = "Sandwich";

        public static final int SANDWICH_DEFAULT = 10020;

        public static final String SANDWICH_UNLOCALIZED_NAME = "sandwich";

        public static final String[] SANDWICH_NAMES = {"Chicken Sandwich", "Egg Salad Sandwich", "Fish Sandwich", "Ham Sandwich", "Steak Sandwich"};

        public static final String[] SANDWICH_ICONS = {"chicken_sandwich", "eggsalad_sandwich", "fish_sandwich", "ham_sandwich", "steak_sandwich"};

       

        public static int SOUP_ID;

        public static final String SOUP_KEY = "Soup";

        public static final int SOUP_DEFAULT = 10021;

        public static final String SOUP_UNLOCALIZED_NAME = "soup";

        public static final String[] SOUP_NAMES = {"Beef Stew", "Chicken Soup", "Fish Soup", "Broth", "Egg Drop Soup"};

        public static final String[] SOUP_ICONS = {"beefstew", "chicken_soup", "fish_soup", "broth", "egg_drop_soup"};

       

        public static int CANNED_FOOD_ID;

        public static final String CANNED_FOOD_KEY = "Canned_food";

        public static final int CANNED_FOOD_DEFAULT = 10022;

        public static final String CANNED_FOOD_UNLOCALIZED_NAME = "cannedFood";

        public static final String[] CANNED_FOOD_NAMES = {"Canned Beef Stew", "Canned Carrots", "Canned Chicken Soup", "Canned Fish Soup", "Canned Nopalitos", "Canned Potatoes", "Spam"};

        public static final String[] CANNED_FOOD_ICONS = {"canned_beef_stew", "canned_carrot", "canned_chicken_soup", "canned_fish_soup", "canned_nopalitos", "canned_potato", "spam"};

       

        public static int SWEETS_ID;

        public static final String SWEETS_KEY = "Sweets";

        public static final int SWEETS_DEFAULT = 10023;

        public static final String SWEETS_UNLOCALIZED_NAME = "sweets";

        public static final String[] SWEETS_NAMES = {"Carrot Cake", "Chocolate Cake", "Chocolate Ice Cream", "Chocolate Pudding", "Ice Cream", "Melon Sherbet", "Pumpkin Sherbert", "Vanilla Pudding"};

        public static final String[] SWEETS_ICONS = {"carrot cake", "chocolate_cake", "chocolate_icecream", "chocolate_pudding", "icecream", "melon_sherbet", "pumpkin_sherbert", "vanilla_pudding"};

       

        public static int BEVERAGE_ID;

        public static final String BEVERAGE_KEY = "Beverage";

        public static final int BEVERAGE_DEFAULT = 10024;

        public static final String BEVERAGE_UNLOCALIZED_NAME = "beverage";

        public static final String[] BEVERAGE_NAMES = {"Cactus Juice", "Apple Juice", "Melon Juice", "Milk Jug", "Hot Milk", "Hot Chocolate", "Chocolate Milk", "Apple Cider" };

        public static final String [] BEVERAGE_ICONS = {"cactus_juice", "apple_juice", "melon juice", "milk_jug", "hot_milk", "hot_chocolate", "chocolate_milk", "apple_cider"};

       

        public static int FOOD_UTIL_ID;

        public static final String FOOD_UTIL_KEY = "FoodUtil";

        public static final int FOOD_UTIL_DEFAULT = 10025;

        public static final String FOOD_UTIL_UNLOCALIZED_NAME = "foodUtil";

        public static final String[] FOOD_UTIL_NAMES = {"Unprepared Broth", "Mayo", "Flour", "Oil", "Coacoa Powder", "Dough", "Potato Dough"};

        public static final String[] FOOD_UTIL_ICONS = {"unprepared_broth", "mayo", "flour", "oil", "coacoa", "dough", "potato_dough" };

       

        public static int SIDES_ID;

        public static final String SIDES_KEY = "Sides";

        public static final int SIDES_DEFAULT = 10026;

        public static final String SIDES_UNLOCALIZED_NAME = "sides";

        public static final String[] SIDES_NAMES = {"Cooked Egg", "Egg Salad", "Mashed Potatoes", "Nopalitos","Potato Cake", "Yogurt", "Carrot Souffle", "Apple Cured Ham"};

        public static final String[] SIDES_ICONS = {"cooked_egg", "egg_salad", "mashed_potato", "nopalitos", "potato_cake", "yogurt", "carrot_souffle", "apple_pork"} ;

       

       

        public static int GLASS_JAR_ID;

        public static final String GLASS_JAR_KEY = "Glass_jar";

        public static final int GLASS_JAR_DEFAULT = 10027;

        public static final String GLASS_JAR_UNLOCALIZED_NAME = "glassJar";

        public static final String GLASS_JAR_NAME = "Glass Jar";

        public static final String GLASS_JAR_ICON = "glass_jar";

       

 

        public static int MUG_ID;

        public static final String MUG_KEY = "Mug";

        public static final int MUG_DEFAULT = 10028;

        public static final String MUG_UNLOCALIZED_NAME = "mug";

        public static final String MUG_NAME = "Mug";

        public static final String MUG_ICON = "mug";

       

       

}[/embed]

 

Items Class (int he process of merging addNames method and init method, bad idea?)

[embed=425,349]package foodstuffs.items;

 

import cpw.mods.fml.common.registry.GameRegistry;

import cpw.mods.fml.common.registry.LanguageRegistry;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.item.crafting.FurnaceRecipes;

 

public class Items {

        public static Item sandwich;

        public static Item soup;

        public static Item canned_food;

        public static Item sweets;

        public static Item beverage;

        public static Item food_util;

        public static Item sides;

        public static Item glass_jar;

        public static Item mug;

       

       

        public static void init(){

               

                sandwich = new ItemSandwich(ItemIds.SANDWICH_ID, 0);

               

                for (int i = 0; i < ItemIds.SANDWICH_NAMES.length; i++){

                    LanguageRegistry.addName(new ItemStack(sandwich, 1, i), ItemIds.SANDWICH_NAMES);

       

                }

               

                soup = new ItemSoup(ItemIds.SOUP_ID, 0);

               

                for (int i = 0; i < ItemIds.SOUP_NAMES.length; i++){

            LanguageRegistry.addName(new ItemStack(soup, 1, i), ItemIds.SOUP_NAMES);

        }

               

               

                canned_food = new ItemCannedFood(ItemIds.CANNED_FOOD_ID, ItemIds.CANNED_FOOD_DEFAULT);

               

                for (int i = 0; i < ItemIds.CANNED_FOOD_NAMES.length; i++){

            LanguageRegistry.addName(new ItemStack(canned_food, 1, i), ItemIds.CANNED_FOOD_NAMES);

        }

 

               

                food_util = new ItemFoodUtil(ItemIds.FOOD_UTIL_ID, ItemIds.FOOD_UTIL_DEFAULT);

               

                for (int i = 0; i < ItemIds.FOOD_UTIL_NAMES.length; i++){

                    LanguageRegistry.addName(new ItemStack(food_util, 1, i), ItemIds.FOOD_UTIL_NAMES);

                }

               

        }

       

       

       

        // public static void addNames(){ }

       

        public static void registerRecipes(){

               

                //sandwiches

               

                GameRegistry.addShapelessRecipe(new ItemStack(sandwich, 1, 0), new ItemStack(Item.bread), new ItemStack(Item.chickenCooked), new ItemStack(Item.bread));

                GameRegistry.addShapelessRecipe(new ItemStack(sandwich, 1, 1), new ItemStack(Item.bread), new ItemStack(ItemIds.SIDES_ID, 1, 0), new ItemStack(Item.bread));

                GameRegistry.addShapelessRecipe(new ItemStack(sandwich, 1, 2), new ItemStack(Item.bread), new ItemStack(Item.fishCooked), new ItemStack(Item.bread));

                GameRegistry.addShapelessRecipe(new ItemStack(sandwich, 1, 3), new ItemStack(Item.bread), new ItemStack(ItemIds.SIDES_ID, 1, 7), new ItemStack(Item.bread));

                GameRegistry.addShapelessRecipe(new ItemStack(sandwich, 1, 1), new ItemStack(Item.bread), new ItemStack(Item.beefCooked), new ItemStack(Item.bread));

               

                //soups

               

                GameRegistry.addShapelessRecipe(new ItemStack(soup, 2, 0), new ItemStack(Item.bowlEmpty), new ItemStack(Item.beefRaw), new ItemStack(Item.carrot), new ItemStack(Item.potato), new ItemStack(ItemIds.SOUP_ID, 1, 4));

                GameRegistry.addShapelessRecipe(new ItemStack(soup, 2, 1), new ItemStack(Item.bowlEmpty), new ItemStack(Item.chickenRaw), new ItemStack(Item.carrot), new ItemStack(Item.potato), new ItemStack(ItemIds.SOUP_ID, 1, 4));

                GameRegistry.addShapelessRecipe(new ItemStack(soup, 2, 2), new ItemStack(Item.bowlEmpty), new ItemStack(Item.fishRaw), new ItemStack(Item.carrot), new ItemStack(Item.potato), new ItemStack(ItemIds.SOUP_ID, 1, 4));

 

                FurnaceRecipes.smelting().addSmelting(ItemIds.FOOD_UTIL_DEFAULT, 0, new ItemStack(soup, 1, 3), 0F);

               

                //canned

               

                //sweets

               

                //beverage

               

                //food utilities

               

                GameRegistry.addShapelessRecipe(new ItemStack(food_util, 1, 0), new ItemStack(Item.bucketWater), new ItemStack(Item.beefRaw));

                GameRegistry.addShapelessRecipe(new ItemStack(food_util, 1, 0), new ItemStack(Item.bucketWater), new ItemStack(Item.chickenRaw));

                GameRegistry.addShapelessRecipe(new ItemStack(food_util, 1, 0), new ItemStack(Item.bucketWater), new ItemStack(Item.fishRaw));

                GameRegistry.addShapelessRecipe(new ItemStack(food_util, 1, 0), new ItemStack(Item.bucketWater), new ItemStack(Item.porkRaw));

               

                //sides

               

                //other

        }

}[/embed]

 

ItemFoodUtil class (overwritting the other items)

[embed=425,349]package foodstuffs.items;

 

import java.util.List;

 

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.client.renderer.texture.IconRegister;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.item.Item;

import net.minecraft.item.ItemFood;

import net.minecraft.item.ItemStack;

import net.minecraft.util.Icon;

 

public class ItemFoodUtil extends ItemFood{

       

        @SideOnly(Side.CLIENT)

    private Icon[] icons;

   

 

    public ItemFoodUtil(int id, int heal){

        super(id, heal, 0F, false);

        setCreativeTab(CreativeTabs.tabFood);

        setHasSubtypes(true);

        this.setAlwaysEdible();

     

       

  }

   

 

        @Override

    public String getUnlocalizedName(ItemStack itemstack){

        return ItemIds.FOOD_UTIL_UNLOCALIZED_NAME + itemstack.getItemDamage();

    }

   

    @Override

    @SideOnly(Side.CLIENT)

    public void registerIcons(IconRegister register){

        icons = new Icon[itemIds.FOOD_UTIL_ICONS.length];

       

        for (int i = 0; i < icons.length; i++){

            icons = register.registerIcon(ItemIds.TEXTURE_LOCATION + ":" + ItemIds.FOOD_UTIL_ICONS);

        }

       

    }

   

    @Override

    @SideOnly(Side.CLIENT)

    public Icon getIconFromDamage(int dmg){

        return icons[dmg];

    }

   

 

    @Override

    @SideOnly(Side.CLIENT)

    public void getSubItems(int id, CreativeTabs tabs, List list){

        for (int i = 0; i < ItemIds.FOOD_UTIL_NAMES.length; i++){

            ItemStack itemstack =  new ItemStack (id, 1, i);

            list.add(itemstack);

        }

       

     

    }

}

 

[/embed]

 

ItemSandwich class (being overwritten)

[embed=425,349]package foodstuffs.items;

 

import java.util.List;

 

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.client.renderer.texture.IconRegister;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.Item;

import net.minecraft.item.ItemFood;

import net.minecraft.item.ItemStack;

import net.minecraft.util.Icon;

import net.minecraft.world.World;

 

public class ItemSandwich extends ItemFood{

       

       

        @SideOnly(Side.CLIENT)

    private Icon[] icons;

   

 

    public ItemSandwich(int id, int heal){

        super(id, heal, 4.8F, false);

        setCreativeTab(CreativeTabs.tabFood);

        setHasSubtypes(true);

        this.setAlwaysEdible();

       

  }

   

   

   

        @Override

    public String getUnlocalizedName(ItemStack itemstack){

        return ItemIds.SANDWICH_UNLOCALIZED_NAME + itemstack.getItemDamage();

    }

 

   

    @SideOnly(Side.CLIENT)

    @Override

    public Icon getIconFromDamage (int dmg)

    {

        return icons[dmg];

    }

   

     

          @SideOnly(Side.CLIENT)

            @Override

            public void registerIcons (IconRegister iconRegister)

            {

                this.icons = new Icon[itemIds.SANDWICH_NAMES.length];

 

                for (int i = 0; i < this.icons.length; ++i)

                {

                    this.icons = iconRegister.registerIcon(ItemIds.TEXTURE_LOCATION + ItemIds.SANDWICH_NAMES);

                }

            }

         

            @Override

            @SideOnly(Side.CLIENT)

            public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4)

            {

                list.add("Sammich");

            }

 

       

           

 

    @Override

    @SideOnly(Side.CLIENT)

    public void getSubItems(int id, CreativeTabs tabs, List list){

        for (int i = 0; i < ItemIds.SANDWICH_NAMES.length; i++){

            ItemStack itemstack =  new ItemStack (id, 1, i);

            list.add(itemstack);

        }

       

     

    }

}[/embed]

 

ItemSoupClass (being overwritten)

[embed=425,349]package foodstuffs.items;

 

import java.util.List;

 

import net.minecraft.client.renderer.texture.IconRegister;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.Item;

import net.minecraft.item.ItemFood;

import net.minecraft.item.ItemStack;

import net.minecraft.util.Icon;

import net.minecraft.world.World;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

 

public class ItemSoup extends ItemFood {

       

        @SideOnly(Side.CLIENT)

    private Icon[] icons;

   

 

    public ItemSoup(int id, int heal){

        super(id, heal, 4.8F, false);

        setMaxDamage(0);

        setCreativeTab(CreativeTabs.tabFood);

        setHasSubtypes(true);

        this.setAlwaysEdible();

       

  }

   

 

   

    @Override

    public ItemStack onEaten (ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)

    {

        ItemStack stack = super.onEaten(par1ItemStack, par2World, par3EntityPlayer);

 

        if (!par3EntityPlayer.capabilities.isCreativeMode)

        {

            if (par1ItemStack.stackSize <= 0)

            {

                return new ItemStack(Item.bowlEmpty);

            }

 

            par3EntityPlayer.inventory.addItemStackToInventory(new ItemStack(Item.bowlEmpty));

        }

 

        return stack;

    }

   

    @SideOnly(Side.CLIENT)

    @Override

    public Icon getIconFromDamage (int dmg)

    {

        return icons[dmg];

    }

 

    @SideOnly(Side.CLIENT)

    @Override

    public void registerIcons (IconRegister iconRegister)

    {

        this.icons = new Icon[itemIds.SOUP_NAMES.length];

 

        for (int i = 0; i < this.icons.length; ++i)

        {

            this.icons = iconRegister.registerIcon(ItemIds.TEXTURE_LOCATION + ItemIds.SOUP_NAMES);

        }

    }

 

    @Override

    @SideOnly(Side.CLIENT)

    public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4)

    {

        list.add("Mmm mmm good!");

    }

 

        @Override

    public String getUnlocalizedName(ItemStack itemstack){

        return ItemIds.SOUP_UNLOCALIZED_NAME + itemstack.getItemDamage();

    }

       

 

        @Override

            @SideOnly(Side.CLIENT)

            public void getSubItems(int id, CreativeTabs tabs, List list){

                for (int i = 0; i < ItemIds.SOUP_NAMES.length; i++){

                    ItemStack itemstack =  new ItemStack (id, 1, i);

                    list.add(itemstack);

                }

               

        }   

}[/embed]

 

 

Thanks!

Link to comment
Share on other sites

can you please use

 

the code tag, so we dont have to scroll for ours


btw here how you do them

[code]

my code

[/$code]
without the dollar sign (the forums will close the code tag if i dont put the dollar sign)
also you can click the # icon in the reply editor to insta paste that

 

thank you :D

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

can you please use

 

the code tag, so we dont have to scroll for ours


btw here how you do them

[code]

my code

[/$code]
without the dollar sign (the forums will close the code tag if i dont put the dollar sign)
also you can click the # icon in the reply editor to insta paste that

 

thank you :D

 

ok sorry.

 

main class

package foodstuffs;

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 foodstuffs.handlers.ConfigHandler;
import foodstuffs.items.Items;
import foodstuffs.lib.Reference;
import foodstuffs.proxy.CommonProxy;


        


        


        @Mod(modid = Reference.ID, name = Reference.NAME, version = Reference.VERSION)
        //for multiplayer ability
        @NetworkMod(channels = {Reference.CHANNEL}, clientSideRequired = true, serverSideRequired = false)

public class FoodStuffs {        
                
                //mod instance
        @Instance(Reference.ID)
        public static FoodStuffs instance;

        //note the proxy classes locations are added
        @SidedProxy(clientSide = "foodstuffs.proxy.ClientProxy", serverSide = "foodstuffs.proxy.CommonProxy" )
        public static CommonProxy proxy;

        //new to 1.6 annotation eventhandler
        @EventHandler
        public void preInit(FMLPreInitializationEvent event){
           //ConfigHandler.init(event.getSuggestedConfigurationFile());
           Items.init();
          // Blocks.init();
            
                
                
                }
        @EventHandler
        public void init(FMLInitializationEvent event){        
        
        // Blocks.addNames();
         Items.registerRecipes();
        // Blocks.registerTileEntities();
                
                
        }
        @EventHandler
        public void postInit(FMLPostInitializationEvent event){
                
                
                }
        }

 

Items Class

package foodstuffs.items;

import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;

public class Items {
        public static Item sandwich;
        public static Item soup;
        public static Item canned_food;
        public static Item sweets;
        public static Item beverage;
        public static Item food_util;
        public static Item sides;
        public static Item glass_jar;
        public static Item mug;
        
        
        public static void init(){
                
                sandwich = new ItemSandwich(ItemIds.SANDWICH_ID, 0);
                
                 for (int i = 0; i < ItemIds.SANDWICH_NAMES.length; i++){
                    LanguageRegistry.addName(new ItemStack(sandwich, 1, i), ItemIds.SANDWICH_NAMES[i]);
        
                }
                
                soup = new ItemSoup(ItemIds.SOUP_ID, 0);
                
                for (int i = 0; i < ItemIds.SOUP_NAMES.length; i++){
            LanguageRegistry.addName(new ItemStack(soup, 1, i), ItemIds.SOUP_NAMES[i]);
         }
                
                
                canned_food = new ItemCannedFood(ItemIds.CANNED_FOOD_ID, ItemIds.CANNED_FOOD_DEFAULT);
                
                for (int i = 0; i < ItemIds.CANNED_FOOD_NAMES.length; i++){
            LanguageRegistry.addName(new ItemStack(canned_food, 1, i), ItemIds.CANNED_FOOD_NAMES[i]);
         }

                
                food_util = new ItemFoodUtil(ItemIds.FOOD_UTIL_ID, ItemIds.FOOD_UTIL_DEFAULT);
                 
                for (int i = 0; i < ItemIds.FOOD_UTIL_NAMES.length; i++){
                    LanguageRegistry.addName(new ItemStack(food_util, 1, i), ItemIds.FOOD_UTIL_NAMES[i]);
                 }
                
        }
        
        
        
        // public static void addNames(){ }
         
         public static void registerRecipes(){
                 
                 //sandwiches
                 
                 GameRegistry.addShapelessRecipe(new ItemStack(sandwich, 1, 0), new ItemStack(Item.bread), new ItemStack(Item.chickenCooked), new ItemStack(Item.bread));
                 GameRegistry.addShapelessRecipe(new ItemStack(sandwich, 1, 1), new ItemStack(Item.bread), new ItemStack(ItemIds.SIDES_ID, 1, 0), new ItemStack(Item.bread));
                 GameRegistry.addShapelessRecipe(new ItemStack(sandwich, 1, 2), new ItemStack(Item.bread), new ItemStack(Item.fishCooked), new ItemStack(Item.bread));
                 GameRegistry.addShapelessRecipe(new ItemStack(sandwich, 1, 3), new ItemStack(Item.bread), new ItemStack(ItemIds.SIDES_ID, 1, 7), new ItemStack(Item.bread));
                 GameRegistry.addShapelessRecipe(new ItemStack(sandwich, 1, 1), new ItemStack(Item.bread), new ItemStack(Item.beefCooked), new ItemStack(Item.bread));
                 
                 //soups
                 
                 GameRegistry.addShapelessRecipe(new ItemStack(soup, 2, 0), new ItemStack(Item.bowlEmpty), new ItemStack(Item.beefRaw), new ItemStack(Item.carrot), new ItemStack(Item.potato), new ItemStack(ItemIds.SOUP_ID, 1, 4));
                 GameRegistry.addShapelessRecipe(new ItemStack(soup, 2, 1), new ItemStack(Item.bowlEmpty), new ItemStack(Item.chickenRaw), new ItemStack(Item.carrot), new ItemStack(Item.potato), new ItemStack(ItemIds.SOUP_ID, 1, 4));
                 GameRegistry.addShapelessRecipe(new ItemStack(soup, 2, 2), new ItemStack(Item.bowlEmpty), new ItemStack(Item.fishRaw), new ItemStack(Item.carrot), new ItemStack(Item.potato), new ItemStack(ItemIds.SOUP_ID, 1, 4));

                 FurnaceRecipes.smelting().addSmelting(ItemIds.FOOD_UTIL_DEFAULT, 0, new ItemStack(soup, 1, 3), 0F);
                 
                 //canned
                 
                 //sweets
                 
                 //beverage
                 
                 //food utilities
                 
                 GameRegistry.addShapelessRecipe(new ItemStack(food_util, 1, 0), new ItemStack(Item.bucketWater), new ItemStack(Item.beefRaw));
                 GameRegistry.addShapelessRecipe(new ItemStack(food_util, 1, 0), new ItemStack(Item.bucketWater), new ItemStack(Item.chickenRaw));
                 GameRegistry.addShapelessRecipe(new ItemStack(food_util, 1, 0), new ItemStack(Item.bucketWater), new ItemStack(Item.fishRaw));
                 GameRegistry.addShapelessRecipe(new ItemStack(food_util, 1, 0), new ItemStack(Item.bucketWater), new ItemStack(Item.porkRaw));
                 
                 //sides
                 
                 //other
         }
}

 

ItemIds Class

package foodstuffs.items;

public class ItemIds {

        
        public static final String TEXTURE_LOCATION = "fm";
        
        
        public static int SANDWICH_ID;
        public static final String SANDWICH_KEY = "Sandwich";
        public static final int SANDWICH_DEFAULT = 10020;
        public static final String SANDWICH_UNLOCALIZED_NAME = "sandwich";
        public static final String[] SANDWICH_NAMES = {"Chicken Sandwich", "Egg Salad Sandwich", "Fish Sandwich", "Ham Sandwich", "Steak Sandwich"};
        public static final String[] SANDWICH_ICONS = {"chicken_sandwich", "eggsalad_sandwich", "fish_sandwich", "ham_sandwich", "steak_sandwich"};
        
        public static int SOUP_ID;
        public static final String SOUP_KEY = "Soup";
        public static final int SOUP_DEFAULT = 10021;
        public static final String SOUP_UNLOCALIZED_NAME = "soup";
        public static final String[] SOUP_NAMES = {"Beef Stew", "Chicken Soup", "Fish Soup", "Broth", "Egg Drop Soup"};
        public static final String[] SOUP_ICONS = {"beefstew", "chicken_soup", "fish_soup", "broth", "egg_drop_soup"};
        
        public static int CANNED_FOOD_ID;
        public static final String CANNED_FOOD_KEY = "Canned_food";
        public static final int CANNED_FOOD_DEFAULT = 10022;
        public static final String CANNED_FOOD_UNLOCALIZED_NAME = "cannedFood";
        public static final String[] CANNED_FOOD_NAMES = {"Canned Beef Stew", "Canned Carrots", "Canned Chicken Soup", "Canned Fish Soup", "Canned Nopalitos", "Canned Potatoes", "Spam"};
        public static final String[] CANNED_FOOD_ICONS = {"canned_beef_stew", "canned_carrot", "canned_chicken_soup", "canned_fish_soup", "canned_nopalitos", "canned_potato", "spam"};
        
        public static int SWEETS_ID;
        public static final String SWEETS_KEY = "Sweets";
        public static final int SWEETS_DEFAULT = 10023;
        public static final String SWEETS_UNLOCALIZED_NAME = "sweets";
        public static final String[] SWEETS_NAMES = {"Carrot Cake", "Chocolate Cake", "Chocolate Ice Cream", "Chocolate Pudding", "Ice Cream", "Melon Sherbet", "Pumpkin Sherbert", "Vanilla Pudding"};
        public static final String[] SWEETS_ICONS = {"carrot cake", "chocolate_cake", "chocolate_icecream", "chocolate_pudding", "icecream", "melon_sherbet", "pumpkin_sherbert", "vanilla_pudding"};
        
        public static int BEVERAGE_ID;
        public static final String BEVERAGE_KEY = "Beverage";
        public static final int BEVERAGE_DEFAULT = 10024;
        public static final String BEVERAGE_UNLOCALIZED_NAME = "beverage";
        public static final String[] BEVERAGE_NAMES = {"Cactus Juice", "Apple Juice", "Melon Juice", "Milk Jug", "Hot Milk", "Hot Chocolate", "Chocolate Milk", "Apple Cider" };
        public static final String [] BEVERAGE_ICONS = {"cactus_juice", "apple_juice", "melon juice", "milk_jug", "hot_milk", "hot_chocolate", "chocolate_milk", "apple_cider"};
        
        public static int FOOD_UTIL_ID;
        public static final String FOOD_UTIL_KEY = "FoodUtil";
        public static final int FOOD_UTIL_DEFAULT = 10025;
        public static final String FOOD_UTIL_UNLOCALIZED_NAME = "foodUtil";
        public static final String[] FOOD_UTIL_NAMES = {"Unprepared Broth", "Mayo", "Flour", "Oil", "Coacoa Powder", "Dough", "Potato Dough"};
        public static final String[] FOOD_UTIL_ICONS = {"unprepared_broth", "mayo", "flour", "oil", "coacoa", "dough", "potato_dough" };
        
        public static int SIDES_ID;
        public static final String SIDES_KEY = "Sides";
        public static final int SIDES_DEFAULT = 10026;
        public static final String SIDES_UNLOCALIZED_NAME = "sides";
        public static final String[] SIDES_NAMES = {"Cooked Egg", "Egg Salad", "Mashed Potatoes", "Nopalitos","Potato Cake", "Yogurt", "Carrot Souffle", "Apple Cured Ham"};
        public static final String[] SIDES_ICONS = {"cooked_egg", "egg_salad", "mashed_potato", "nopalitos", "potato_cake", "yogurt", "carrot_souffle", "apple_pork"} ;
        
        
        public static int GLASS_JAR_ID;
        public static final String GLASS_JAR_KEY = "Glass_jar";
        public static final int GLASS_JAR_DEFAULT = 10027;
        public static final String GLASS_JAR_UNLOCALIZED_NAME = "glassJar";
        public static final String GLASS_JAR_NAME = "Glass Jar";
        public static final String GLASS_JAR_ICON = "glass_jar";
        

        public static int MUG_ID;
        public static final String MUG_KEY = "Mug";
        public static final int MUG_DEFAULT = 10028;
        public static final String MUG_UNLOCALIZED_NAME = "mug";
        public static final String MUG_NAME = "Mug";
        public static final String MUG_ICON = "mug";
        
        
}

 

ItemFoodUtil (the one over writing)

package foodstuffs.items;

import java.util.List;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;

public class ItemFoodUtil extends ItemFood{
        
        @SideOnly(Side.CLIENT)
    private Icon[] icons;
    
  
    public ItemFoodUtil(int id, int heal){
        super(id, heal, 0F, false);
        setCreativeTab(CreativeTabs.tabFood);
        setHasSubtypes(true);
        this.setAlwaysEdible();
       
        
  }
    

        @Override
    public String getUnlocalizedName(ItemStack itemstack){
        return ItemIds.FOOD_UTIL_UNLOCALIZED_NAME + itemstack.getItemDamage(); 
    }
    
    @Override
    @SideOnly(Side.CLIENT)
    public void registerIcons(IconRegister register){
        icons = new Icon[itemIds.FOOD_UTIL_ICONS.length];
        
        for (int i = 0; i < icons.length; i++){
            icons[i] = register.registerIcon(ItemIds.TEXTURE_LOCATION + ":" + ItemIds.FOOD_UTIL_ICONS[i]);
        }
        
    }
    
    @Override
    @SideOnly(Side.CLIENT)
    public Icon getIconFromDamage(int dmg){
        return icons[dmg];
    }
    

    @Override
    @SideOnly(Side.CLIENT)
    public void getSubItems(int id, CreativeTabs tabs, List list){
        for (int i = 0; i < ItemIds.FOOD_UTIL_NAMES.length; i++){
            ItemStack itemstack =  new ItemStack (id, 1, i);
            list.add(itemstack);
        }
        
       
    }
}

 

ItemSoup class (being overwritten)

package foodstuffs.items;

import java.util.List;

import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class ItemSoup extends ItemFood {
        
        @SideOnly(Side.CLIENT)
    private Icon[] icons;
    
  
    public ItemSoup(int id, int heal){
        super(id, heal, 4.8F, false);
        setMaxDamage(0);
        setCreativeTab(CreativeTabs.tabFood);
        setHasSubtypes(true);
        this.setAlwaysEdible();
        
  }
    
   
    
    @Override
    public ItemStack onEaten (ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
    {
        ItemStack stack = super.onEaten(par1ItemStack, par2World, par3EntityPlayer);

        if (!par3EntityPlayer.capabilities.isCreativeMode)
        {
            if (par1ItemStack.stackSize <= 0)
            {
                return new ItemStack(Item.bowlEmpty);
            }

            par3EntityPlayer.inventory.addItemStackToInventory(new ItemStack(Item.bowlEmpty));
        }

        return stack;
    } 
    
    @SideOnly(Side.CLIENT)
    @Override
    public Icon getIconFromDamage (int dmg)
    {
        return icons[dmg];
    }

    @SideOnly(Side.CLIENT)
    @Override
    public void registerIcons (IconRegister iconRegister)
    {
        this.icons = new Icon[itemIds.SOUP_NAMES.length];

        for (int i = 0; i < this.icons.length; ++i)
        {
            this.icons[i] = iconRegister.registerIcon(ItemIds.TEXTURE_LOCATION + ItemIds.SOUP_NAMES[i]);
        }
    }

    @Override
    @SideOnly(Side.CLIENT)
    public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4)
    {
        list.add("Mmm mmm good!");
    }

        @Override
    public String getUnlocalizedName(ItemStack itemstack){
        return ItemIds.SOUP_UNLOCALIZED_NAME + itemstack.getItemDamage(); 
    }
         
   
         @Override
            @SideOnly(Side.CLIENT)
            public void getSubItems(int id, CreativeTabs tabs, List list){
                for (int i = 0; i < ItemIds.SOUP_NAMES.length; i++){
                    ItemStack itemstack =  new ItemStack (id, 1, i);
                    list.add(itemstack);
                }
                
         }    
}

 

ItemSandwich (being overwritten too, not all my itemx classes are made)

package foodstuffs.items;

import java.util.List;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.world.World;

public class ItemSandwich extends ItemFood{
        
        
        @SideOnly(Side.CLIENT)
    private Icon[] icons;
    
  
    public ItemSandwich(int id, int heal){
        super(id, heal, 4.8F, false);
        setCreativeTab(CreativeTabs.tabFood);
        setHasSubtypes(true);
        this.setAlwaysEdible();
        
  }
    
    
    
        @Override
    public String getUnlocalizedName(ItemStack itemstack){
        return ItemIds.SANDWICH_UNLOCALIZED_NAME + itemstack.getItemDamage(); 
    }
  
    
    @SideOnly(Side.CLIENT)
    @Override
    public Icon getIconFromDamage (int dmg)
    {
        return icons[dmg];
    }
    
      
          @SideOnly(Side.CLIENT)
            @Override
            public void registerIcons (IconRegister iconRegister)
            {
                this.icons = new Icon[itemIds.SANDWICH_NAMES.length];

                for (int i = 0; i < this.icons.length; ++i)
                {
                    this.icons[i] = iconRegister.registerIcon(ItemIds.TEXTURE_LOCATION + ItemIds.SANDWICH_NAMES[i]);
                }
            }
          
            @Override
            @SideOnly(Side.CLIENT)
            public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4)
            {
                list.add("Sammich");
            }

        
            

    @Override
    @SideOnly(Side.CLIENT)
    public void getSubItems(int id, CreativeTabs tabs, List list){
        for (int i = 0; i < ItemIds.SANDWICH_NAMES.length; i++){
            ItemStack itemstack =  new ItemStack (id, 1, i);
            list.add(itemstack);
        }
        
       
    }
}

 

In creative the only items that show are the ones from the ItemFoodUtil.class they are named correctly and have the correct icons, but all the recipes that are from the other present item classes are corresponding to the meta from the ItemFoodUtil.class, so instead of 2 bread + fish = fish sandwich, it makes flour which has the same meta 3 as the fish sandwich.

 

Link to comment
Share on other sites

gellegbs you do not have to use metadata for food. its a great way to save itemids but its much more work to install them (my thinking) here is a universal class i made for the baconMod.

Its handel the food and crafing in it^^"

 

A thing before! Do not tell: this is wrong or something! Everything in this code i post now is working correct:

 

Normal Food:

package minecraftwero.baconMod.common.items;

import java.util.List;

import minecraftwero.baconMod.Bacon;
import minecraftwero.baconMod.common.config.BaconItems;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

/**
* 
* @author Speiger
*
*/
public class ItemBaconFood extends ItemFood 
{
private String name;
public String texture;
private PotionEffect[] potion;

public ItemBaconFood(int par1, int par2, boolean par3, String par4, String par5,  PotionEffect...par7) 
{
	super(par1, par2, par3);
	this.setCreativeTab(Bacon.baconMod);
	name = par4;
	texture = par5;
	potion = par7;
	this.setTextureName(par5);
}

public ItemBaconFood(int par1, int par2, boolean par3, String par4, String par5)
{
	this(par1, par2, par3, par4, par5, new PotionEffect(0, 0, 0));
}




public String getItemDisplayName(ItemStack par1)
{
	return name;
}


@SideOnly(Side.CLIENT)
@Override
public void registerIcons(IconRegister par1IconRegister)
{
	this.itemIcon = par1IconRegister.registerIcon(texture);
}

@Override
public ItemStack onEaten(ItemStack par1, World par2, EntityPlayer par3) 
{
        --par1.stackSize;
        par3.getFoodStats().addStats(this);
        par2.playSoundAtEntity(par3, "random.burp", 0.5F, par2.rand.nextFloat() * 0.1F + 0.9F);
        addPotions(par1, par2, par3);
	return par1;
}

public void addPotions(ItemStack par1, World par2, EntityPlayer par3)
{
	for(int i = 0; i<potion.length;i++)
	{
		if(potion[i] != null && potion[i].getPotionID() > 0 && !par2.isRemote)
		{
			par3.addPotionEffect(new PotionEffect(potion[i]));
		}
	}
}





}

 

This FoodClass handel also LanguageRegisty.addName so that is no longer needed xD

 

Now to the Crafting Food class:

It handels a damagecrafting. you can choose how much damage the food after eating gets (more than 1 time eatable) and also (when its a container item) how much damage it gets when you use it at crafting.

 

Crafting Food:

package minecraftwero.baconMod.common.items;

import java.util.List;

import minecraftwero.baconMod.Bacon;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class CraftingFood extends Item  
{

private String var1;
private String var2;
private int var3;
private boolean var4;
private int var5;
private int var6;
private PotionEffect[] var7;
public CraftingFood(int par1, int damage, int damageonCraft, int damageonEat, int extrafood, boolean alwaysEatable, String name, String texture, PotionEffect...effect) 
{
	super(par1);
	this.setCreativeTab(Bacon.baconMod);
	this.setNoRepair();
	this.var5 = damageonCraft;
	var6 = damageonEat;
	this.setMaxDamage(damage);
	this.setMaxStackSize(1);
	var1 = name;
	var2 = texture;
	var3 = extrafood;
	var4 = alwaysEatable;
	var7 = effect;
	this.setTextureName(texture);
}

public CraftingFood(int par1, int damage, int extrafood, boolean alwaysEatable, String name, String texture)
{
	this(par1, damage, 1, 1, extrafood, alwaysEatable, name, texture);
}

@Override
public boolean doesContainerItemLeaveCraftingGrid(ItemStack par1ItemStack) 
{
	return false;
}

@Override
public String getItemDisplayName(ItemStack par1ItemStack) 
{
	return var1;
}

    public int getMaxItemUseDuration(ItemStack par1ItemStack)
    {
        return 32;
    }
    
    public EnumAction getItemUseAction(ItemStack par1ItemStack)
    {
        return EnumAction.eat;
    }
    
@Override
public ItemStack onItemRightClick(ItemStack par1, World par2, EntityPlayer par3) 
{
	if(par3.canEat(var4))
	{
		par3.setItemInUse(par1, this.getMaxItemUseDuration(par1));
	}
	return par1;
}


@Override
public ItemStack onEaten(ItemStack par1, World par2, EntityPlayer par3) 
{
	par1.damageItem(var6, par3);
	par3.getFoodStats().addStats(var3, 0.6F);
        par2.playSoundAtEntity(par3, "random.burp", 0.5F, par2.rand.nextFloat() * 0.1F + 0.9F);
        addPotionEffect(par1, par2, par3);
	return par1;
}

public void addPotionEffect(ItemStack par1, World par2, EntityPlayer par3) 
{
	for(int i = 0; i<var7.length;i++)
	{
		if(var7[i].getPotionID() > 0 && var7[i] != null)
		{
			par3.addPotionEffect(var7[i]);
		}
	}
}

@SideOnly(Side.CLIENT)
@Override
public void registerIcons(IconRegister par1IconRegister)
{
	this.itemIcon = par1IconRegister.registerIcon(var2);
}

@Override
public ItemStack getContainerItemStack(ItemStack itemStack) 
{
	itemStack.setItemDamage(itemStack.getItemDamage()+var5);
	return itemStack;

}




}

 

I hope these examples help you out^^"

Link to comment
Share on other sites

You never set your item ids in ItemIds class.

And your "default id"s are used for the healing amount in the ItemFoodUtil constructor.

 

Thank you for reminding me about registering items. I do all that in my Items class though not ItemIds I like to keep my ItemIds( or BlockIds) full of references and not methods that do anything. I'm still trying to figure out how I like to structure things like the init method etc., I was thinking of adding the name registry to it, maybe even the recipes but that may be going overboard. Anyways i digress. I saw that healing thing you pointed out and didn't finish fixing all of them, so i did that the Items class now looks like this.

 

package foodstuffs.items;

import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import foodstuffs.lib.Reference;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;

public class Items {
public static Item sandwich;
public static Item soup;
public static Item canned_food;
public static Item sweets;
public static Item beverage;
public static Item food_util;
public static Item sides;
public static Item glass_jar;
public static Item mug;


public static void init(){

	sandwich = new ItemSandwich(ItemIds.SANDWICH_ID, 0);
	GameRegistry.registerItem(sandwich, Reference.ID + ItemIds.SANDWICH_UNLOCALIZED_NAME) ;
	 for (int i = 0; i < ItemIds.SANDWICH_NAMES.length; i++){
            LanguageRegistry.addName(new ItemStack(sandwich, 1, i), ItemIds.SANDWICH_NAMES[i]);
            
	}


	soup = new ItemSoup(ItemIds.SOUP_ID, 0);
	GameRegistry.registerItem(soup, Reference.ID + ItemIds.SOUP_UNLOCALIZED_NAME);
	for (int i = 0; i < ItemIds.SOUP_NAMES.length; i++){
            LanguageRegistry.addName(new ItemStack(soup, 1, i), ItemIds.SOUP_NAMES[i]);
 }


	canned_food = new ItemCannedFood(ItemIds.CANNED_FOOD_ID, 0);
	GameRegistry.registerItem(canned_food, Reference.ID + ItemIds.CANNED_FOOD_UNLOCALIZED_NAME);
	for (int i = 0; i < ItemIds.CANNED_FOOD_NAMES.length; i++){
            LanguageRegistry.addName(new ItemStack(canned_food, 1, i), ItemIds.CANNED_FOOD_NAMES[i]);
 }



	food_util = new ItemFoodUtil(ItemIds.FOOD_UTIL_ID, 0);
	 GameRegistry.registerItem(canned_food, Reference.ID + ItemIds.FOOD_UTIL_UNLOCALIZED_NAME);
	for (int i = 0; i < ItemIds.FOOD_UTIL_NAMES.length; i++){
            LanguageRegistry.addName(new ItemStack(food_util, 1, i), ItemIds.FOOD_UTIL_NAMES[i]);
	 }


}



// public static void addNames(){ }

 public static void registerRecipes(){

	 //sandwiches

	 GameRegistry.addShapelessRecipe(new ItemStack(sandwich, 1, 0), new ItemStack(Item.bread), new ItemStack(Item.chickenCooked), new ItemStack(Item.bread));
	 GameRegistry.addShapelessRecipe(new ItemStack(sandwich, 1, 1), new ItemStack(Item.bread), new ItemStack(ItemIds.SIDES_ID, 1, 0), new ItemStack(Item.bread));
	 GameRegistry.addShapelessRecipe(new ItemStack(sandwich, 1, 2), new ItemStack(Item.bread), new ItemStack(Item.fishCooked), new ItemStack(Item.bread));
	 GameRegistry.addShapelessRecipe(new ItemStack(sandwich, 1, 3), new ItemStack(Item.bread), new ItemStack(ItemIds.SIDES_ID, 1, 7), new ItemStack(Item.bread));
	 GameRegistry.addShapelessRecipe(new ItemStack(sandwich, 1, 1), new ItemStack(Item.bread), new ItemStack(Item.beefCooked), new ItemStack(Item.bread));

	 //soups

	 GameRegistry.addShapelessRecipe(new ItemStack(soup, 2, 0), new ItemStack(Item.bowlEmpty), new ItemStack(Item.beefRaw), new ItemStack(Item.carrot), new ItemStack(Item.potato), new ItemStack(ItemIds.SOUP_ID, 1, 4));
	 GameRegistry.addShapelessRecipe(new ItemStack(soup, 2, 1), new ItemStack(Item.bowlEmpty), new ItemStack(Item.chickenRaw), new ItemStack(Item.carrot), new ItemStack(Item.potato), new ItemStack(ItemIds.SOUP_ID, 1, 4));
	 GameRegistry.addShapelessRecipe(new ItemStack(soup, 2, 2), new ItemStack(Item.bowlEmpty), new ItemStack(Item.fishRaw), new ItemStack(Item.carrot), new ItemStack(Item.potato), new ItemStack(ItemIds.SOUP_ID, 1, 4));

	 FurnaceRecipes.smelting().addSmelting(ItemIds.FOOD_UTIL_DEFAULT, 0, new ItemStack(soup, 1, 3), 0F);

	 //canned

	 //sweets

	 //beverage

	 //food utilities

	 GameRegistry.addShapelessRecipe(new ItemStack(food_util, 1, 0), new ItemStack(Item.bucketWater), new ItemStack(Item.beefRaw));
	 GameRegistry.addShapelessRecipe(new ItemStack(food_util, 1, 0), new ItemStack(Item.bucketWater), new ItemStack(Item.chickenRaw));
	 GameRegistry.addShapelessRecipe(new ItemStack(food_util, 1, 0), new ItemStack(Item.bucketWater), new ItemStack(Item.fishRaw));
	 GameRegistry.addShapelessRecipe(new ItemStack(food_util, 1, 0), new ItemStack(Item.bucketWater), new ItemStack(Item.porkRaw));

	 //sides

	 //other
 }
}

 

And unfortunately, when i run the instance it does the same thing with itemfoodutil class overwriting soup and sandwich but now the images are broken. But I still think I progressed thanks to you pointing out those two things.

Link to comment
Share on other sites

gellegbs you do not have to use metadata for food. its a great way to save itemids but its much more work to install them (my thinking) here is a universal class i made for the baconMod.

Its handel the food and crafing in it^^"

 

I wanted to use metadata because I know how annoying it is changing all the ids in the config when multiple mods are added and ids clash. I just want to alieve any fustrations not using metadata would create.

 

 

 

A thing before! Do not tell: this is wrong or something! Everything in this code i post now is working correct:

 

Normal Food:

package minecraftwero.baconMod.common.items;

import java.util.List;

import minecraftwero.baconMod.Bacon;
import minecraftwero.baconMod.common.config.BaconItems;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

/**
* 
* @author Speiger
*
*/
public class ItemBaconFood extends ItemFood 
{
private String name;
public String texture;
private PotionEffect[] potion;

public ItemBaconFood(int par1, int par2, boolean par3, String par4, String par5,  PotionEffect...par7) 
{
	super(par1, par2, par3);
	this.setCreativeTab(Bacon.baconMod);
	name = par4;
	texture = par5;
	potion = par7;
	this.setTextureName(par5);
}

public ItemBaconFood(int par1, int par2, boolean par3, String par4, String par5)
{
	this(par1, par2, par3, par4, par5, new PotionEffect(0, 0, 0));
}




public String getItemDisplayName(ItemStack par1)
{
	return name;
}


@SideOnly(Side.CLIENT)
@Override
public void registerIcons(IconRegister par1IconRegister)
{
	this.itemIcon = par1IconRegister.registerIcon(texture);
}

@Override
public ItemStack onEaten(ItemStack par1, World par2, EntityPlayer par3) 
{
        --par1.stackSize;
        par3.getFoodStats().addStats(this);
        par2.playSoundAtEntity(par3, "random.burp", 0.5F, par2.rand.nextFloat() * 0.1F + 0.9F);
        addPotions(par1, par2, par3);
	return par1;
}

public void addPotions(ItemStack par1, World par2, EntityPlayer par3)
{
	for(int i = 0; i<potion.length;i++)
	{
		if(potion[i] != null && potion[i].getPotionID() > 0 && !par2.isRemote)
		{
			par3.addPotionEffect(new PotionEffect(potion[i]));
		}
	}
}





}

 

 

Thank you for sharing your code with me. I'm curious what are the 3 parameters for super in the first ItemBaconFood? I am not adding potion effects to my food yet, at least haven't intended to. This mod I'm creating is more of a  practice and will be used privately and I won't release it.

 

 

 

 

This FoodClass handel also LanguageRegisty.addName so that is no longer needed xD

 

Now to the Crafting Food class:

It handels a damagecrafting. you can choose how much damage the food after eating gets (more than 1 time eatable) and also (when its a container item) how much damage it gets when you use it at crafting.

 

Crafting Food:

package minecraftwero.baconMod.common.items;

import java.util.List;

import minecraftwero.baconMod.Bacon;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class CraftingFood extends Item  
{

private String var1;
private String var2;
private int var3;
private boolean var4;
private int var5;
private int var6;
private PotionEffect[] var7;
public CraftingFood(int par1, int damage, int damageonCraft, int damageonEat, int extrafood, boolean alwaysEatable, String name, String texture, PotionEffect...effect) 
{
	super(par1);
	this.setCreativeTab(Bacon.baconMod);
	this.setNoRepair();
	this.var5 = damageonCraft;
	var6 = damageonEat;
	this.setMaxDamage(damage);
	this.setMaxStackSize(1);
	var1 = name;
	var2 = texture;
	var3 = extrafood;
	var4 = alwaysEatable;
	var7 = effect;
	this.setTextureName(texture);
}

public CraftingFood(int par1, int damage, int extrafood, boolean alwaysEatable, String name, String texture)
{
	this(par1, damage, 1, 1, extrafood, alwaysEatable, name, texture);
}

@Override
public boolean doesContainerItemLeaveCraftingGrid(ItemStack par1ItemStack) 
{
	return false;
}

@Override
public String getItemDisplayName(ItemStack par1ItemStack) 
{
	return var1;
}

    public int getMaxItemUseDuration(ItemStack par1ItemStack)
    {
        return 32;
    }
    
    public EnumAction getItemUseAction(ItemStack par1ItemStack)
    {
        return EnumAction.eat;
    }
    
@Override
public ItemStack onItemRightClick(ItemStack par1, World par2, EntityPlayer par3) 
{
	if(par3.canEat(var4))
	{
		par3.setItemInUse(par1, this.getMaxItemUseDuration(par1));
	}
	return par1;
}


@Override
public ItemStack onEaten(ItemStack par1, World par2, EntityPlayer par3) 
{
	par1.damageItem(var6, par3);
	par3.getFoodStats().addStats(var3, 0.6F);
        par2.playSoundAtEntity(par3, "random.burp", 0.5F, par2.rand.nextFloat() * 0.1F + 0.9F);
        addPotionEffect(par1, par2, par3);
	return par1;
}

public void addPotionEffect(ItemStack par1, World par2, EntityPlayer par3) 
{
	for(int i = 0; i<var7.length;i++)
	{
		if(var7[i].getPotionID() > 0 && var7[i] != null)
		{
			par3.addPotionEffect(var7[i]);
		}
	}
}

@SideOnly(Side.CLIENT)
@Override
public void registerIcons(IconRegister par1IconRegister)
{
	this.itemIcon = par1IconRegister.registerIcon(var2);
}

@Override
public ItemStack getContainerItemStack(ItemStack itemStack) 
{
	itemStack.setItemDamage(itemStack.getItemDamage()+var5);
	return itemStack;

}




}

 

I hope these examples help you out^^"

 

Yes thank you. Its a good reference, although i may organize things differently I like to see how others implement things. Unfortunately my problem remains with my ItemsFoodUtil class overwriting all my others.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

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

×   Your previous content has been restored.   Clear editor

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

Announcements



×
×
  • Create New...

Important Information

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