Jump to content

Recommended Posts

Posted

I'm trying to make my machine fill buckets if you put them in a certain slot, so I want to check that there is a bucket in the slot, however my if statement crashes with a null pointer exception when I load into the game with my current method.

 

 

It crashes on this line on what I assume is the first check.

if(slotBucketOut.getItem() == Items.bucket && (this.distilledWater - 1000) >= 0)

 

Here is all of my code in that class:

 

  Reveal hidden contents

 

 

If anyone can help I'd greatly appreciate it, thanks.

I have no idea what I'm doing.

Posted
  On 11/9/2014 at 7:22 PM, diesieben07 said:

The ItemStack will be

null

if the slot is empty. You need to check for that, as you can't call methods on references that are

null

.

 

Ok, would that just be

if(slotBucketOut != null)

I have no idea what I'm doing.

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.