Custom Entity Models

What is it?
Custom Entitiy Models (CEM) is the OptiFine feature that allows you to edit and change the models of existing entities in Minecraft. CEM allows you to both change the model of the entity, and the animations of the entitiy.

Useful key words
Short for Custom Entity Models Also known as CEM Animation, Custom Entity Model Animations, or Ceminations. An element is the cubes which will make up your model. A folder in which elements are stored for both organisation, rotation, and animation purposes. The topmost bone in a list of bones. This bone is not inside any other bones.
 * CEM
 * CEMA
 * Element
 * Bone
 * Parent Bone

Limitations
Before you get started modelling, it is useful to know the limitations that you will have to work with, because if you do not follow these, you will wonder why you model is incorrect in game or not loading at all.

On each CEM model, you are limited to using the parent bones that that entity has by default. A full list of these can be found here. Every single element you add must be inside one of these parent bones. Adding a new parent bone will cause the model to fail to load in game.
 * Parent Bones

You cannot edit the pivot points of the entities within vanilla. An example of something you would not be able to do is moving the leg of a cow, as that would require moving its legs pivot point. Please note however, this can be done using CEMA. While modelling the entitiy, pivot points on bones will behave as expected, allowing you to rotate elements around a point, however this is not the case for parent bones. If you load/use a template model, all the parent bones will already have their pivot points set up correctly. Do not touch these, or you will break the model when you try and load it in game. If for whatever reason you need to move the pivot points in the model, this is how it works:
 * Pivot Points
 * The elements are tied to the pivot point in game. Increasing the gap between the pivot point and the elements will increase the gap between the actual pivot point and the elements in game. For example, If you move the pivot point 12 pixels east inside the model, the elements will appear 12 pixels west in game. This is because, as the pivot point cannot be moved in game, the elements will move instead. The elements render relative to the pivot point. If you didn't understand this, don't worry, it is very unlikely that you will need to edit these pivot points.

Getting started
The easiest way to make models is using Blockbench, which is a boxy 3D model editor designed specifically for Minecraft! When selecting a mode to create your model with, make sure to select the OptiFine mode. From here you can start modelling, or load in a template. You can find a full selection of templates with CEM Template Loader

Modelling
This tutorial will show you the basics to modelling a CEM model.

Random entity models
If you wish to make randomised entity models, you cannot. Instead you have to use a workaround. To make randomised entity models, you will actually have to make all of your different models in the same model, and then switch out the texture to show and hide different models. Models will be shown by texturing those cubes, and models will be hidden by leaving those cubes untextured/transparent.

This tutorial will show you how to get random entity models working.

Random entity models will work with any method from the OptiFine random entities documentation. Please note, random entity models will not work on entities that do not support transparency, as this relies on transparency to work.

Saving your model
When you are finished creating your model, you will need to save it. Custom entity models should be saved to the assets/minecraft/optifine/cem folder with the name of the entity that you are replacing. If you are unsure what the name formatting is, you can check here.

When saving the model, you will need to save it in different ways depening on the texture.
 * If there is only going to be one texture used, you will save the texture in the cem folder, and then save the model there too.


 * If you are using random entities, or are using the vanilla entity skin variants with things like horses and cats, you will need to replace those textures. Next you will need to remove the texture from the model, before saving it in the cem folder.

It is done this way, because if you save the model with the texture in it, the game expects the texture to be in the CEM folder. If that texture is then not found, then it will show a missing texture. If you remove the texture from the model before saving, then the game will load the default texture instead of the CEM one.

CEM animation
To create custom animations for your entity model, you will need to use a text editor and code them into the model manually. Two recommended text editors are Sublime Text and Notepad++. Do not use the default Windows notepad application as it does not support indentation.

This tutorial will show the basics of CEMA, and a couple different ways to use it.

For a full list of CEMA perameters, please refer to the OptiFine CEMA Documentation

Model structure
For more advanced users, you can edit the model file directly to make your custom entity model. This is the JSON structure that is used in CEM: