---
title: "Updating Guide: 2.x to 3.x"
hide_meta: true
---

# Updating Items

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

## Item Class

<CodeTabs>

```java !!tabs AzureLib 2.x/Geckolib
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;
    }
}
```

```java !!tabs AzureLib 3.x
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);
        }
    }
}
```

</CodeTabs>

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

<Callout variant="info">
    See [here](../misc/animating/azcommands_101) for a more indepth info about AzCommands
</Callout>

<CodeTabs>

```java !!tabs AzureLib 2.x/Geckolib
    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
            )
        );
    }
```

```java !!tabs AzureLib 3.x
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;
    }
}
```

</CodeTabs>

<Callout variant="info">
    It is recommend to created a dedicated class for your Animation triggers as AzureLib now functions only using animation trigger calls, which is registered in your item like in the example above of the new Item class:
</Callout>
```java
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

<Callout variant="info">
    See [here](../misc/rendering/azrenderer_config#azitemrendererconfig) for a more indepth example
</Callout>
<Callout variant="warning">
    There is currently a bug in the plugin which exports the displays with an offset applied, please use useNewOffset(true) in your AzItemRendererConfig builder to fix this.
</Callout>

<CodeTabs>

```java !!tabs AzureLib 2.x/Geckolib
public class ExampleItemRenderer<D extends ArmorItem> extends GeoItemRenderer<ExampleItem> {
    public ExampleItemRenderer() {
        super(new DefaultedItemGeoModel<>(ResourceLocation.fromNamespaceAndPath(
            YOUR_MOD_ID, "exampleitem"
        )));
    }
}
```

```java !!tabs AzureLib 3.x
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()
        );
    }
}
```

</CodeTabs>

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

## Registering

<CodeTabs>

```java !!tabs AzureLib 2.x/Geckolib
    @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;
            }
        });
    }
```

```java !!tabs AzureLib 3.x
AzItemRendererRegistry.register(ExampleItemRenderer::new, YourItemRegistry.YOUR_ITEM);
```

</CodeTabs>

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

## Registering your Armor for proper animation triggering

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

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