Working directory: all custom entity files will be placed into assets/minecraft/optifine/cem in your resourcepack.
A jem file is required when entity modelling, it is the main file which specifies how to re-model an entity.
You simply need to create a jem file named as the entity that you want to have a custom model, ie zombie.jem.
A full list of entities and the names of the files can be found in the optifine's jem documentation along with a list of parts which can be replaced in each entity.
jem stands for JSON Entity Model, meaning that the file must be written in valid JSON.
Firstly "models" is a required parameter which is an array, it will contain objects which then contain models and which parts they replace.
#part must be replaced with one of the parts specified in the optifine's jem documentation. ie "head", "body", "leg1".
#model can be replaced one of two things, you can use a jpm file, or you can specify the model in-line by creating the elements within the jem file itself.
You can replace #model with elements (explained further down), or with "model": "file_name.jpm".
There is some other values that will come in handy which are: "attach": < true | false >, "translate": [x, y, z], "rotate": [x, y, z].
"attach" will default to false if left out, but if set to true will add the model to the part specified rather than replacing it.
"translate" will move the element the number of pixels on the specified axes.
"rotate" will rotate the element on the axes the amount of degrees.
jpm stands for JSON Part Model, which means that the file must be valid JSON. jpm files must be located within the optifine/cem folder.
A jpm file is purely a part which can consist of multiple elements which can then be used by jem files when replacing parts.
These files do not need to have specific names. But you need to create at least one element.
Instead of writing jpm files by hand, Cubik Studio (~ €20), a modelling program which supports Minecraft json block models, also has the ability to export jpms from the program itself.
You can also use blockbench a free block modelling program, which can be downloaded or used online, which can also export optifine jpms.
This means you won't have to write a jpm by hand but can just create and export models from Cubik Studio or blockbench.
This is a basic method of creating elements, note that "coordinates" works quite differently from that when block modelling. The first three values are the location of the element, the next three are actually the width, height and depth.
"coordinates": [0, 0, 0, 2, 2, 2]
"coordinates": [3, 4, 0, 2, 2, 2]
Both of these elements will be the same size but will be in different places.
There is two ways to texture elements but first you need to specify the texture that will be used by the element by specifying the path following assets/minecraft ie, "texture": "textures/entity/pig/pig.png". You also need to put the size of the texture in pixels ie, "textureSize": [64, 32].
When texturing an element you can specify the uv mapping of individual faces with: "uvUp", "uvDown", "uvNorth", "uvEast", "uvSouth", "uvWest".
ie "uvUp": [0, 0, 4, 6]. The first two numbers are the most top left coordiante of the area you want to have the texture then the next two will be the opposite most right down corner.
The second method is to use "textureOffset" which works with a unwrapped box texture layed out in this specific format. You specify one set of coordinates which is the most top left coordinates of the rectangle drawn around the unwrapped box. From this example the coordinates would be [0, 0], ie "textureOffset": [0, 0].
Custom animations can be applied to each part of the entity, they are created by mathematical equations located within the jem file for mobs. You can read the optifine documentation on animations for more information.
The animation equations used for custom animations are located within an object, within an array called "animations" which will be inside the object within the "models" array in the jem file.
Each equation will start with a key for the model the animations will affect. This is done through use of a model variable in the format <model>.<variable>:
The main two model properties are:
part - part refers to the part that the custom model has been attached to or replaced, this will animate the existing part and the model that has replaced/added to the part.
this - this refers to the part that has been added, this will not affect the original part, this can be seen clearly if the new model has been attached instead of replacing.
The variable has 12 possible values and this will define the type of animation and the axis that will be affected.
The type can any one of 4 possible values:
rotation (r), offset (o), translation (t), scale (s)
Followed by one of the three axis (x, y, z)
Note the difference between translate and offset. Offset refers to an absolute value for the model whereas translate will refer to a relative value, which will be relative to the existing location of the part model.
eg "part.ty", "this.ox", "part.rz"
Following the model variable will be a string which contains a mathematical equation.
There's several variables and functions which can be used within equations.
model variables - Already stated, these can be used to get values from other parts on the entity.
time - This is the world time in ticks and can be used on all entities.
limb_swing, limb_speed - Can only be used with 'living' entities, the swing and speed of entity limbs, these will change when the entity is moving.
+ addition, - subtraction, / division, * multiplication, % modulo (gives the remainder after division)
This is a small problem which seemed impossible to acheive, the idea was to be able to change the origin for limbs as the point from where limbs were swinging couldn't be changed with translate. This would allow legs to be bigger or smaller, further apart or closer together than the original entity.
The way this can be done is using animations to simply translate the limb a fixed amount, and it will move the origin of the part itself.
Is it possible to tie custom entity models to optifines random mob feature? I dont want to replace every creeper in the game with a new model for example, i want to give various textures and have them spawn randomly.
Hello, I have been making a 3D resource pack for my new mini-game. One of the blocks that I have to modify is the Sign, it is an entity model so I had to investigate Custom Entity Models. Within the map, the signs are sometimes placed on Spruce Logs, which, in my 3D pack, extend outwards 2 pixels off of all sides (except for top and bottom). Now this extension prevents the Sign's text from being visible.
I have figured out how to make custom entity models, but what I need to know is how to actually move the text of the sign. Because when you modify the board part of the sign, the text stays floating where it originally was. Do you know how to shift the position of the text itself?
If not, I could always modify the log so that it doesn't stick out as far as it does...