Jump to content

Question about EntityPlayer.getItemInUse() being Side.CLIENT


ShetiPhian

Recommended Posts

Is there a reason EntityPlayer.getItemInUse() is flagged @SideOnly(Side.CLIENT) ?

 

Removing @SideOnly(Side.CLIENT) doesn't appear to cause any problems (very limited testing)

Testing on both the built-in LAN server and stand alone dedicated server (through Eclipse) returned the correct item every time.

 

If it has to stay client side only, does anyone know of a server side equivalent?

Link to comment
Share on other sites

I'm checking if the item is a food, and stopping the player from eating.

 

 

EDIT:

Found a workaround  :)

 

Using PlayerInteractEvent, I check for right click events, get the current item, see if its a food, cancel the event accordingly.

It also solves the problem of the cake blocks avoiding my previous checks. stops the block from being used but players still get the food value.

Link to comment
Share on other sites

I was using the server side instance of the player (checking in LivingUpdateEvent)

but getItemInUse is locked to the client (even though unlocked it works on the server)

 

PlayerInteractEvent works better, it doesn't need getItemInUse and the check doesn't happen as often.

 

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

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