Skip to content

GeckoLib Render Layer

Lucas Bandermann edited this page Mar 24, 2023 · 5 revisions

Setup

Before you start with this, make sure to have read the page about render layers starting at "Creating a Render Layer"!

With GeckoLib you can use their model format for render layers, and even use their animations for them!

For a basic understanding of how modelling for GeckoLib works, read their wiki.

To get started create a render layer like this:

{
  "type": "geckolib3:default",
  "model": "test:geo/gecko_model_test.geo.json",
  "texture": "test:textures/models/gecko_model_test.png"
}

model needs to have the location of your model file. IMPORTANT: Your model needs to have the correct bones/groups in them for them to being applied to the player's body parts. The correct ones are armorHead, armorBody, armorRightArm, armorLeftArm, armorRightLeg, armorLeftLeg. You can define custom names for the bones if required, which is explained at the bottom of this page.

texture is the texture location for the model. You can use the extensive system of texture described on the main render layer page here.

Adding animations

You can also make use of GeckoLib's animation system to animate certain new added parts of your model. There are two ways of doing so: If you want to start an animation at a given time, use a power and use the geckolib3:render_layer_animation ability! If you want to add a looping one, you have to further define an animation controller. An animation controller holds an animation. Only one at a time! So if you want to have multiple animations at the same time, you'll have to make use of this too. The "initial_animation" part here is what defines what animation will be started with. If your animation is set to loop, this will of course loop forever.

{
  "type": "geckolib3:default",
  "model": "test:geo/gecko_model_test.geo.json",
  "texture": "test:textures/models/gecko_model_test.png",
  "animation_file": "test:animations/gecko_model_test.animation.json",
  "animation_controllers": [
    {
      "name": "looping",
      "initial_animation": "animation.model.loop"
    }
  ]
}

Defining custom bone names

If you don't want to use the pre-defined bone names mentioned in the first step, you can tell the render layer to use custom ones like this:

{
  "type": "geckolib3:default",
  "model": "test:geo/gecko_model_test.geo.json",
  "texture": "test:textures/models/gecko_model_test.png",
  "animation_file": "test:animations/gecko_model_test.animation.json",
  "animation_controllers": [
    {
      "name": "looping",
      "initial_animation": "animation.model.loop"
    }
  ],
  "bones": {
    "head": "armorHead",
    "body": "armorBody",
    "right_arm": "armorRightArm",
    "left_arm": "armorLeftArm",
    "right_leg": "armorRightLeg",
    "left_leg": "armorLeftLeg"
  }
}
Clone this wiki locally