Jump to content

[1.7.10] Is this the more efficient way to call code when you left click?


Silly511

Recommended Posts

I have an item that I need to make it run code when you left-click a block with it. Currently I am subscribing to MouseInputEvent and sending a packet to the the server if you left-clicked. The server then checks if you have that item in your hand, and if so, runs the code. Is their a more efficient way of doing it so that I'm not sending a packet every time the player left-clicks?

Link to comment
Share on other sites

Left click is "item use" - there are methods for that in Item class.

 

Simply override method in your Item class and do code there. Such methods are fired on both sides - use proper logical checks (!world.isRemote).

 

Methods are something like onItemUse, idk for sure because stuff changed a lot in new versions - UPDATE.

1.7.10 is no longer supported by forge, you are on your own.

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.

Announcements



×
×
  • Create New...

Important Information

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