Making GeoModels - Rift-Modding-Group/RiftLibrary GitHub Wiki
GeoModels are where the model, animations, and textures of an entity are tied together. They are made by creating a concrete subclass of the generic superclass AnimatedGeoModel<T>
, where T is the entity, block, item, or armor piece being animated. Defining such a subclass is required for any object you want to animate using RiftLibrary.
AnimatedGeoModel requires you to implement 3 methods:
This should return a ResourceLocation
pointing to your model file. It must point to any model file in resources/assets/<modid>/geo
, or in any sub-directory thereof.
This should return a ResourceLocation
pointing to your texture file. It must point to any texture file in resources/assets/<modid>/textures
, or in any sub-directory thereof.
This should return a ResourceLocation
pointing to your animation file. It must point to any animation file in resources/assets/<modid>/animations
, or in any sub-directory thereof.
The following is a GeoModel for the Red Dragon example
public class DragonModel extends AnimatedGeoModel<DragonEntity> {
@Override
public ResourceLocation getModelLocation(DragonEntity object) {
return new ResourceLocation(RiftLib.ModID, "geo/dragon.geo.json");
}
@Override
public ResourceLocation getTextureLocation(DragonEntity object) {
return new ResourceLocation(RiftLib.ModID, "textures/model/entity/dragon.png");
}
@Override
public ResourceLocation getAnimationFileLocation(DragonEntity animatable) {
return new ResourceLocation(RiftLib.ModID, "animations/dragon.animation.json");
}
}
You may have noticed that all the required return methods have a parameter accepting the object to animate. As GeoModels are updated every tick, you can use this to your advantage to, say, change textures depending on whatever state for an entity. Here's an example from Prehistoric Rift's RiftCreatureModel
:
@Override
public ResourceLocation getTextureLocation(RiftCreature object) {
String name = object.creatureType.name().toLowerCase();
boolean sleeping = object.isSleeping();
if (object.getVariant() >= 0 && object.getVariant() <= 3) {
return new ResourceLocation(RiftInitialize.MODID, "textures/entities/"+name+"/"+name+"_"+(object.getVariant()+1)+(sleeping ? "_sleep" : "")+".png");
}
else {
return new ResourceLocation(RiftInitialize.MODID, "textures/entities/"+name+"_1.png");
}
}