1. Wiki
  2. /方块
  3. /方块纹理、声音和名称

方块纹理、声音和名称

自定义方块的资源包部分:terrain_texture.json、material_instances、blocks.json 中的声音,以及 en_US.lang 中的名称。

自定义方块和物品一样,分布在两个包里。行为包决定它的行为,资源包存放它的纹理、声音和名称。

文件一览

资源包
RP/
  blocks.json
  textures/
    terrain_texture.json
    blocks/
      ruby_block.png
  texts/
    en_US.lang

第 1 步:纹理

把一张 16x16 的 PNG 保存到 RP/textures/blocks/。然后在 terrain_texture.json 中给它起个简称:

RP/textures/terrain_texture.json
{
  "resource_pack_name": "My Ruby Add-on",
  "texture_name": "atlas.terrain",
  "padding": 8,
  "num_mip_levels": 4,
  "texture_data": {
    "ruby_block": {
      "textures": "textures/blocks/ruby_block"
    }
  }
}

第 2 步:把纹理放到方块上

行为包中的方块用 minecraft:material_instances 选择纹理。* 表示所有面。

BP/blocks/ruby_block.json
"minecraft:material_instances": {
  "*": {
    "texture": "ruby_block",
    "render_method": "opaque"
  }
}

要让不同的面用不同纹理,就写出面的名称。没写的面使用 *:

BP/blocks/ruby_block.json
"minecraft:material_instances": {
  "*": { "texture": "ruby_block_side" },
  "up": { "texture": "ruby_block_top" },
  "down": { "texture": "ruby_block_bottom" }
}
render_method适用于
opaque实心方块。默认值。
alpha_test镂空像素,比如树叶或玻璃板。两面都绘制。
alpha_test_single_sided镂空像素,只绘制正面。
blend半透明颜色,比如染色玻璃。
double_sided实心,但两面都绘制。

第 3 步:声音

blocks.json 位于资源包根目录。它设置破坏、放置和行走时的声音:

RP/blocks.json
{
  "format_version": "1.21.40",
  "wiki:ruby_block": {
    "sound": "stone"
  }
}

常用声音:stone、wood、gravel、grass、glass、metal、sand、cloth、amethyst_block。

第 4 步:名称

RP/texts/en_US.lang
tile.wiki:ruby_block.name=Ruby Block

方块以 tile. 开头,以 .name 结尾。你也可以在方块文件中设置 minecraft:display_name。

自定义形状

如果形状不是完整立方体,就做一个模型,保存为 RP/models/blocks/<name>.geo.json,并让 minecraft:geometry 指向它的 geometry.<name>。这时 material_instances 中的面名称要和模型骨骼的面名称对应。

紫黑格子

纹理的简称不在 terrain_texture.json 中,或路径写错了。路径中不要写 .png,另外记住文件会被缓存:修改后要重新进入世界。

We use cookies to improve your experience and analyse site traffic. Learn more