Minecraft Modding Java 编译错误

发布于 2024-11-27 13:58:02 字数 1677 浏览 2 评论 0原文

我正在尝试为我的世界制作一个模组,添加一个新的方块。这是我的代码:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

紅太極 2024-12-04 13:58:02

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

岁吢 2024-12-04 13:58:02

尝试将 mod_Block.java 中的这一行更改

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

为:

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

Try to change this line in your mod_Block.java

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

into this:

sunBlock.blockIndexInTexture = ModLoader.addOverride("/terrain.png","/block.png");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文