Create a new class that extends GeoModel, then implement all the required methods:
publicclassExampleItemModelextendsGeoModel<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 GeoItemRenderer, then just set it like so:
publicclassExampleItemRendererextendsGeoItemRenderer<ExampleItem > {publicExampleItemRenderer() {// Register the Model class to this render super(newExampleItemModel()); }}
Registering the renderer
Fabric/NeoForge/Forge 1.20.1+
In your Item class, add:
privatefinalSupplier<Object> renderProvider =GeoItem.makeRenderer(this);// Creates the render@OverridepublicvoidcreateRenderer(Consumer<Object> consumer) {// Accepts a consumer to create a new rendererconsumer.accept(newRenderProvider() {// Your render class made aboveprivateExampleItemRenderer renderer =null; @OverridepublicBlockEntityWithoutLevelRenderergetCustomRenderer() {// Check if renderer is null, create a new instance if soif (renderer ==null)returnnewExampleItemRenderer();// Return the existing renderer if it's not nullreturnthis.renderer; } });}@OverridepublicSupplier<Object>getRenderProvider() {// Returns the above renderProvider created abovereturn renderProvider;}
Forge 1.19.4 and older
In your Item class, add:
@OverridepublicvoidinitializeClient(Consumer<IClientItemExtensions> consumer) {// Accepts a consumer to create a new rendererconsumer.accept(newIClientItemExtensions() {// Your render class made aboveprivateExampleItemRenderer renderer =null; @OverridepublicBlockEntityWithoutLevelRenderergetCustomRenderer() {// Check if renderer is null, create a new instance if soif (renderer ==null)returnnewExampleItemRenderer();// Return the existing renderer if it's not nullreturnthis.renderer; } });}