Skip to content
iam edited this page May 19, 2022 · 17 revisions

Folder Structure

Models Folder

models/ is where you put your custom models. Each model must go in its own folder, with the model name as the folder name. In the demo server you can see that models/ can be found, and within the folder there is another folder with the name gem_golem, for the gem golem model.

Each model folder must contain 3 files:

  • model.animation.json File containing the animations
  • model.geo.json File contain the model data
  • texture.png File contain the model textures

Generating a Resource Pack

FileUtils.copyDirectory(BASE_PATH.resolve("resourcepack_template").toFile(), BASE_PATH.resolve("resourcepack").toFile());

First start by copying a template resource pack. This is your server resource pack which you plan on adding the models to. Feel free to use the resource pack in the demo server

ModelParser.parse(BASE_PATH.resolve("resourcepack/assets/wsee"), MODEL_PATH, BASE_PATH);

Next, call the parse method from ModelParser and tell it where your copied resource pack is, and where your models/ folder is. This is the folder described above, containing your custom entity models. Calling this method will generate a model_mappings.json file in BASE_PATH, which is used in the following steps.

Loading your models

ModelEngine.loadMappings(BASE_PATH.resolve("model_mappings.json"), MODEL_PATH);

Specify where your models are located, and where your mapping file is.

Creating a model

The example below can be found in the test folder.

public class GemGolemModel extends GenericModelImpl {
    private static final String id = "gem_golem";

    @Override
    public String getId() {
        return id;
    }

    public void init(@Nullable Instance instance, @NotNull Pos position, LivingEntity masterEntity, LivingEntity nametag) {
        super.init(instance, position, ModelEngine.RenderType.ZOMBIE, masterEntity, nametag);
    }
}

To create a model you must define the model ID. This is the name of the folder that the model is inside of. For example, in the demo server there is a folder models/gem_golem, and this ID is gem_golem.

Here you can also define the RenderType. This specifies what type of entity to use for drawing the bones. Unless your model is designed to use zombies, use ARMOR_STAND here

A full example of the steps described above can be found here Main.java

Clone this wiki locally