Reputation: 31
I had a problem yesterday programming a Minecraft Mod.
Here is the code:
Main.java class
package com.enricobilla.tempercraft;
import com.enricobilla.tempercraft.creativeTab.MyCreativeTab;
@Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.MOD_VERSION)
public class TemperCraft {
public static final MyCreativeTab tabTemperCraft = new MyCreativeTab("tabTemperCraft");
... other code ...
}
and MyCreativeTab.java class
package com.enricobilla.tempercraft.creativeTab;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
public abstract class MyCreativeTab extends CreativeTabs {
public MyCreativeTab(String label) {
super(label);
this.setBackgroundImageName("tab_tempercraft.png");
}
}
So, my problem is that Eclipse report me "Cannot instantiate the type MyCreativeTab" where I wrote new MyCreativeTab("tabTemperCraft)
in Main.java and I don't know why...
I've already looked on the Internet but anyone has the same problem.
Can someone help me, please? Thanks!
Upvotes: 3
Views: 859
Reputation: 1973
The problem here is that MyCreativeTab
is an abstract type and those cannot be instantiated.
You need to remove the abstract
keyword of your class declaration or subclass it.
See this quote of the Java Specification:
A named class may be declared abstract (§8.1.1.1) and must be declared abstract if it is incompletely implemented; such a class cannot be instantiated, but can be extended by subclasses.
Upvotes: 2