Eclipse语法错误插入“;”完成FieldDeclaration

时间:2017-05-18 20:13:38

标签: java eclipse minecraft minecraft-forge

当我修改Minecraft时,Eclipse告诉我,我对Creative Tabs做错了。

这是我的代码:

//I don´t write all imports in here

@Mod(modid = Reference.MOD_ID, name = Reference.NAME, version = Reference.VERSION, acceptedMinecraftVersions = Reference.ACCEPTED_VERSIONS)
public class BetterLife {

    @Instance
    public static BetterLife instance;

    @SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)
    public static CommonProxy proxy;

    @EventHandler
    public void preInit(FMLPreInitializationEvent event){
        ModItems.init();
        ModItems.register();

        ModBlocks.init();
        ModBlocks.register();
    }

    @EventHandler
    public void Init(FMLInitializationEvent event){
        proxy.init();
        ModCrafting.register();
    }

    @EventHandler
    public void postInit(FMLPostInitializationEvent event){

    }

    public static CreativeTabs tabBetterLife = new CreativeTab("tab_betterlife") {

        @Override
        public ItemStack getTabIcon() {
            return ItemStack(ModItems.ruby);
        }
    }//Here eclipse comes:"Syntax error Insert ";" to complete FieldDeclaration"

}

我不知道日食想要什么。因为添加或/和删除“;”无所谓。 如果我插入“;”然后eclipse说完整的方法是错误的。

我希望你能理解我糟糕的英语;)

1 个答案:

答案 0 :(得分:2)

  1. 需要分号才能创建静态字段getTabIcon
  2. 方法new错过了public static CreativeTabs tabBetterLife = new CreativeTab("tab_betterlife") { @Override public ItemStack getTabIcon() { return new ItemStack(ModItems.ruby); } }; 的返回值。

    parentid