Skip to content

RiftLibrary Entities

ANightDazingZoroark edited this page Jul 5, 2025 · 4 revisions

Steps

Creating an entity in RiftLibrary requires the following steps:

  1. Creating your Blockbench Model
  2. Creating your Geo Model
  3. Creating your entity class
  4. Creating and registering your renderer

Steps #1 and #2 will not be covered on this page, instead visit their respective links for info. This page will focus on steps #3 and #4

The Entity Class

The first step is to implement the IAnimatable interface on your entity class, and override the two methods your IDE may ask you to. These methods are:

  • registerControllers(AnimationData data): This method is where animations for your entity are registered and controlled
  • getFactory(): This method returns an instance of AnimationFactory

The final step is to define a new instance of AnimationFactory as a global variable, and in its constructor put this. Make getFactory() return this global variable.

Here's an example class showing the result:

public class ExampleEntity extends EntityLiving implements IAnimatable {
        private final AnimationBuilder FLY_ANIM = new AnimationBuilder().addAnimation("move.fly", true);
        private final AnimationFactory factory = new AnimationFactory(this);

        public ExampleEntity(World worldIn) {
            super(worldIn);
        }
    
        @Override
        public void registerControllers(AnimationData data) {
            data.addAnimationController(new AnimationController<>(this, "flying", 0, this::flyAnimController));
        }
        
        private PlayState flyAnimController(AnimationEvent event) {
            if (event.isMoving()) {
                event.getController().setAnimation(FLY_ANIM);
                return PlayState.CONTINUE;
            }

            return PlayState.STOP;
        }
    
        @Override
        public AnimationFactory getFactory() {
            return this.factory;
        }
}

The Renderer

Like any other entity, you need to assign a renderer to your entity. It must extend GeoEntityRenderer<T>, with T being the entity you're making the renderer for. Here's an example renderer class:

public class ExampleEntityRenderer extends GeoEntityRenderer<ExampleEntity> {
    public ExampleEntityRenderer(RenderManager renderManager) {
        super(renderManager, new ExampleEntityModel());
    }
}

Finally, in the FMLPreInitializationEvent event of your mod, register your entity renderer as so:

RenderingRegistry.registerEntityRenderingHandler(ExampleEntity.class, ExampleEntityRenderer::new);

Going Further

Entity Scaling

IAnimatable happens to have a scale() method that, by default, returns 1. You can override this to change the scale of your entity's model.

Editing the renderer

You can override the render(GeoModel model, T animatable, float partialTicks, float red, float green, float blue, float alpha) method in your GeoEntityRenderer class to change how your entity may be rendered. Some examples include:

Clone this wiki locally