Jump to content

Recommended Posts

Posted (edited)

I decided to add a few more tabs to keep organized, but now if I go to the second tab page I crash.

Spoiler

java.lang.NullPointerException: Rendering screen
	at net.minecraft.client.renderer.RenderItem.renderItemOverlayIntoGUI(RenderItem.java:429)
	at net.minecraft.client.renderer.RenderItem.renderItemOverlays(RenderItem.java:399)
	at net.minecraft.client.gui.inventory.GuiContainerCreative.drawTab(GuiContainerCreative.java:925)
	at net.minecraft.client.gui.inventory.GuiContainerCreative.drawGuiContainerBackgroundLayer(GuiContainerCreative.java:749)
	at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:94)
	at net.minecraft.client.renderer.InventoryEffectRenderer.drawScreen(InventoryEffectRenderer.java:59)
	at net.minecraft.client.gui.inventory.GuiContainerCreative.drawScreen(GuiContainerCreative.java:634)
	at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:382)
	at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1147)
	at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1139)
	at net.minecraft.client.Minecraft.run(Minecraft.java:406)
	at net.minecraft.client.main.Main.main(Main.java:118)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
	at GradleStart.main(GradleStart.java:26)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Client thread
Stacktrace:
	at net.minecraft.client.renderer.RenderItem.renderItemOverlayIntoGUI(RenderItem.java:429)
	at net.minecraft.client.renderer.RenderItem.renderItemOverlays(RenderItem.java:399)
	at net.minecraft.client.gui.inventory.GuiContainerCreative.drawTab(GuiContainerCreative.java:925)
	at net.minecraft.client.gui.inventory.GuiContainerCreative.drawGuiContainerBackgroundLayer(GuiContainerCreative.java:749)
	at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:94)
	at net.minecraft.client.renderer.InventoryEffectRenderer.drawScreen(InventoryEffectRenderer.java:59)
	at net.minecraft.client.gui.inventory.GuiContainerCreative.drawScreen(GuiContainerCreative.java:634)
	at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:382)

 

The Tab class is as follows

Spoiler


package keegan.labstuff.common;


import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.*;

public class TabLabStuff extends CreativeTabs {

	
	private Item tab;
	private String name;
	
	public TabLabStuff(String label, Item tab, String name) {
		super(label);
		this.tab = tab;
		this.name = name;
		// TODO Auto-generated constructor stub
	}
	
	@Override
	public Item getTabIconItem()
	{
		
		return tab;
	}
	
	@Override
	public ItemStack getIconItemStack()
	{
		return new ItemStack(tab);
	}
	
	@Override
	public String getTranslatedTabLabel()
	{
		
		return name;
		
	}
}

 

 

And the items are not null I can spawn them in and toss them around and all that jazz so IDK

 

 

Edited by KeeganDeathman

[shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]

Posted
38 minutes ago, KeeganDeathman said:

And the items are not null I can spawn them in and toss them around and all that jazz so IDK

Just because they're not null when you open up a save game and toss them around doesn't mean they aren't null when you initialize your creative tab.

 

Item myItem;
Tab myTab;

preInit() {
	myTab = new Tab(myItem);
	myItem = new Item();
}

In the above (heavily simplified) code, myTab is initialized with a null item.  Why because it hasn't been created yet even though the item itself exists later and you can pick it up and toss it, the tab's item is still null.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Line 429 of RenderItem is the following:

 if (stack.getItem().showDurabilityBar(stack))

 

The only value that can be null on that line is the return of ItemStack#getItem, which means an ItemStack with a null Item is being rendered.

 

The method is being called from GuiContainerCreative#drawTab, which draws the tab's icon ItemStack into the GUI. This means that the ItemStack with the null Item is the one you're returning from CreativeTabs#getIconItemStack.

 

Creative tabs need to be initialised before items, so you can't pass an Item to a CreativeTabs constructor. Instead, override CreativeTabs#getTabIconItem or CreativeTabs#getIconItemStack (there's no need to override both) to get the Item from the the field it's being stored in (e.g. in your ModItems class).

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.

Posted
2 minutes ago, Choonster said:

Line 429 of RenderItem is the following:


 if (stack.getItem().showDurabilityBar(stack))

 

The only value that can be null on that line is the return of ItemStack#getItem, which means an ItemStack with a null Item is being rendered.

 

The method is being called from GuiContainerCreative#drawTab, which draws the tab's icon ItemStack into the GUI. This means that the ItemStack with the null Item is the one you're returning from CreativeTabs#getIconItemStack.

 

Creative tabs need to be initialised before items, so you can't pass an Item to a CreativeTabs constructor. Instead, override CreativeTabs#getTabIconItem or CreativeTabs#getIconItemStack (there's no need to override both) to get the Item from the the field it's being stored in (e.g. in your ModItems class).

 

That's probably why my old one worked fine, it returned directly not from a value

[shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]

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.