Posted July 15, 20169 yr 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?
July 15, 20169 yr 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.
July 15, 20169 yr Author Right-click is onItemUse. There are no methods in the item class for left clicking except onBlockStartBreak and onBlockDestroyed which are called after you break the block not before(Which is what I want).
July 15, 20169 yr Author Never mind I figured it out. I used PlayerInteractEvent and did it all on the server side. No packets needed.
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.