Jump to content

Recommended Posts

Posted

Hello, I would like to know where in the code of the minecraft is that when you use an item so I can override to use in a custom item, I was looking on the treatment of user input of the game http://greyminecraftcoder.blogspot.com.au/2013/10/user-input.html, however is not quite exactly what I want to do (I do not want to detect when the user clicks the right mouse button but when it activates an item, because that must be considered configuration command 'use item' can be changed to another type of input type a key keyboard).

Appreciate everyone's attention for any clarification.

Posted

Hi

 

Although the Minecraft.clickMouse(button) says "left and right buttons", exactly the same code is called for keyboard keys which have been mapped to the attack or use actions.  In fact, if the right mouse button is clicked, it is converted to a "keyboard press" as the very first thing.

 

For "eating" an item (or blocking a sword or similar) you might be interested in PlayerControllerMP.sendUseItem and Item.useItemRightClick

 

For right clicks on blocks

ForgeEventFactory.onPlayerInteract(RIGHT_CLICK_BLOCK)

or

Item.onItemFirstUse

or

Item.tryPlaceItemIntoWorld

 

For right clicks on air

ForgeEventFactory.onPlayerInteract(RIGHT_CLICK_AIR)

 

You can see all these options and how they are called from Minecraft.clickMouse.

 

-TGG

Posted

I was confusing a class that believed it was represented that the items in the game, such net.minecraft.entity.item.Entityitem, had not noticed that there is a class net.minecraft.item.Item.

Noting she noticed the existence of the method Item.onItemUse (), I believe that is exactly what I was looking for, I will perform some tests to find out if I can use it for what I plan.

ty for replys = b

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.