Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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
}

}

 

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.