Creating the Renderer
Once you've made your armor item class and registered your item, you can now create the armor renderer and apply it.
Making the class
- Simple
- Advanced
Simple Renderer Class
By default, GeckoLib does not require a custom renderer class, and you can instead just pass a new instance of
GeoArmorRenderer when applying your renderer.
If you do not require any custom handling of your armor's rendering, this is the recommended approach.
E.G.
// Applying the renderer
() -> new GeoArmorRenderer<>(ExampleArmorItem.this);
Advanced Renderer Class
This option is for creating a standalone renderer class that can override methods for additional handling.
Green highlights show added or modified lines of code for each step.
To begin, let's create a renderer class that extends GeoArmorRenderer:
public class ExampleArmorRenderer extends GeoArmorRenderer {
}
Then, we'll need to add in the generic types that the renderer requires:
For more information on this, see The generic types section.
public class ExampleArmorRenderer<R extends HumanoidRenderState & GeoRenderState> extends GeoArmorRenderer<ExampleArmorItem, R> {
}
And then we add in the constructor, passing in the Item to automatically create the GeoModel:
public class ExampleArmorRenderer<R extends HumanoidRenderState & GeoRenderState> extends GeoArmorRenderer<ExampleArmorItem, R> {
public ExampleArmorRenderer(Item item) {
super(item);
}
}
That's it! Now you need to apply it to the item.
The generic types
In step 2, we added in the generic types that the renderer requires.
But what are these generic types?
R- This is theRenderStatetype. GeckoLib armor rendering requiresHumanoidRenderState, combined with GeckoLib'sGeoRenderState. For more information on RenderStates, see the RenderStates page.ExampleArmorITem- This is your item! Replace this with your item's class name.
The asset files
If you followed the above instructions, GeckoLib will be looking for your asset files (.geo.json, .animation.json, .png)
in the /armor/ subdirectory, named the same as your item's registered id.
For example, if your item was registered as example_armor_item, your files should be:
- Model:
resources/assets/<mod_id>/geckolib/models/armor/example_armor_item.geo.json- Animations:
resources/assets/<mod_id>/geckolib/animations/armor/example_armor_item.animation.json- Texture:
resources/assets/<mod_id>/textures/armor/example_armor_item.png
Where <mod_id> is the id of your mod.
See the Placing the Files page for more information on where to place these files.