Minecraft 改装 "Cannot instantiate the type" creatring CreativeTab
Minecraft Modding "Cannot instantiate the type" creatring CreativeTab
我昨天在编写 Minecraft Mod 时遇到了问题。
代码如下:
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 ...
}
和MyCreativeTab.javaclass
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");
}
}
所以,我的问题是 Eclipse 报告我 "Cannot instantiate the type MyCreativeTab" 我在 Main.java 中写了 new MyCreativeTab("tabTemperCraft)
的地方,我不知道为什么...
我已经在 Internet 上查看过,但任何人都有同样的问题。
有人可以帮帮我吗?谢谢!
这里的问题是 MyCreativeTab
是抽象类型,无法实例化。
您需要删除 class 声明的 abstract
关键字或子class 它。
的这句话
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.
我昨天在编写 Minecraft Mod 时遇到了问题。
代码如下:
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 ...
}
和MyCreativeTab.javaclass
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");
}
}
所以,我的问题是 Eclipse 报告我 "Cannot instantiate the type MyCreativeTab" 我在 Main.java 中写了 new MyCreativeTab("tabTemperCraft)
的地方,我不知道为什么...
我已经在 Internet 上查看过,但任何人都有同样的问题。
有人可以帮帮我吗?谢谢!
这里的问题是 MyCreativeTab
是抽象类型,无法实例化。
您需要删除 class 声明的 abstract
关键字或子class 它。
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.