TLHPoE Posted September 20, 2013 Posted September 20, 2013 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); } } } Quote Kain
TheGreyGhost Posted September 21, 2013 Posted September 21, 2013 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 Quote
TLHPoE Posted September 21, 2013 Author Posted September 21, 2013 How do I trace through with the debugger? Not so great with Eclipse. Quote Kain
TheGreyGhost Posted September 21, 2013 Posted September 21, 2013 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 Quote
Recommended Posts
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.