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

Old Item class in AzureLib/GeckolibNew 3.x Armor 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;
}
}
public class ExampleItem extends Item {
// This is your class where you will setup the AzCommands/Animations you wish to play
public final ExampleItemDispatcher dispatcher;
public ExampleItem(Properties properties) {
super(properties);
// Create the instance of the class here to use later.
this.dispatcher = new ExampleItemDispatcher();
}
@Override
public void onUseTick(Level level, LivingEntity livingEntity, ItemStack stack, int remainingUseDuration) {
super.onUseTick(level, livingEntity, stack, remainingUseDuration);
if (livingEntity instanceof Player player && !level.isClientSide()) {
// This is where you now trigger an animation to play
dispatcher.firing(player, stack);
}
}
}

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

Old AzureLib/Geckolib Controller/Animation registrationNew 3.x Controller/Animation registration
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 ExampleItemAnimator extends AzItemAnimator {
private static final ResourceLocation ANIMATIONS = ResourceLocation.fromNamespaceAndPath(
YOUR_MOD_ID,
"animations/item/exampleitem.animation.json"
);
@Override
public void registerControllers(AzAnimationControllerContainer<ItemStack> animationControllerContainer) {
animationControllerContainer.add(
AzAnimationController.builder(this, "base_controller")
.build()
);
}
@Override
public @NotNull ResourceLocation getAnimationLocation(ItemStack animatable) {
return ANIMATIONS;
}
}
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

Old AzureLib/Geckolib RendererNew 3.x Renderer
public class ExampleItemRenderer<D extends ArmorItem> extends GeoItemRenderer<ExampleItem> {
public ExampleItemRenderer() {
super(new DefaultedItemGeoModel<>(ResourceLocation.fromNamespaceAndPath(
YOUR_MOD_ID, "exampleitem"
)));
}
}
public class ExampleItemRenderer extends AzItemRenderer {
private static final ResourceLocation GEO = ResourceLocation.fromNamespaceAndPath(
YOUR_MOD_ID,
"geo/item/exampleitem.geo.json"
);
private static final ResourceLocation TEX = ResourceLocation.fromNamespaceAndPath(
YOUR_MOD_ID,
"textures/item/exampleitem.png"
);
public ExampleItemRenderer() {
super(
AzItemRendererConfig.builder(GEO, TEX)
.setAnimatorProvider(ExampleItemAnimator::new).build()
);
}
}

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

Registering

Old Registering method that was done in your Item classNew 3.x Registering method
@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;
}
});
}
AzItemRendererRegistry.register(ExampleItemRenderer::new, YourItemRegistry.YOUR_ITEM);

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, ...);