Minecraft Wiki

除另有声明,转载时均必须注明出处若簡繁轉換出錯,請以遊戲內為準请勇于扩充与修正内容有兴趣逛逛我们的微博沟通交流,欢迎到社区专页需要协助,请在告示板留言

了解更多

Minecraft Wiki
Advertisement
Ic translate
此条目的(部分)内容需要翻译。

你可以帮助我们来翻译此条目,但请勿使用机器翻译

Brush
该文章需要整理以符合格式指导 讨论

请帮助优化文章格式来让它符合格式指导。

本教程是对官方支持的附加包来修改的。

概括

本教程是对于高级用户编写的!普通用户请不要轻易尝试! 请您熟悉 JSON 的数据格式。如果您并不熟悉的话,请阅读行为附加包教程的JSON部分。 在本教程中,我们将涉及:

  • Minecraft的JSON模型格式
  • 如何去修改模型

所需时间

30 分钟

所需工具

一个文本编辑器

任何的文本编辑器应该都是可以的,但是我们建议您使用用于编程的IDE软件。Notepad++ 是一个优秀且免费还带有多编程语言高亮显示支持的编辑器。你可以在 here 下载Notepad++ 。

入门

在本教程中我们将使 爬行者 有3个头。但是在修改 爬行者 之前,我们来看看组成模型的代码。

Minecraft模型格式

Minecraft的实体建模由JSON语言编程,叫做 mobs.json.你可以在Minecraft vanilla资源包找到他 Vanilla Resource Pack/models/mobs.json.这个文件包含了所有Minecraft中实体的模型代码。 它们看起来是这个样子的:

Entity Template Pseudocode
"geometry.entityname": {
  "texturewidth": x,
  "textrueheight": y,
  "bones": [
    {
      "name": "body part name",
      "pivot": [ x, y, z ],
      "cubes": [
        {
          "origin": [ x, y, z ],
          "size": [ x, y, z ],
          "uv": [ x, y ]
        }
      ]
    }
  ]
}

注: 这只是一个参考例子,不是一个可用的实体模型。如果你使用它作为代码,他将不会工作!

geometry.entity 名字是这个要修改的实体的名称
texturewidth 宽度单位,1个像素
textureheight 长度单位,1个像素
bones 骨骼动画使几何体运动,它包含了使几何体运转的信息。注:但这也有局限性,他只能使包含在源代码骨骼动画清单的骨骼部分运。
name 骨骼(动画)的名称
pivot 轴位置是实体肢体的旋转中心。例如:爬行者的头是能绕着这一点旋转的方形构成。
rotation 旋转实体的部分在xyz轴上。注: 游戏可能会以动画覆盖包含动画的对象。
mirror 布鲁值,可设置为true或false。如果填true,游戏会根据UV位置映射对应的肢体。
cubes 如果几何没有骨骼动画,写入此关键符并键入要映射的动画肢体名,即可赋予几何动画。
origin 几何体的位置和实体模型的起点位置有关。 注: 这个点在几何体的左前下角。

例如: 这个爬行者身体的红色顶点,就是这个身体的几何体位置。

CMEMPicture 7
size 几何体的大小。注: 16x16x16是一个方块的大小!(中文补充:它和肢体大小确实有关,但是只是用来确认肢体材质位置的,放大用inflate见下文)
uv 这个是实体肢体材质的起点。

注:这是规定x(横轴),y(纵轴)轴的第一个点 注:这个点应该是一个实体的某个肢体材质的区域的左上角。 例如: 这个红点是你想做成苦力怕"body"(身体,因为是代码不译)的UV 做成点。 ("uv": [ 16, 16 ]). 身体将会使用被框起的部分作为材质.

CMEMPicture 6
mirror 布鲁值,可设置为true或false。如果填true,游戏会根据UV位置映射对应的部位。
inflate 使这部分肢体成倍数增大(可为小数或负数)

骨骼动画

骨骼是我们用来制作模型的。把它想象成一具骷髅!在人体中,骨骼是由肌肉运动的,而你的肌肉也随着肌肉运动。在3D动画中,骨骼是由动画移动的,而动画反过来又会移动附着在骨骼上的几何图形!

重要注意事项

Models are not entirely data driven yet. While it is possible to change things about a model, there are still certain hardcoded values like: which bones an entity needs, what material an entity is rendered with, and what animations an entity has. This means that you cannot just copy and paste geometry from the villager into the spider section and hope that it works! Until this system becomes more data driven, you will need to do some experimenting to achieve the results that you want!

Make sure you name your bones correctly! The name of the bones for an entity should be the same as they are in the Vanilla Minecraft resource pack. The animation and rendering of a model relies on this information being correct as explained above!

Modifying the Creeper

Now that we’ve looked at how the Minecraft model format is setup, let’s modify the creeper a bit. We are going to make him have 3 heads, 2 on bottom and then 1 stacked on top, like a pyramid.

  • First, find the geometry.creeper section in Vanilla Minecraft’s mobs.json file and copy it.
    • Vanilla Resource Pack/models/mobs.json
  • Create a new folder in your resource pack called models
  • Create a new JSON file called mobs.json and save it into your new models folder
  • Enter in a pair of curly brackets ({ }) into your new mobs.json and then paste the geometry.creeper from Vanilla’s model file after the left curly bracket.
  • Now, let’s first move his original head to the left a bit. To do this, we are going to change the x component of the origin for the bone named "head" from -4 to -8.
  • Now copy everything in the square brackets for "cubes" for "head". This should just be the text highlighted grey.
    mobs.json – geometry.creeper – head section
{
  "name": "head",
  "pivot": [ 0.0, 18.0, 0.0 ],
  "cubes": [
    {
      "origin": [ -8.0, 18.0, -4.0 ],
      "size": [ 8, 8, 8 ],
      "uv": [ 0, 0 ]
    }
  ]
},
  • Add a comma after the right curly bracket for the lines you just copied.
  • Paste the lines you copied after the comma
  • Add a comma after the right curly bracket for the lines you just pasted
  • Paste the copied lines again after the new comma
  • You should now have 3 pairs of curly brackets in the "cubes" that each have an origin, size and uv object
  • In the first copied lines, we are going to move that head right by changing the x component of origin to 0 from -8
  • In the second copy, change the x component of the origin to -4 and the y component to 26
  • Your head section for the creeper should now look like (new text in grey):
    mobs.json – geometry.creeper – head section
{
  "name": "head",
  "pivot": [ 0.0, 18.0, 0.0 ],
  "cubes": [
    {
      "origin": [ -8.0, 18.0, -4.0 ],
      "size": [ 8, 8, 8 ],
      "uv": [ 0, 0 ]
    },
    {
      "origin": [ 0.0, 18.0, -4.0 ],
      "size": [ 8, 8, 8 ],
      "uv": [ 0, 0 ]
    },
    {
      "origin": [ -4.0, 26.0, -4.0 ],
      "size": [ 8, 8, 8 ],
      "uv": [ 0, 0 ]
    }
  ]
},

Note that we don’t have to change the UV’s for any of the new heads because we copied the old head’s UV coordinates and we aren’t adding different textures to the new heads.

Results

CMEMPicture 10

Three-headed creeper.

Adding More

If you want to change another entity’s model, make sure to add a comma after the right curly bracket of geometry.creeper.

Pseudocode example

Don’t forget the comma! (highlighted red)

{
  "geometry.creeper": {
    // model stuff
  },
  "geometry.chicken": {
    // model stuff
  }
}

Congratulations!

If you’ve made it to here, you should now know everything you need to know to make your own entity models!

Advertisement