Jump to content

Recommended Posts

Posted

So before I changed this method and to the latest version of forge, this was working, but not I am having a ton of repetitive crashes and I have NO idea what is causing them, I get a NullPointerException even when the items are not null.

 

This is the crash:

 

  Reveal hidden contents

 

 

These are the methods:

 

  Reveal hidden contents

 

Posted

TextureAtlasSprite textureAtlasSprite = mc.getTextureMapBlocks().getAtlasSprite(ibakedmodel.getTexture().getIconName()); // This is where the crash points to

Whenever you get a NULL pointer exception, the first thing you should do is put a break point on that line and fire up the debugger.

 

If you are not comfortable doing that, then you can still quickly debug it by putting everything on its own line:

TextureAtlasSprite textureAtlasSprite = mc
    .getTextureMapBlocks()
    .getAtlasSprite(ibakedmodel
        .getTexture()
        .getIconName()
    );

Now when you run your code again, you will find out EXACTLY which of those is null.

Posted
  On 6/24/2015 at 2:24 AM, Jedispencer21 said:

So I did that and it appears to go null on the .getIconName() method

So... you can fix it now, right, since you know what is null?

 

Specifically: "Calling the instance method of a null object."

 

i.e. You cannot call a class method if you do not have an object of that class. You are trying to call getIconName() on a NULL object.

Posted
  On 6/24/2015 at 4:22 AM, Jedispencer21 said:

Well I would assume I am handling it being null because

if (stack == null) continue;
and
if (this.mc.thePlayer.inventory.getCurrentItem() != null)

should handle it, correct?

Is that the line that your crash log pointed to when it gave you the NPE? No, it isn't, i.e. this is not where the problem is.

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.