Skip to main content
Version: GeckoLib5

Defaulted GeoModels

DefaultedGeoModels are the next best option for implementing GeoModels if letting the renderer do it automatically doesn't give you enough control.

How do they work?

Defaulted GeoModels take a simple Identifier input, and automatically generate model, animations, and texture resource paths based on that identifier, automatically applying a subfolder for easier file management.

This allows you to keep your file names consistent and avoid having to manually define every path.

Usage

To create a new Defaulted GeoModel, you can either use one of the existing implementations or create your own.

Using an existing implementation

GeckoLib has three existing implementations of Defaulted GeoModels:

  • DefaultedEntityGeoModel
  • DefaultedBlockGeoModel
  • DefaultedItemGeoModel

Examples

Example DefaultedItemGeoModel Usage
new DefaultedItemGeoModel(Identifier.fromNamespaceAndPath(ExampleMod.MOD_ID, "example_item"));

Then, we would place our assets in these locations:

Model/assets/examplemod/geckolib/models/item/example_item.geo.json
Animations/assets/examplemod/geckolib/animations/item/example_item.animation.json
Texture/assets/examplemod/textures/item/example_item.png
Example DefaultedEntityGeoModel Usage
new DefaultedEntityGeoModel(Identifier.fromNamespaceAndPath(ExampleMod.MOD_ID, "animal/example_animal"));

Then, we would place our assets in these locations:

Model/assets/examplemod/geckolib/models/entity/animal/example_animal.geo.json
Animations/assets/examplemod/geckolib/animations/entity/animal/example_animal.animation.json
Texture/assets/examplemod/textures/entity/animal/example_animal.png

Creating a custom Defaulted GeoModel

If the existing implementations don't fit your needs, you can create your own, by creating a new class that extends DefaultedGeoModel.

You will then need to override the subtype method to return the 'type' of object your type is for, which will automatically act as a subfolder name for your asset paths.

Example DefaultedGeoModel Usage
public class ExampleCustomDefaultedGeoModel extends DefaultedGeoModel {
public ExampleCustomDefaultedGeoModel(Identifier identifier) {
super(identifier);
}

@Override
protected String subtype() {
return "custom";
}
}