A guide for converting AzureLib/Geckolib Entities to the new 3.x code.
Entity Class
public class ExampleEntity extends Entity implements GeoEntity {private static final RawAnimation IDLE = RawAnimation.begin().thenLoop("idle");// Geckolib used GeckoLibUtilprivate final AnimatableInstanceCache cache = AzureLibUtil.createInstanceCache(this);public ExampleEntity(EntityType<? extends Entity> entityType, Level level) {super(entityType, level);}@Overridepublic void registerControllers(AnimatableManager.ControllerRegistrar controllers) {controllers.add(new AnimationController<>(this, "base_controller", 0,state -> state.setAndContinue(IDLE)));}@Overridepublic AnimatableInstanceCache getAnimatableInstanceCache() {return cache;}}
As you can see here, you no longer need to implement a Geo interface to your class anymore and no longer register your controllers here. All that is needed now is to simply implement a Dispatcher, which we will cover below.
Animations
private static final RawAnimation IDLE = RawAnimation.begin().thenLoop("idle");@Overridepublic void registerControllers(AnimatableManager.ControllerRegistrar controllers) {controllers.add(new AnimationController<>(this, "base_controller", 0,state -> state.setAndContinue(IDLE)));}
public class ExampleEntityDispatcher {private static final AzCommand IDLE_COMMAND = AzCommand.create("base_controller","idle",AzPlayBehaviors.LOOP);private final ExampleEntity example_entity;public DoomHunterAnimationDispatcher(ExampleEntity animatable) {this.example_entity = animatable;}public void idle() {IDLE_COMMAND.sendForEntity(example_entity);}}
Rendering
public class ExampleEntityRenderer extends GeoEntityRenderer<ExampleEntity> {public ExampleEntityRenderer() {super(new DefaultedEntityGeoModel<>(ResourceLocation.fromNamespaceAndPath(YOUR_MOD_ID, "example_entity")));}}
This is where you will now register the ResourceLocation model and texture of your armor and you register your ExampleEntityAnimator.
Registering
Basic Example of Fabric and NeoForge
@Overridepublic void onInitializeClient() {EntityRendererRegistry.register(EntityType.CREEPER, ExampleEntityRenderer::new);}