AzureLib

Updating Guide: 2.x to 3.x

Updating Items

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

Item Class

public class ExampleItem extends Item implements GeoItem {
// Geckolib used GeckoLibUtil
private final AnimatableInstanceCache cache = AzureLibUtil.createInstanceCache(this);
public ExampleItem(Properties properties) {
super(properties);
}
@Override
public void createRenderer(Consumer<RenderProvider> consumer) {
// Where you registered your Renderer
}
@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 or renderer here. All that is needed now is to simply implement a Dispatcher, which we will cover below.

Animations

private static final RawAnimation FIRING_ANIMATION = RawAnimation.begin().thenLoop("firing");
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar controllers) {
controllers.add(
new AnimationController<>(this, "base_controller", 0,
state -> PlayState.CONTINUE).triggerableAnim(
"firing",
FIRING_ANIMATION
)
);
}
public class ExampleItemDispatcher {
private static final AzCommand FIRING_COMMAND = AzCommand.create("base_controller", "firing", AzPlayBehaviors.PLAY_ONCE);
public void firing(Entity entity, ItemStack itemStack) {
FIRING_COMMAND.sendForItem(entity, itemStack);
}
}

Rendering

public class ExampleItemRenderer<D extends ArmorItem> extends GeoItemRenderer<ExampleItem> {
public ExampleItemRenderer() {
super(new DefaultedItemGeoModel<>(ResourceLocation.fromNamespaceAndPath(
YOUR_MOD_ID, "exampleitem"
)));
}
}

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

Registering

@Override
public void createRenderer(Consumer<RenderProvider> consumer) {
consumer.accept(new RenderProvider() {
private ExampleItemRenderer renderer = null;
@Override
public BlockEntityWithoutLevelRenderer getCustomRenderer() {
this.renderer = new ExampleItemRenderer();
return this.renderer;
}
});
}

Now simply call the AzItemRendererRegistry#register() in your onInitializeClient for Fabric and FMLClientSetupEvent for Neoforge/Forge

To ensure trigger animations work properly, you will need to also call AzIdentityRegistry#register() in your onInitialize for Fabric and FMLCommonSetupEvent for NeoForge/Forge like so:

AzIdentityRegistry.register(YourItemRegistry.YOUR_ITEM, ...);