Minecraft Modding Java编译错误

时间:2011-08-02 08:27:12

标签: java compiler-construction minecraft

我正在尝试为我的世界制作一个mod,它增加了一个新的块。这是我的代码:

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   location:包java   import java.util;   ^

     

src / minecraft / net / minecraft / src / BlockSun.java:11:找不到符号   符号:类随机   location:class net.minecraft.src.BlockSun   public int quantityDropped(int i,Random random)   ^

     

src / minecraft / net / minecraft / src / mod_Block.java:2:找不到符号   符号:类util   location:包java   import java.util;   ^

     

src / minecraft / net / minecraft / src / mod_Block.java:11:找不到符号   符号:变量blockSun   location:class net.minecraft.src.mod_Block   blockSun.blockIndexInTexture = ModLoader.addOverride(“/ terrain.png”,“/ block.png”);   ^

如果你帮助我,我将非常感激,谢谢。

2 个答案:

答案 0 :(得分:4)

Java区分大小写:java.util.Random

您也可以阅读Java的命名约定:http://www.oracle.com/technetwork/java/codeconv-138413.html

答案 1 :(得分:2)

尝试在mod_Block.java中更改此行

blockSun.blockIndexInTexture = ModLoader.addOverride("/terrain.png","/block.png");

进入这个:

sunBlock.blockIndexInTexture = ModLoader.addOverride("/terrain.png","/block.png");