AzureLib

Updating Guide: 2.x to 3.x

Updating Armor

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

Armor Item Class

public class ExampleArmor extends ArmorItem implements GeoItem {
// Geckolib used GeckoLibUtil
private final AnimatableInstanceCache cache = AzureLibUtil.createInstanceCache(this);
public ExampleArmor(Type type) {
super(ArmorMaterials.NETHERITE, type, new 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 EQUIP_ANIMATION = RawAnimation.begin().thenLoop("equipping");
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar controllers) {
// Trigger Animations on armors did not with Azurelib 2.x and older and in Geckolib
controllers.add(
new AnimationController<>(this, "base_controller", 0,
state -> PlayState.CONTINUE).triggerableAnim(
"equipping",
EQUIP_ANIMATION
)
);
}
public class ExampleArmorDispatcher {
private static final AzCommand EQUIP_COMMAND = AzCommand.create(
"base_controller",
"equipping",
AzPlayBehaviors.LOOP
);
public void equip(Entity entity, ItemStack itemStack) {
EQUIP_COMMAND.sendForItem(entity, itemStack);
}
}

Rendering

public class ExampleArmorRenderer<D extends ArmorItem> extends GeoArmorRenderer<ExampleArmor> {
public ExampleArmorRenderer() {
super(new DefaultedItemGeoModel<>(ResourceLocation.fromNamespaceAndPath(
YOUR_MOD_ID, "examplearmor"
)));
}
}

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

Registering

@Override
public void createRenderer(Consumer<RenderProvider> consumer) {
consumer.accept(new RenderProvider() {
private ExampleArmorRenderer<ExampleArmor> renderer;
@Override
public HumanoidModel<LivingEntity> getHumanoidArmorModel(
LivingEntity livingEntity,
ItemStack itemStack,
EquipmentSlot equipmentSlot,
HumanoidModel<LivingEntity> original
) {
if (renderer == null) {
renderer = new ExampleArmorRenderer<ExampleArmor>();
}
renderer.prepForRender(livingEntity, itemStack, equipmentSlot, original);
return this.renderer;
}
});
}

Now simply call the AzArmorRendererRegistry#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_ARMOR_HELMET,
YourItemRegistry.YOUR_ARMOR_CHESTPLATE,
YourItemRegistry.YOUR_ARMOR_LEGGINGS,
YourItemRegistry.YOUR_ARMOR_BOOTS);