Tutorials/Changing minecraft entity models

Από Minecraft Wiki
Μετάβαση σε: πλοήγηση, αναζήτηση
This article may need cleanup to comply with the style guide.
Please help improve this if you can. The talk page may contain suggestions.

This tutorial refers specifically to the officially supported Add-ons modification architecture.

Summary[επεξεργασία | επεξεργασία κώδικα]

This tutorial is intended for advanced users! It is expected that you are familiar with the JSON data format. If you are not, please read the JSON sections of the Behavior Add-on tutorial. In this tutorial, we will be covering:

  • Overview of Minecraft’s JSON model format
  • How to modify models

Time Required[επεξεργασία | επεξεργασία κώδικα]

30 minutes

Required Tools[επεξεργασία | επεξεργασία κώδικα]

You will need the following programs to follow along with this tutorial:

A text editor[επεξεργασία | επεξεργασία κώδικα]

Any text editor should work but I would suggest using some sort of programming IDE. Notepad++ is an excellent, and FREE, text editor with syntax highlighting for lots of programming languages. You can download Notepad++ from here: https://notepad-plus-plus.org/

Getting Started[επεξεργασία | επεξεργασία κώδικα]

   We will be modifying the creeper to have 3 heads in this tutorial! Before we modify the creeper, let’s look at the code that makes up our models.

Minecraft Model Format[επεξεργασία | επεξεργασία κώδικα]

Minecraft’s models are defined using JSON in a file called mobs.json. You can find mobs.json in the Vanilla Minecraft resource pack at Vanilla_Resource_Pack/models/mobs.json. This file contains the definition for every entity’s model. Each definition looks something like:

Entity Template Pseudocode[επεξεργασία | επεξεργασία κώδικα]

Αρχείο:CMEMPicture 13.png

Note:[επεξεργασία | επεξεργασία κώδικα]

   This is just an example overview of how each entity’s model is laid out. If you used this as is, it would not work!

Geometry.entity[επεξεργασία | επεξεργασία κώδικα]

The name of the entity that this model belongs to

Texturewidth[επεξεργασία | επεξεργασία κώδικα]

   The width of the texture, in pixels, for this entity

Textureheight[επεξεργασία | επεξεργασία κώδικα]

   The height of the texture, in pixels, for this entity

Bones[επεξεργασία | επεξεργασία κώδικα]

   The bones that make up the skeleton of the entity. Bones contain the geometry data affected by the bone.  Note that there can be more than a single bone listed here, separated by commas.
Name[επεξεργασία | επεξεργασία κώδικα]
   Name of the bone
Pivot[επεξεργασία | επεξεργασία κώδικα]
   The point in space that the body part will rotate around. For example, the creeper’s head rotates around a point on the bottom center of the cube that makes up its head.
Cubes[επεξεργασία | επεξεργασία κώδικα]
   The geometry that belongs to the bone. Note that a bone can have multiple cubes, separated by commas.
Origin[επεξεργασία | επεξεργασία κώδικα]
   The position of this cube, relative to the origin of the entity. Note that this position is the bottom front left point of the cube (see example).
Origin Example:[επεξεργασία | επεξεργασία κώδικα]
       For the creeper’s body cube, the red circled vertex is the origin for the body cube.

CMEMPicture 7.png

Size[επεξεργασία | επεξεργασία κώδικα]
       The size of the cube. Note that a cube of 16 x 16 x 16 is the same size as a single block!
UV[επεξεργασία | επεξεργασία κώδικα]
   The pixel coordinate of where this bone is in the entity’s texture. Note that this is specified as the x pixel (horizontal) first, then the y pixel (vertical). Note that this pixel should be the top left corner of the square that textures the cube (see example). 
UV Example:[επεξεργασία | επεξεργασία κώδικα]

The red pixel is the pixel you want to specify for the UV for the “body” bone for the creeper (“uv”: [ 16, 16] ). The body will then be textured using the texture in the area enclosed in the dotted line.

CMEMPicture 6.png

Bones and animation:[επεξεργασία | επεξεργασία κώδικα]

Bones are what we use to animate a model. Think of it like a human skeleton! In the human body, bones are moved by muscle, and your flesh moves along with them. In 3D animation, bones are moved by an animation and that, in turn, moves the geometry that is attached to them!

Important Note![επεξεργασία | επεξεργασία κώδικα]

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 mob.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 {} into your new mobs.json and then paste the geometry.creeper from Vanilla’s model file after the first {.
  • 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 } for the lines you just copied.
  • Paste the lines you copied after the comma
  • Add a comma after the } for the lines you just pasted
  • Paste the copied lines again after the new comma
  • You should now have 3 { } sections 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.png

Adding More[επεξεργασία | επεξεργασία κώδικα]

If you want to change another entity’s model, make sure to add a comma after the closing } of “geometry.creeper”.

Pseudocode example:[επεξεργασία | επεξεργασία κώδικα]

Don’t forget the comma! (highlighted)



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