2
昨天编程一个Minecraft Mod时,我遇到了一个问题。Minecraft Modding“Can not instantiate type”creatring CreativeTab
下面是代码:
Main.java类
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.java类
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的报告我“无法实例的类型MyCreativeTab“,我在Main.java中写了new MyCreativeTab("tabTemperCraft)
,我不知道为什么......
我已经在互联网上看过,但任何人都有同样的问题。
有人可以帮我吗?谢谢!
抽象类不能被实例化。你需要做以下两件事之一:从你的MyCreativeTab类中移除关键字'abstract' *或者*创建另一个类来扩展MyCreativeTab类并使其具体化。后者你可以在你的'TemperCraft'类中实例化。 – aribeiro
@aribeiro谢谢,你在7分钟内回答! – EnricoBilla