Execution failed for task #39;:compileJava#39;. - Issue 3 in this series(执行任务#39;失败:编译Java#39;。-本系列第三期)
问题描述
在此问题因已被提出而关闭之前,据我所知,这是一个模糊且常见的错误,因此此问题与其他问题不同。 我通过安装略微不同的Forge版本修复了以前post中的错误,但现在已达到this tutorial的第5步。当我将.gradlew构建与示例mod一起使用时,一切似乎都运行得很好(尽管我找不到控制台输出),但当我将mod编辑为作者的描述时,我收到了许多错误。
示例mod:
package com.example.examplemod;
import net.minecraft.init.Blocks;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
@Mod(modid = ExampleMod.MODID, version = ExampleMod.VERSION)
public class ExampleMod
{
public static final String MODID = "examplemod";
public static final String VERSION = "1.0";
@EventHandler
public void init(FMLInitializationEvent event)
{
// some example code
System.out.println("DIRT BLOCK >> "+Blocks.dirt.getUnlocalizedName());
}
}
我是如何按照教程进行更改的:
package com.example.examplemod;
import net.minecraft.init.Blocks;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
@Mod(modid = ExampleMod.MODID, version = ExampleMod.VERSION)
public class ExampleMod
{
public static final String MODID = "examplemod";
public static final String VERSION = "1.1";
@EventHandler
public void init(FMLInitializationEvent event)
{
Block amethystOre = new ModBlock(Material.rock, "amethystOre");
GameRegistry.registerBlock(amethystOre, "amethystOre");
}
private class ModBlock extends Block
{
public ModBlock(Material material, String blockName)
{
super(material);
this.setBlockName(blockName);
this.setBlockTextureName(MODID + ":" + blockName);
this.setCreativeTab(CreativeTabs.tabBlock);
}
}
}
当我运行.gradlew生成时,我收到:
#################################################
ForgeGradle 1.2-SNAPSHOT-fb514d3
https://github.com/MinecraftForge/ForgeGradle
#################################################
Powered by MCP unknown
http://modcoderpack.com
by: Searge, ProfMobius, Fesh0r,
R4wk, ZeuX, IngisKahn, bspkrs
#################################################
:compileApiJava UP-TO-DATE
:processApiResources UP-TO-DATE
:apiClasses UP-TO-DATE
:sourceMainJava UP-TO-DATE
:compileJava
warning: [options] bootstrap class path not set in conjunction with -source 1.6
C:UsersenjiMinecraftWorkspaceforge-1.7.10-10.13.4.1558-1.7.10-srcuildsourcesjavacomexampleexamplemodExampleMod.java:21: error: cannot find symbol
private class ModBlock extends Block
^
symbol: class Block
location: class ExampleMod
C:UsersenjiMinecraftWorkspaceforge-1.7.10-10.13.4.1558-1.7.10-srcuildsourcesjavacomexampleexamplemodExampleMod.java:23: error: cannot find symbol
public ModBlock(Material material, String blockName)
^
symbol: class Material
location: class ExampleMod.ModBlock
C:UsersenjiMinecraftWorkspaceforge-1.7.10-10.13.4.1558-1.7.10-srcuildsourcesjavacomexampleexamplemodExampleMod.java:17: error: cannot find symbol
Block amethystOre = new ModBlock(Material.rock, "amethystOre");
^
symbol: class Block
location: class ExampleMod
C:UsersenjiMinecraftWorkspaceforge-1.7.10-10.13.4.1558-1.7.10-srcuildsourcesjavacomexampleexamplemodExampleMod.java:17: error: cannot find symbol
Block amethystOre = new ModBlock(Material.rock, "amethystOre");
^
symbol: variable Material
location: class ExampleMod
C:UsersenjiMinecraftWorkspaceforge-1.7.10-10.13.4.1558-1.7.10-srcuildsourcesjavacomexampleexamplemodExampleMod.java:18: error: cannot find symbol
GameRegistry.registerBlock(amethystOre, "amethystOre");
^
symbol: variable GameRegistry
location: class ExampleMod
C:UsersenjiMinecraftWorkspaceforge-1.7.10-10.13.4.1558-1.7.10-srcuildsourcesjavacomexampleexamplemodExampleMod.java:26: error: cannot find symbol
this.setBlockName(blockName);
^
symbol: method setBlockName(String)
C:UsersenjiMinecraftWorkspaceforge-1.7.10-10.13.4.1558-1.7.10-srcuildsourcesjavacomexampleexamplemodExampleMod.java:27: error: cannot find symbol
this.setBlockTextureName(MODID + ":" + blockName);
^
symbol: method setBlockTextureName(String)
C:UsersenjiMinecraftWorkspaceforge-1.7.10-10.13.4.1558-1.7.10-srcuildsourcesjavacomexampleexamplemodExampleMod.java:28: error: cannot find symbol
this.setCreativeTab(CreativeTabs.tabBlock);
^
symbol: variable CreativeTabs
location: class ExampleMod.ModBlock
8 errors
1 warning
:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
我对Java了解不多(我刚刚开始学习),但我认为逐个字符复制教程应该会产生一个没有错误的程序。显然不是。
查看编译器上的错误输出,第一个错误是‘导入网络无法解析’(第3行),但我不知道原因。
任何帮助都非常感谢, 本
推荐答案
(来自评论)
导入错误。您应该使用net.minecraft.*
而不是net.minecraft.init.*
:
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
这篇关于执行任务';失败:编译Java';。-本系列第三期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:执行任务';失败:编译Java';。-本系列第三期
基础教程推荐
- Java 中保存最后 N 个元素的大小受限队列 2022-01-01
- 在螺旋中写一个字符串 2022-01-01
- 如何使用 Eclipse 检查调试符号状态? 2022-01-01
- 由于对所需库 rt.jar 的限制,对类的访问限制? 2022-01-01
- 如何对 HashSet 进行排序? 2022-01-01
- 如何强制对超级方法进行多态调用? 2022-01-01
- 如何在不安装整个 WTP 包的情况下将 Tomcat 8 添加到 Eclipse Kepler 2022-01-01
- Spring Boot Freemarker从2.2.0升级失败 2022-01-01
- 首次使用 Hadoop,MapReduce Job 不运行 Reduce Phase 2022-01-01
- 如何使用 Stream 在集合中拆分奇数和偶数以及两者的总和 2022-01-01