Jump to content

[1.12.2] [SOLVED] Item Model Not Rendering


GooberGunter

Recommended Posts

So I have an item registered in the game, and have a class ItemRenderRegister to register the item to a modelresource location via the following code:

Spoiler

public class ItemRenderRegister {
	public static void registerItemRenderer() {
		Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.oldTome, 0, new ModelResourceLocation("ds:oldtome", "inventory"));

	}

the method is called in the client proxy

but I can't wrap my head around how to use the ModelResourceLocation. I'm getting no errors about a missing json file, the item just simply has not model or texture, which makes it very hard to debug. 

Edited by GooberGunter
Link to comment
Share on other sites

        ModelLoader.setCustomModelResourceLocation(ModItems.oldTome, 0, new ModelResourceLocation("ds:models//item//old_tome.json", "inventory"));
 

still not working

 

Spoiler

{
    "parent": "builtin/generated",
    "textures": {
        "layer0": "ds:items/old_tome"
    }
}

 And I'm not any errors in the log about the texture location so I know that's right. It's just this part. And I also had a problem where I made two instances of the item, registering one and registering the render of the other, which I have fixed.

Edited by GooberGunter
Link to comment
Share on other sites

You should use items/blocks getRegistryName() as the first parameter.
First parameter should not contain any extensions (".json") nor any file-separators ("/"). All of that is automagically done "behind the curtains" for you.

  • Like 1

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Link to comment
Share on other sites

That was suggested in the documentation but i didn't see it in the source code, but I fixed it now. I also added the first parameter, but it's still not showing up

		ModelLoader.setCustomModelResourceLocation(ModItems.oldTome, 0, new ModelResourceLocation(ModItems.oldTome.getRegistryName(), "ds:old_tome"));

Am i supposed to register the render or is the model loader enough?

 

Here is all the code involving the item:

 

ModItems:

Spoiler

package com.GooberGunter.DivineSorcery.common.items;

import java.rmi.registry.Registry;

import com.GooberGunter.DivineSorcery.DSReferences;
import com.GooberGunter.DivineSorcery.common.utils.Util;

import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.item.Item;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

public final class ModItems {
	
	public static Item oldTome = new ItemOldTome("old_tome");
	
	@Mod.EventBusSubscriber
	public static class ItemRegister{
		
		@SubscribeEvent
	    public static void registerItem(RegistryEvent.Register<Item> e) {
	    	e.getRegistry().register(oldTome);
	    	Util.logger.info("ITEMS REGISTERED");
	    }//Items MUST MUST MUST MUST MUST BE REGISTERED IN STATIC FIELDS
	}
}

 

ItemRegisterRender:

Spoiler

package com.GooberGunter.DivineSorcery.client.render.items;

import java.io.FileNotFoundException;
import java.io.IOException;

import com.GooberGunter.DivineSorcery.DSReferences;
import com.GooberGunter.DivineSorcery.common.items.ModItems;
import com.GooberGunter.DivineSorcery.common.utils.Util;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;

public class ItemRenderRegister {
	public static void registerItemRenderer() {
		ModelLoader.setCustomModelResourceLocation(ModItems.oldTome, 0, new ModelResourceLocation(ModItems.oldTome.getRegistryName(), "ds:old_tome"));
		Util.logger.info("Item Renders Registered");
	}
}

 

 

Edited by GooberGunter
Link to comment
Share on other sites

...

The second parameter is the variant of which you want to use... Unless otherwise specified in the BlockState file, there is only "inventory" for items, but blocks also have "normal" (placed)...

The Item's RegistryName (which comes from getRegistryName()) should already equal "ds:old_tome", IF you used setRegistryName("old_tome") in the item's constructor... You don't need to worry about that...
On a tangent however, modid's are recommended to never be shortened or otherwise altered from the original "name". I don't know what "ds" stands for, but for example, what if I made a mod called "Deep Storage" and also used "ds" as my modid? The longer a modid is, the probability of another mod having the same name exponentially becomes smaller.

 

You also need to actually have this code RUN during the ModelRegistryEvent...

You can do this very simply by annotating your client-proxy with @Mod.EventBusSubscriber and moving your registerItemRenderer method to said client-proxy. Your registerItemRenderer() also needs to become registerItemRenderer(ModelRegistryEvent event), so that the method can be picked up by the scanner, and called when the ModelRegistryEvent is fired, which then will run the code.

Edited by Matryoshika

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Link to comment
Share on other sites

Thanks a lot for the tips. Man, it seems like everything was replaced with annotations

 

So to be clear, the render register no longer goes in the init? What are the initialization methods for?

 

Now I'm getting a file not found exception, I've been waiting for one. I have a lead.

 

Edit: classic blockstate, I fixed the chain and now I have the item model json, the blockstate json, and the texture. Everything works fine now

 

 

Do recipes, world generators, and entities still initialize the same or are they events too?

Edited by GooberGunter
Link to comment
Share on other sites

2 hours ago, GooberGunter said:

Do recipes, world generators, and entities still initialize the same or are they events too?

 

Recipes and entities are managed by registries, so register them in RegistryEvent.Register<IRecipe> and RegistryEvent.Register<EntityEntry> respectively. Use EntityEntryBuilder to create the EntityEntry.

 

World Generators aren't managed by a registry and there's no dedicated event to register them, so do it in preInit/init/postInit.

  • Like 1

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.