Jump to content

Error Registering tools


nayoshi12

Recommended Posts

Whenever I tried to register a Pickaxe, It gives me an error........

 

ModTools class

public class Modtool {

    public static Item.ToolMaterial nayoMaterial = EnumHelper.addToolMaterial("nayoMaterial",2,153,6.0F,2.0F,22);

    //Tools

    public static Item PotatoPickaxe;

 

    public static void init(){

      PotatoPickaxe = new PotatoPickaxe();

 

    }

}

 

 

PotatoPickaxe class

 

public class PotatoPickaxe extends ItemPickaxe {

    private static final String name = "PotatoPickaxe";

 

    public PotatoPickaxe(Item.ToolMaterial material) {

        super(material);

        GameRegistry.registerItem(this, name);

        setUnlocalizedName(name);

        setTextureName("nayocraft" + ":" + name);

        setCreativeTab(Top.nayotab);

    }

}

 

 

Link to comment
Share on other sites

That is not my main class, Sorry. Here it is

 

 

/* 19:  */ @Mod(name="Nayocraft!", modid="nayocraft", version="1.0.0")

/* 20:  */ public class Top

/* 21:  */ {

/* 22:  */  @SidedProxy(clientSide="com.nayoshi12.nayocraft.core.proxy.ClientProxy", serverSide="com.nayoshi12.nayocraft.core.proxy.CommonProxy")

/* 23:  */  public static CommonProxy proxy;

 

/* 25:44 */  public static CreativeTabs nayotab = new CreativeTabs("nayoshiTab")

/* 26:  */  {

/* 27:  */    public Item getTabIconItem()

/* 28:  */    {

/* 29:48 */      return Items.nether_star;

/* 30:  */    }

/* 31:  */  };

/* 32:  */ 

/* 33:  */  @Mod.EventHandler

/* 34:  */  public void preInit(FMLPreInitializationEvent event)

/* 35:  */  {

/* 36:53 */  //Pre Initialization is where you register Blocks!

              //TODO maybe Register tools as seperate class......

                Modblock.init();

                Modtool.init();

/* 38:55 */    Moditem.init();

/* 39:  */  }

/* 40:  */ 

  @Mod.EventHandler

  public void init(FMLInitializationEvent event)

  {

  Recipes.init();

              Smelting.init();

}

 

@Mod.EventHandler

  public void postInit(FMLPostInitializationEvent event) {}

}

 

 

I am getting an error towards PotatoPickaxe = new PotatoPickaxe()

there are too many classes to put in here. I thought that would be enough....

 

 

 

Link to comment
Share on other sites

First, please PLEASE organize your code. It looks horrid. Second, don't use the same name as an object when assigning an object's value. Java (and you) will get confused. Do something like this:

 

public static Item potatoPickaxe;

public static void init() {
    potatoPickaxe = new PotatoPickaxe();
    // You don't seem to register your item anywhere. You will need to do something like this, otherwise, your item will not load.
    GameRegistry.addItem(potatoPickaxe, "item.potatoPickaxe");
}

 

You can also pre-assign objects like so:

 

public static Item potatoPickaxe = new PotatoPickaxe();

public static void init() {
    // You still need to register the item, though.
    GameRegistry.registerItem(potatoPickaxe, "item.potatoPickaxe");
}

 

Less code to write, and generally looks nicer.

if (user.hasKnowledgeOfJava) {

    if (user.question.hasCode) {

        return interpetHelpfulResponse(user.getQuestion());

    } else {

        return "Could you post your code please?";

    }

} else {

    return "Learn some freaking Java!";

}

Link to comment
Share on other sites

I'm sorry about my lack of organization. I've fixed it some how. I just removed (Item.ToolMaterial material) and replaced the the material inside the super() with nayoMaterial, also I registered it inside the PotatoPickaxe class. I will try to organize my codes.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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