Jump to content

Help with stacking an item added from my mod.


kenny2810

Recommended Posts

I am trying too add a crafting recipe for a pickaxe, and to start I tried to stack the ingots but I keep getting this error: genericItem cannot be resolved or is not a field. Here is the class of the main class called Generic.java:

 

package tutorial.generic;

 

// This Import list will grow longer with each additional tutorial.

// It's not pruned between full class postings, unlike other tutorial code.

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.item.EnumToolMaterial;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraftforge.common.EnumHelper;

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="generic", name="Generic", version="0.0.0")

@NetworkMod(clientSideRequired=true, serverSideRequired=false)

public class Generic

{

        // See Basic items tutorial for Generic Ingot

 

public EnumToolMaterial generic = EnumHelper.addToolMaterial("Generic", 3, 2000, 13.0F, 3.0F, 22);

public final Item genericSword = new GenericSword(5002, generic).setCreativeTab(CreativeTabs.tabCombat).setUnlocalizedName("genericSword");

public final Item genericPick = new GenericPick(5003, generic).setCreativeTab(CreativeTabs.tabTools).setUnlocalizedName("genericPick");

 

public static Item genericIngot;

    public static Block genericDirt;

    public static Block genericOre;

       

        @Instance(value="generic")

        public static Generic instance;

       

        @SidedProxy(clientSide="tutorial.generic.client.ClientProxy",

                        serverSide="tutorial.generic.CommonProxy")

        public static CommonProxy proxy;

       

        @EventHandler

        public void preInit(FMLPreInitializationEvent event)

        {

       

        genericIngot = new GenericItem(201).setMaxStackSize(64)

                    .setUnlocalizedName("genericIngot");

                 

genericDirt = new GenericBlock(500, Material.ground)

                .setHardness(0.5F).setStepSound(Block.soundGravelFootstep)

                .setUnlocalizedName("genericDirt").setCreativeTab(CreativeTabs.tabBlock);

genericOre = new GenericOre(501, Material.rock);

        }

       

        @EventHandler

        public void load(FMLInitializationEvent event)

        {

               

        ItemStack genricIngot = new ItemStack(Item.genericItem, 1);

        // See Basic items tutorial for Generic Ingot

                LanguageRegistry.addName(genericIngot, "Generic Ingot");

                LanguageRegistry.addName(genericOre, "Generic Ore");

                MinecraftForge.setBlockHarvestLevel(genericOre, "pickaxe", 3);

                GameRegistry.registerBlock(genericOre, "genericOre");

                GameRegistry.registerItem(genericSword, "genericSword");

                LanguageRegistry.addName(genericSword, "GenericSword");

                GameRegistry.registerItem(genericPick, "genericPick");

                LanguageRegistry.addName(genericPick, "GenericPick");

               

             

               

                             

                // End Basic Blocks

               

                proxy.registerRenderers();

        }

       

        @EventHandler

        public void postInit(FMLPostInitializationEvent event)

        {

                // Stub Method

        }

}

 

Here is the genericItem class:

 

package tutorial.generic;

 

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.creativetab.CreativeTabs;

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

import net.minecraft.item.Item;

 

public class GenericItem extends Item {

 

        public GenericItem(int id) {

                super(id); 

                // Constructor Configuration

                maxStackSize = 64;

                setCreativeTab(CreativeTabs.tabMisc);

                setUnlocalizedName("genericItem");

        }

 

        public void registerIcons(IconRegister iconRegister)

        {

          itemIcon = iconRegister.registerIcon("genericmod:genericIngot");

        }

 

 

}

 

Can anyone tell me what I am doing wrong?

 

 

Link to comment
Share on other sites

Your genericItem is not a public final variable of the Item class. You need to give the ItemStack constructor a specific instance of your class or an id so in this code:

 

 

@EventHandler
        public void load(FMLInitializationEvent event) 
        {
                
           ItemStack genricIngot = new ItemStack(Item.genericItem, 1);

 

 

change it to

 

ItemStack genricIngot = new ItemStack(this.genericIngot, 1);

 

 

Hope this helps. =)

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.