Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello Guys!

 

I'm creating a special Item, which should have a shooting function if you right klick it and a healing function if you left klick it.

 

Right Klick short: Shoot

Right Klick long: Aim and shoot

Left klick: Heal

 

The function should be created in a way that you don't have to select a Block or an Entity before klicking, just klick anywhere.

 

Any Ideas??

I'm not sure what you mean by click it.

Do you mean having it in the hand and then clicking?

If you guys dont get it.. then well ya.. try harder...

  • Author

I'm not sure what you mean by click it.

Do you mean having it in the hand and then clicking?

Yes, exactly.

You hold the Item and perform a klick, either with the left mouse-button or with the right one. And both clicks should lead to a single method. But I could only find methods for the event of klicking at a Block... You should be able to klick right into the air, like wit a bow, but also with the left mouse button.

 

(Hope, everybody understands)

 

There are many functions of the Item which you can look into.

 

If you look into the Item.java class of the minecraft project you will see many methods, look into them and you will find several interesting ones like onItemUse and so on.

 

If you press Ctrl+Shift+T inside eclipse and type Item you should be able to find the main Item class rather quickly ;)

If you guys dont get it.. then well ya.. try harder...

@ForgeSubscribe
public void playerInteractEvent(PlayerInteractEvent evt) 

it might help to you.

Hi

 

The code for handling left & right mouse clicks is in Minecraft.tick() --> Minecraft.clickMouse(int button)

 

A left click goes to EntityLivingBase.swingItem --> item.onEntitySwing(), so you can probably intercept it here, however the code continues on to do all sorts of other left-click things and you might have trouble stopping it - perhaps overwriting Minecraft.objectMouseOver might do the trick.  Depends what you want to do exactly.

 

-TGG

 

 

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.