Jump to content

Out of nowhere my items and blocks wont render anymore


American2050

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hello all! I'm currently trying to make the Biomes o' Plenty mod (1.12.2 version) compatible with my shaderpack (BSL v8.5). Even after I've already inserted a "shaders" folder with a correctly-formatted blocks.PROPERTIES file within the assets folder of the .jar, it still does not wave the textures from the mod. I definitely thought this was going to work since I noticed the 1.19.2 version of the mod laid it out exactly like that and it worked perfectly when my PC was able to run 1.19.2 Forge... ^^;;; Could there be some missing link I'm not getting at here?
    • After much experimentation I finally realised why this doesn't work and how to fix it. The critical component to understand here, is that ItemCraftedEvent is called before the crafting ingredients are purged from the crafting slots; this all happens in ResultSlot.java's onTake method: We can see here the first line fires checkTakeAchievements, this is what fires the ItemCraftedEvent (after a few method calls). Then we can see the purge behaviour. I worked around this by creating a CarverItem class, which uses hasCraftingRemainingItem and getCraftingRemainingItem to hook into ResultSlot.onTake: Now, I reconstruct my ItemCraftedEvent handler, and using some smart tags (which I omit for brevity), I handle two cases: 1. When crafting a carved item, I damage the tool used in the recipe 2. When crafting a carving tool from a repair recipe, I manually purge the input tools as with the new CarverItem class, as otherwise items would be duplicated   This has now greatly improved implementation, beyond my expectations, for the standard crafting table and the user's inventory crafting grid. A user can now click or shift-click 'carve' items, with no duplication or issues that I have spotted so far.  
    • Hi, I'm having issues launching my Forge 1.20.1 installation (47.2.0). I keep getting error code 1, and all the logs abruptly pause with the game attempting to open GL 4.6. Latest Crash: https://pastebin.com/zsP5Wipk Debug (No idea what the real name is) Log: https://pastebin.com/CzvqhNq0   Thanks for the help!
    • In the most up to date version of Allthemods 6 (v1.9.2) the stoned bee is not able to be interacted with apart from putting it into an empty bee jar. I can't breed the bee or put it into my aviary breeder. When I try to put it into the breeder it says import unsuccessful. The stoned bee is one of the most important bees for advancing in the mod so it is rather unfortunate that it is not working as intended.
    • Everytime I try to run the Forge 1.20.1 - 47.1.0 Installer, only appears an a black window and then closes. I don't appear the installing menu anymore.
  • Topics

×
×
  • Create New...

Important Information

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