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 GeckoLibUtilprivate final AnimatableInstanceCache cache = AzureLibUtil.createInstanceCache(this);public ExampleItem(Properties properties) {super(properties);}@Overridepublic void createRenderer(Consumer<RenderProvider> consumer) {// Where you registered your Renderer}@Overridepublic void registerControllers(AnimatableManager.ControllerRegistrar controllers) {// Where you registered your Controllers and such}@Overridepublic 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");@Overridepublic void registerControllers(AnimatableManager.ControllerRegistrar controllers) {controllers.add(new AnimationController<>(this, "base_controller", 0,state -> PlayState.CONTINUE).triggerableAnim("firing",FIRING_ANIMATION));}
Heads up!
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:
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
@Overridepublic void createRenderer(Consumer<RenderProvider> consumer) {consumer.accept(new RenderProvider() {private ExampleItemRenderer renderer = null;@Overridepublic 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, ...);