Minecraft Modding Java 编译错误
我正在尝试为我的世界制作一个模组,添加一个新的方块。这是我的代码:
mod_Block.java
package net.minecraft.src;
import java.util.random;
public class mod_Block extends BaseMod
{
public static final Block sunBlock = new BlockSun(100,0).setBlockName("sun").setLightValue(2.0F);
public mod_Block()
{
ModLoader.RegisterBlock(sunBlock);
blockSun.blockIndexInTexture = ModLoader.addOverride("/terrain.png","/block.png");
ModLoader.AddName(sunBlock,"Sun");
ModLoader.AddRecipe(new ItemStack(sunBlock, 1), new Object [] {
"**", Character.valueOf('*'), Block.dirt
});
}
public String Version()
{
return "3.14159265";
}
}
BlockSun.java
package net.minecraft.src;
import java.util.random;
public class BlockSun extends Block
{
protected BlockSun (int i, int j)
{
super (i,j,Material.glass);
}
public int quantityDropped (int i, Random random)
{
return 0;
}
}
但编译器说:
src/minecraft/net/minecraft/src/BlockSun.java:2: 找不到符号 符号:类 util 位置:java包 导入java.util; ^
src/minecraft/net/minecraft/src/BlockSun.java:11: 找不到符号 符号:随机类 位置:类net.minecraft.src.BlockSun public int amountDropped(int i,Random随机) ^
src/minecraft/net/minecraft/src/mod_Block.java:2: 找不到符号 符号:类 util 位置:java包 导入java.util; ^
src/minecraft/net/minecraft/src/mod_Block.java:11:找不到符号 符号:变量blockSun 位置:类 net.minecraft.src.mod_Block blockSun.blockIndexInTexture = ModLoader.addOverride("/terrain.png","/block.png"); ^
如果您能帮助我,我将非常感激,谢谢。
I am trying to make a mod for minecraft which adds a new block. Here is my code:
mod_Block.java
package net.minecraft.src;
import java.util.random;
public class mod_Block extends BaseMod
{
public static final Block sunBlock = new BlockSun(100,0).setBlockName("sun").setLightValue(2.0F);
public mod_Block()
{
ModLoader.RegisterBlock(sunBlock);
blockSun.blockIndexInTexture = ModLoader.addOverride("/terrain.png","/block.png");
ModLoader.AddName(sunBlock,"Sun");
ModLoader.AddRecipe(new ItemStack(sunBlock, 1), new Object [] {
"**", Character.valueOf('*'), Block.dirt
});
}
public String Version()
{
return "3.14159265";
}
}
BlockSun.java
package net.minecraft.src;
import java.util.random;
public class BlockSun extends Block
{
protected BlockSun (int i, int j)
{
super (i,j,Material.glass);
}
public int quantityDropped (int i, Random random)
{
return 0;
}
}
But the compiler says:
src/minecraft/net/minecraft/src/BlockSun.java:2: cannot find symbol
symbol : class util
location: package java
import java.util;
^src/minecraft/net/minecraft/src/BlockSun.java:11: cannot find symbol
symbol : class Random
location: class net.minecraft.src.BlockSun
public int quantityDropped (int i, Random random)
^src/minecraft/net/minecraft/src/mod_Block.java:2: cannot find symbol
symbol : class util
location: package java
import java.util;
^src/minecraft/net/minecraft/src/mod_Block.java:11: cannot find symbol
symbol : variable blockSun
location: class net.minecraft.src.mod_Block
blockSun.blockIndexInTexture = ModLoader.addOverride("/terrain.png","/block.png");
^
I would be really grateful if you helped me out, thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Java 区分大小写:
java.util.Random
此外,阅读 Java 的命名约定也会有好处:http://www.oracle.com/technetwork/java/codeconv-138413.html
Java is case-sensitive:
java.util.Random
Also it would be good for you to read Java's naming conventions: http://www.oracle.com/technetwork/java/codeconv-138413.html
尝试将 mod_Block.java 中的这一行更改
为:
Try to change this line in your mod_Block.java
into this: