Posted September 20, 201312 yr 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
September 21, 201312 yr 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
September 21, 201312 yr Author How do I trace through with the debugger? Not so great with Eclipse. Kain
September 21, 201312 yr 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
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.