Minecraft Forge 1.8 - 加载块纹理

Minecraft Forge 1.8 - Loading Block Textures

我刚刚开始学习 Java,同时正在制作 Minecraft 模组。我看过一个关于使用 Minecraft Forge API 将方块添加到游戏中的教程,但我遇到了问题。不再有“.setBlockTextureName()”方法,所以我不知道该怎么办。我在我的游戏中添加了一个简单的块,但它没有纹理,我想为其添加纹理。我将如何为 Minecraft 1.8 执行此操作?

P.S.: 如果这是重复的,我很抱歉,我只看到关于 Minecraft 生物的问题,而不是 1.8 的纹理(请记住,1.8 的 Forge API 是与其他版本不同),所以我决定问问自己。

如果我需要澄清任何事情,请告诉我!

纹理在 1.8 中非常不同。这里有一些教程:

Updating Blocks;
Updating Items.

以上两项:

  • 从主要 mod class 中删除任何 GameRegistry.registerBlock。这些现在应该在 block/item 的构造函数中。
  • 添加一个 private final name 字段并为其创建一个 getter。

对于

  • src/main/resources/assets/{MODID}/models/block 中,您将需要 2 JSON 个文件。
    第一个应称为 {BLOCKNAME}.json 并包含此内容:

    {
        "parent": "block/cube_all",
        "textures": {
            "all": "{MODID}:blocks/{BLOCKNAME}"
        }
    }
    

    第二个同名,进入 src/main/resources/assets/{MODID}/models/item,代码如下:

    {
        "parent": "{MODID}:block/{BLOCKNAME}",
        "display": {
            "thirdperson": {
                "rotation": [ 10, -45, 170 ],
                "translation": [ 0, 1.5, -2.75 ],
                "scale": [ 0.375, 0.375, 0.375 ]
            }
        }
    }
    
  • 现在 src/main/resources/assets/{MODID}/blockstates,您还需要 1 个 JSON 文件。具有相同的名称,它应该包含此代码:

    {
        "variants": {
            "normal": { "model": "{MODID}:{BLOCKNAME}" }
        }
    }
    

您应该分别用您的 mod 的 ID 和块的名称替换 {MODID}{BLOCKNAME}

我推荐阅读Minecraft Modding

The way that Minecraft renders blocks has changed significantly for 1.8. Previously, the shape of blocks was defined in the java code. This meant that (for example) a BlockTorch would always have the same shape, and only the textures could be changed. Minecraft now uses model files to define both the shape and the texture.

特别是上页的"Some Clarifications of some of the key points"。

另请参阅:Block models