Jump to content

Opening a custom GUI?


TLHPoE

Recommended Posts

I'm currently trying to make my GUI open when the player opens their inventory. I crash when I open my inventory, and throws a NPE on line 23 (the line where I use the openGUI method). The part that seems very sketchy to me, is the last 3 ints in the method. I have no clue what they're for.

 

package tlhpoe.rpgadditions.handlers;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.client.event.GuiOpenEvent;
import net.minecraftforge.event.EventPriority;
import net.minecraftforge.event.ForgeSubscribe;
import tlhpoe.rpgadditions.RPGAdditions;

public class GuiEventHandler
{

@ForgeSubscribe(priority = EventPriority.NORMAL)
public void onRenderInventory(GuiOpenEvent event)
{

	if(event.gui instanceof GuiInventory)
	{

		EntityPlayer player = Minecraft.getMinecraft().thePlayer;

		player.openGui(RPGAdditions.instance, 0, player.worldObj, (int)player.posX, (int)player.posY, (int)player.posZ);

	}

}

}

Kain

Link to comment
Share on other sites

Hi

 

So which variable is NULL? (when you trace through with the debugger, you should be able to tell which object is NULL before it gets a method invoked on it?)

 

I'm pretty sure the x,y,z is just there so that your GUI knows where the player is in the world, in case your code needs to know.  I'm also pretty sure it's not the cause of your problem.

 

-TGG

 

Link to comment
Share on other sites

Sorry I can't help you there, I use IntelliJ.

 

But I'm sure there are some good docs on the web, this one looks promising for example:

http://www.vogella.com/articles/EclipseDebugging/article.html

 

Once you've learnt how to set breakpoints, inspect variables, and step through your code one line at a time, your programming life will be so much easier, trust me :-)

 

-  TGG

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.



×
×
  • Create New...

Important Information

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