Creating the Entity Class
The first step in making a GeckoLib entity is to create the entity class itself.
This tutorial is specifically for GeckoLib implementation. For information on general-modding entity features, seek a tutorial or community support.
Making the class
Green highlights show added or modified lines of code for each step.
First, we will make the base entity class:
public class ExampleEntity extends PathfinderMob {
public ExampleEntity(EntityType<? extends PathfinderMob> entityType, Level level) {
super(entityType, level);
}
}
Then, we will implement the GeoEntity interface and override the getAnimatableInstanceCache and registerControllers methods:
public class ExampleEntity extends PathfinderMob implements GeoEntity {
public ExampleEntity(EntityType<? extends PathfinderMob> entityType, Level level) {
super(entityType, level);
}
@Override
public void registerControllers(final AnimatableManager.ControllerRegistrar controllers) {
// We can fill this in later
}
@Override
public AnimatableInstanceCache getAnimatableInstanceCache() {
return null;
}
}
Next, let's instantiate an AnimatableInstanceCache in a final field at the top of our class, and return it in getAnimatableInstanceCache:
public class ExampleEntity extends PathfinderMob implements GeoEntity {
private final AnimatableInstanceCache geoCache = GeckoLibUtil.createInstanceCache(this);
public ExampleEntity(EntityType<? extends PathfinderMob> entityType, Level level) {
super(entityType, level);
}
@Override
public void registerControllers(final AnimatableManager.ControllerRegistrar controllers) {
// We can fill this in later
}
@Override
public AnimatableInstanceCache getAnimatableInstanceCache() {
return this.geoCache;
}
}
And you're done!
For information on adding animation controllers, see the Animation Controllers page.
Registering the entity
Once you have created your entity class, you then need to register it. This differs depending on the modloader you are using.
Select your loader below for a link to that loader's documentation for registering entities.