Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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

 

  • Author

How do I trace through with the debugger? Not so great with Eclipse.  :-\

Kain

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.