Jump to content

Recommended Posts

Posted

Hey everyone, i have a NullPointerException problem, i know what it is an all since i experienced java for 4 years,

though, i have no idea how to avoid it since i rarely had this problem,

im trying to check the item held by the player in a tick event.

 

This is the main file:

 

  Reveal hidden contents

 

 

This is the event:

 

  Reveal hidden contents

 

Posted

Either this is being called before the player actually spawns, or the players held item is null.

 

 

Also, why aren't you using the onUpdate method in your custom item class? It gets called whenever the item is in the players inventory which means you could do your check from there.

We all stuff up sometimes... But I seem to be at the bottom of that pot.

Posted

And from your "60% worthless" post right there I assume you just copy/pasted the exact same code you had in the event handler. So of course its not going to work. As diesieben07 kindly told you:

  Quote

a) This won't work, you can't add PotionEffects on the client.

 

So you need to use the parameters given in the method, but first surround it all with a check to see if the world is server side world.

We all stuff up sometimes... But I seem to be at the bottom of that pot.

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.