Updating Guide: 2.x to 3.x

A guide for converting AzureLib/Geckolib Blocks Entities to the new 3.x code.

Block Entities Class

public class ExampleBE extends BlockEntity implements GeoBlockEntity {
// Geckolib used GeckoLibUtil
private final AnimatableInstanceCache cache = AzureLibUtil.createInstanceCache(this);
public ExampleBE(BlockPos pos, BlockState blockState) {
super(YourEntityTypes.EXAMPLE_BE, pos, blockState);
}
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar controllers) {
// Where you registered your Controllers and such
}
@Override
public 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 SPINNING = RawAnimation.begin().thenLoop("spinning");
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar controllers) {
controllers.add(
new AnimationController<>(this, "base_controller", 0,
state -> PlayState.CONTINUE).triggerableAnim(
"spinning",
SPINNING
)
);
}
public class ExampleBEDispatcher {
private static final AzCommand SPINNING_COMMAND = AzCommand.create(
"base_controller",
"spinning",
AzPlayBehaviors.LOOP
);
public void spin(BlockEntity entity) {
SPINNING_COMMAND.sendForItem(entity, itemStack);
}
}

Rendering

public class ExampleBERenderer extends GeoBlockRenderer<ExampleBE> {
public ExampleBERenderer() {
super(new DefaultedBlockGeoModel<>(ResourceLocation.fromNamespaceAndPath(
YOUR_MOD_ID, "examplebe"
)));
}
}

This is where you will now register the ResourceLocation model and texture of your armor and you register your ExampleBEAnimator.

Registering

Basic Example of Fabric and NeoForge

@Override
public void onInitializeClient() {
BlockEntityRenderers.register(
ExampleRegistry.EXAMPLE_BE,
(BlockEntityRendererProvider.Context rendererDispatcherIn) -> new ExampleBERenderer()
);
}