Jump to content

Recommended Posts

Posted (edited)

So, I don't know why this happens, and not sure if I even touch anything like to "break it" but my items and blocks aren't rendering anymore, and I can't find anything on the logs as to what the problem could be.

 

On my main class I have on preInit

		//INIT ITEMS
    	ModItems.init();   	

		//INIT BLOCKS
    	ModBlocks.init();

ModItems looks like this:

public class ModItems {
	
	//CREATE THE ITEMS
	public static final ModItem CLOVER = new Clover("clover");
	
	public static void init() {
		
		registerItem(CLOVER);

	}
	
	//This gets called on ClientPoxy
	public static void registerRenders() {
		
		registerRender(CLOVER);
		
	}
	
	
	private static void registerItem(Item item){
		GameRegistry.register(item);
	}

	public static void registerRender(Item item) {
    	ModelResourceLocation modelLocation = new ModelResourceLocation(item.getRegistryName(), "inventory");
    	ModelLoader.setCustomModelResourceLocation(item, 0,  modelLocation);
	}
}

ClientProxy is called on init and looks like this:

public class ClientProxy extends CommonProxy
{
	
	@Override
	public void registerRender()
	{
		//Register Renders on Client Side Only
		ModItems.registerRenders();
		ModBlocks.registerRenders();		
		
		RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();
                
        renderManager.entityRenderMap.put(MyDragon.class, new RenderMyDragon(renderManager));
        
	}
	


}

 

The item clover.json is: (Located at: assets.irishluck.models.item and the clover.png at assets.irishluck.textures.items)

 

{
    "parent": "item/generated",
    "textures": {
        "layer0": "irishluck:items/clover"
    }
}

 

Not sure what's going on here. In the meanwhile I'm gonna rebuild my workspace and let you guys know.

 

Any ideas?

 

Thanks a lot.

 

PS: My latest log https://pastebin.com/yCL7AqHH

Edited by American2050
Posted (edited)

Your render registration must be done in pre-init for entities. For items/blocks use ModelRegistryEvent.

Registering items/blocks must be done in RegistryEvent.Register that is appropriate for the object(RegistryEvent.Register<Block> for blocks, RegistryEvent.Register<Item> for items/etc). Even if you are not yet using new versions of forge you should still use event registration system so you will not have to rewrite all your code when you do decide to update.

At the very least you should register your models and renderers using pre-init, not init, if you refuse to use the ModelRegistryEvent for one reson or another.

16 minutes ago, American2050 said:

RenderManager renderManager = Minecraft.getMinecraft().getRenderManager(); renderManager.entityRenderMap.put(MyDragon.class, new RenderMyDragon(renderManager));

Why are you using RenderManager directly? You should use RenderingRegistry::registerEntityRenderingHandler(Class, IRenderFactory).

 

 

16 minutes ago, American2050 said:

public class ModItems

 

16 minutes ago, American2050 said:

public static void registerRender(Item item)

Client-side only code can't be located in common classes or you will crash the server. It must either be located in your client proxy or in a class that you know for sure will not get loaded on server.

Edited by V0idWa1k3r
  • Like 1
Posted (edited)

As why am I using RenderManager directly, the answer I guess it's because it always worked for me, for a long time with no issues at all :P Sorry I don't have a better reason.

 

As for the code that is called Client-Side, again I always had it like that without any issues, even using this mod on servers. So not sure if it's just a bad practice coming from me, or something that just works, and that's why I have it like that.

 

I guess I should move the rendering to it's own class? And call those from Client Proxy?

 

I will give the RegistryEvent.Register<Item>  a try and see how it goes. Again, I was calling the render on init because I believe that was suggested to me time ago, where if I called my rendering on pre-init it just wouldn't work.

 

I just updated to the newest Forge, and I believe I did some update time ago, so probably that was what broke my renderings.

 

Thanks a lot for your help.

Edited by American2050

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.