Jump to content

[1.8] Null Pointer Exception With Rendering Items


loawkise

Recommended Posts

I am trying to figure out the 1.8 item rendering thing but get a null pointer exception with this line:

 

Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(References.MODID + ":" + item.getUnlocalizedName().substring(5), "inventory"));

 

Mod class:

 

@Mod(name = References.NAME, modid = References.MODID, version = References.VERSION)
public class ExampleMod
{
    @SidedProxy(clientSide = "com.example.examplemod.ClientProxy", serverSide = "com.example.examplemod.CommonProxy")
    public static CommonProxy proxy;
    
    @Instance(References.MODID)
    public static ExampleMod modInstance;
    
    @EventHandler
    public void preInit(FMLPreInitializationEvent e)
    {
    	TutorialItems.init();
    	TutorialItems.register();
    }
    
    @EventHandler
    public void init(FMLPreInitializationEvent e)
    {
    	proxy.render();
    }
    
    @EventHandler
    public void postInit(FMLPreInitializationEvent e)
    {
    	
    }
}

 

Items class:

 

public class TutorialItems 
{
public static Item test_item;

public static void init()
{
	test_item = new Item().setUnlocalizedName("test_item");	
}

public static void register()
{
	GameRegistry.registerItem(test_item, test_item.getUnlocalizedName().substring(5));
}

public static void registerRenders()
{
	registerRender(test_item);
}

public static void registerRender(Item item)
{
	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(References.MODID + ":" + item.getUnlocalizedName().substring(5), "inventory"));
}
}

 

Client proxy:

 

public class ClientProxy extends CommonProxy 
{
@Override
public void render() 
{
	TutorialItems.registerRenders();
}
}

Link to comment
Share on other sites

That may have had an effect...

 

Now just having this issue when loading the game:

 

[18:39:02] [Client thread/ERROR] [FML]: Model definition for location example:test_item#inventory not found

 

The Json file should be under src/main/resources/assets/modid/models/item and the texture under src/main/resources/assets/modid/textures/items, right?

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.