Solved Custom Right Click Functionality

Hycord

New member
Jun 13, 2022
2
0
1
How do I add custom right click functionality to an item? I've looked everywhere and can't find anything!
 
Version Output
This server is running Paper version git-Paper-8 (MC: 1.19) (Implementing API version 1.19-R0.1-SNAPSHOT) (Git: e4f5e1c)
You are running the latest version
Previous version: git-Paper-379 (MC: 1.18.2)

Noah

Paper Developer
Staff member
Jan 4, 2022
44
6
16
8
The Netherlands
You'll want to listen to the PlayerInteractEvent and check whether the action is RIGHT_CLICK_AIR or RIGHT_CLICK_BLOCK. Then, you'll have to identify whether the item clicked is your custom item. The easiest (and most reliable) way to store this typo of info on your item is probably in the PersistentDataContainer, see this resource for a quick tutorial.
 

Hycord

New member
Jun 13, 2022
2
0
1
You'll want to listen to the PlayerInteractEvent and check whether the action is RIGHT_CLICK_AIR or RIGHT_CLICK_BLOCK. Then, you'll have to identify whether the item clicked is your custom item. The easiest (and most reliable) way to store this typo of info on your item is probably in the PersistentDataContainer, see this resource for a quick tutorial.

Thanks!