Skip to content

Geo Models (Geckolib4)

Tslat edited this page Jul 31, 2024 · 6 revisions

Geo models are GeckoLib's way of tying together your animatable's resource (json) files, its animation handling, and various other miscellaneous data.

All animatable objects in GeckoLib have a Geo Model of some kind, and as such it is required that you create one for each that you make.

Creating a Geo Model

To create a new Geo Model, simply make a class that extends GeoModel, then implement all the required methods:

getModelResource

This method should return the ResourceLocation path to your .geo.json model file for this animatable

getTextureResource

This method should return the ResourceLocation path to your .png texture file for this animatable

getAnimationResource

This method should return the ResourceLocation path to your .animation.json animation file for this animatable

Example Geo Model
public class ExampleModel extends GeoModel<ExampleItem> {
	private final ResourceLocation model = new ResourceLocation(GeckoLib.ModID, "geo/example.geo.json");
	private final ResourceLocation texture = new ResourceLocation(GeckoLib.ModID, "textures/item/example.png");
	private final ResourceLocation animations = new ResourceLocation(GeckoLib.ModID, "animations/example.animation.json");

	@Override
	public ResourceLocation getModelLocation(ExampleItem object) {
		return this.model;
	}

	@Override
	public ResourceLocation getTextureLocation(ExampleItem object) {
		return this.texture;
	}

	@Override
	public ResourceLocation getAnimationFileLocation(ExampleItem object) {
		return this.animations;
	}
}

File Locations

As a minimum, GeckoLib requires that your asset (model, texture, animation) files be in certain directories in your resources folder. This is to allow for GeckoLib to easily find them. Once they are in these directories however, you are free to put them in any sub-directory of that folder, as long as your GeoModel instance's methods reflect those locations.

Models (.geo.json)

Model files have to go in resources/assets/<modid>/geo, or in any sub-directory thereof.

Animation Files (.animation.json)

Animation files have to go in resources/assets/<modid>/animations, or in any sub-directory thereof.

Textures (.png)

Textures are the same as in vanilla. They must go in resources/assets/<modid>/textures, or in any sub-directory thereof.

Defaulted Models

New to GeckoLib4 are 'Defaulted' GeoModels. These are pre-designed model classes that allow you to make your model with next to no effort. They also encourage consistency of file organisation, and efficient model handling.

It is highly recommended that you use one of the defaulted model classes.

Click here for example
new DefaultedGeoEntityModel(new ResourceLocation(GeckoLib.MOD_ID, "bat"));

This creates a new GeoModel, and sets the following paths automagically:

  • Texture: textures/entity/bat.png
  • Model: geo/entity/bat.geo.json
  • Animation: animations/entity/bat.animation.json

Table of Contents

Geckolib 3
Geckolib 4

Hosted By: Cloudsmith

Package repository hosting is graciously provided by Cloudsmith.

Cloudsmith is the only fully hosted, cloud-native, universal package management solution that enables your organization to create, store and share packages in any format, to any place, with total confidence.

Clone this wiki locally