Create a new class that extends GeoModel, then implement all the required methods:
publicclassExampleArmorModelextendsGeoModel<ExampleItem> {// Models must be stored in assets/<modid>/geo with subfolders supported inside the geo folderprivatestaticfinalResourceLocation model =newResourceLocation("yournamespace","geo/yourmodel.geo.json");// Textures must be stored in assets/<modid>/textures with subfolders supported inside the textures folder private static final ResourceLocation texture = new ResourceLocation("yournamespace", "textures/<modeltype>/yourtexture.png");
// Animations must be stored in assets/<modid>/animations with subfolders supported inside the animations folder private static final ResourceLocation animation = new ResourceLocation("yournamespace", "animations/youranimation.animation.json");
@OverridepublicResourceLocationgetModelResource(ExampleItem object) {returnthis.model; } @OverridepublicResourceLocationgetTextureResource(ExampleItem object) {returnthis.texture; } @OverridepublicResourceLocationgetAnimationResource(ExampleItem object) {returnthis.animation; }}
Creating the renderer class
Create a class that extends GeoArmorRenderer, then just set it like so:
// For versions 1.21+, Object has been replaced with RenderProvider, and there is no need to call renderProvider or getRenderProvider().
privatefinalSupplier<RenderProvider> renderProvider =GeoItem.makeRenderer(this);// Creates the renderer@OverridepublicvoidcreateRenderer(Consumer<RenderProvider> consumer) {consumer.accept(newRenderProvider() {// Your custom armor rendererprivateExampleArmorRenderer renderer; /** * Returns a custom humanoid armor model for the entity, based on the given equipment slot. * * @param livingEntity The entity wearing the armor. * @param itemStack The item stack representing the armor. * @param equipmentSlot The equipment slot where the armor is equipped (e.g., head, chest). * @param original The original humanoid model. * @return The humanoid model used for rendering the armor. */ @Override public @NotNull HumanoidModel<LivingEntity> getHumanoidArmorModel(LivingEntity livingEntity, ItemStack itemStack, EquipmentSlot equipmentSlot, HumanoidModel<LivingEntity> original) {
if (renderer == null) { renderer =newExampleArmorRenderer(); // Create the renderer if it doesn't exist } renderer.prepForRender(livingEntity, itemStack, equipmentSlot, original);returnthis.renderer; } });}/** * Returns the render provider, but for 1.21+ this method is no longer necessary. * You no longer need to call getRenderProvider() or store the renderProvider. * * @return The render provider (not needed in 1.21+). */@OverridepublicSupplier<RenderProvider>getRenderProvider() {return renderProvider;}
Forge 1.19.4 and older
In your Item class, add:
/** * Initializes client-side extensions for the item, including custom rendering for armor. * This method sets up how the armor item should be rendered when equipped on a humanoid entity. * * @param consumer A {@link Consumer} that accepts an {@link IClientItemExtensions} object to handle client-side item extensions.
*/@OverridepublicvoidinitializeClient(Consumer<IClientItemExtensions> consumer) {consumer.accept(newIClientItemExtensions() {privateExampleItemRenderer renderer; /** * Provides the humanoid armor model for the item, preparing it for rendering based on the entity and equipment slot.
* This method determines how the armor should be rendered when equipped on a humanoid entity. * * @param livingEntity The {@link LivingEntity} wearing the armor. * @param itemStack The {@link ItemStack} representing the armor item. * @param equipmentSlot The {@link EquipmentSlot} where the armor is equipped (e.g., head, chest). * @param original The original {@link HumanoidModel} to be replaced or modified. * @return The {@link HumanoidModel} used for rendering the armor, which includes custom rendering logic. */ @Override public @NotNull HumanoidModel<?> getHumanoidArmorModel(LivingEntity livingEntity, ItemStack itemStack, EquipmentSlot equipmentSlot, HumanoidModel<?> original) {
if (renderer == null) {// Create the renderer if it doesn't exist renderer =newExampleItemRenderer(); }// Prepare the renderer with the current entity and armor information renderer.prepForRender(livingEntity, itemStack, equipmentSlot, original);returnthis.renderer; } });}