java - Eclipse 语法错误插入 ";"来完成 FieldDeclaration

标签 java eclipse minecraft minecraft-forge

当我修改 Minecraft 时,Eclipse 对我说我的创意选项卡出了问题。

这是我的代码:

//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想要什么。因为添加或/和删除“;”没关系。 如果我插入“;”然后eclipse说完整的方法是错误的。

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

最佳答案

  1. 创建静态字段 tabBetterLife 需要分号。
  2. 方法 getTabIcon 缺少一个 new 返回值。

    public static CreativeTabs tabBetterLife =
        new CreativeTab("tab_betterlife") {
    
        @Override
        public ItemStack getTabIcon() {
            return new ItemStack(ModItems.ruby);
        }
    };
    

关于java - Eclipse 语法错误插入 ";"来完成 FieldDeclaration,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44057014/

相关文章:

java - 使用自定义标记 (taglib) 在 JSP 上提示 Eclipse 代码

android - 编译运行项目时唤醒和解锁安卓手机屏幕?

java - 将剩余的小数转换为周、天、小时、分钟、秒

java - 以编程方式修改 Minecraft World 文件 (Java)

java - 打印 ArrayList 的子列表(基于用户输入的待办事项列表)会导致空 ArrayList

java - ExecutorService java 可能的线程泄漏

eclipse - 如何干净地停止 m2e cargo :run from Eclipse?

java - "Simple"Trie实现

java - Spring Web应用程序初始化器

java - 在 Minecraft 中为盔甲添加自定义模型?