Jump to content

Recommended Posts

Posted

Hello, so please excuse me for some newbie mistake, as I'm still on the learning curve of forge but I can not seem to figure out what the problem is. For some reason, the name of my item keeps coming up as item.breadslice.name the breadslice part is the name of my unlocalized name. and I tried adding a crafting recipe, but after trying it won't craft my item. Here is my main class

 

 

package mydeblob.sandwichmod;

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 cpw.mods.fml.common.Mod;
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;

@Mod(modid="sandwich", name="Sandwich", version="0.0.1")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class Sandwich {


        // The instance of your mod that Forge uses.
        @Instance("Sandwich")
        public static Sandwich instance;
        private static Item breadslice = new BreadSlice(5000).setUnlocalizedName("breadslice").setMaxStackSize(64).setCreativeTab(CreativeTabs.tabFood).func_111206_d("Sandwich:slicebread");

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

        public void preInit(FMLPreInitializationEvent event) {
                // Stub Method
        }
        

        public void load(FMLInitializationEvent event) {
                proxy.registerRenderers();
               breadslice = new BreadSlice(5000);
               gameRegisters();
               languageRegisters();
               craftingRecipes();


        }

        
        private static void gameRegisters(){
        	GameRegistry.registerItem(breadslice, "Bread Slice");
        }
        private static void languageRegisters(){
        	LanguageRegistry.addName(breadslice, "Bread Slice");
        }
        public void craftingRecipes(){
        	GameRegistry.addShapelessRecipe(new ItemStack (Sandwich.breadslice, 3), new ItemStack(ItemFood.bread));
        }

        public void postInit(FMLPostInitializationEvent event) {
                // Stub Method
        }
}

 

And Here is my item class

 

 

package mydeblob.sandwichmod;

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

public class BreadSlice extends Item {

public BreadSlice(int par1) {
	super(par1);
	// TODO Auto-generated constructor stub
}

}

 

Posted

Replace:

private static Item breadslice = new BreadSlice(5000).setUnlocalizedName("breadslice").setMaxStackSize(64).setCreativeTab(CreativeTabs.tabFood).func_111206_d("Sandwich:slicebread");

with

private static Item breadslice;

 

Move all of this to the method receiving FMLPreInitializationEvent:

 

proxy.registerRenderers();
breadslice = new BreadSlice(5000);
languageRegisters();
craftingRecipes();

 

Replace:

breadslice = new BreadSlice(5000);

with

breadslice = new BreadSlice(5000).setUnlocalizedName("breadslice").setMaxStackSize(64).setCreativeTab(CreativeTabs.tabFood).func_111206_d("Sandwich:slicebread");

 

Annotate your methods that are receiving FML events with this:

 

@EventHandler

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.