@OverridepublicvoidregisterControllers(ControllerRegistrar controllers) {controllers.add(newAnimationController<>(this,"controllerName",0, event -> {returnevent.setAndContinue(// If moving, play the walking animationevent.isMoving() ?RawAnimation.begin().thenLoop("walking"):// If not moving, play the idle animationRawAnimation.begin().thenLoop("idle")); })// Sets a Sound KeyFrame.setSoundKeyframeHandler(event -> {//Plays the step sound on the walk keyframes in an animationif (event.getKeyframeData().getSound().matches("walk"))if (level().isClientSide())level().playLocalSound(this.getX(),this.getY(),this.getZ(),DoomSounds.PINKY_STEP,SoundSource.HOSTILE,0.25F,1.0F,false); }));}
Creating the model class
Create a new class that extends GeoModel, then implement all the required methods:
publicclassExampleEntityModelextendsGeoModel<ExampleEntity> {// Models must be stored in assets/<modid>/geo with subfolders supported inside the geo folderprivatestaticfinalResourceLocation model =newResourceLocation("yournamespace","geo/yourmodel.geo.json");// Textures must be stored in assets/<modid>/geo with subfolders supported inside the textures folder private static final ResourceLocation texture = new ResourceLocation("yournamespace", "textures/<modeltype>/yourtexture.png");
// Animations must be stored in assets/<modid>/animations with subfolders supported inside the animations folder private static final ResourceLocation animation = new ResourceLocation("yournamespace", "animations/youranimation.animation.json");
@OverridepublicResourceLocationgetModelResource(ExampleEntity object) {returnthis.model; } @OverridepublicResourceLocationgetTextureResource(ExampleEntity object) {returnthis.texture; } @OverridepublicResourceLocationgetAnimationResource(ExampleEntity object) {returnthis.animation; }}
Creating the renderer class
Create a class that extends GeoEntityRenderer, then just set it like so: