npc-lib icon indicating copy to clipboard operation
npc-lib copied to clipboard

NPC Interact Event

Open arthurr0 opened this issue 2 years ago • 3 comments

Hi, is there any solution to nullify several times event popup at one click?

arthurr0 avatar May 30 '22 07:05 arthurr0

Can you provide more information? I do not understand the problem completely... 🤔

derklaro avatar May 30 '22 07:05 derklaro

if the player clicks on an NPC, the interact event executes 4 times.

arthurr0 avatar May 30 '22 20:05 arthurr0

If I remember correctly this happens due to the client sending interact packets for the main hand, off hand and maybe other things now I'm not quite sure. I've handled this issue with a debouncer before so that code only gets called once. Not sure if you've solved your issue @arthurr0 but hopefully that clarifies.

virustotalop avatar Jun 26 '22 12:06 virustotalop

On some entities the client will send both interact and interact_at so you will have to check for the action and the hand. grafik

SplotyCode avatar Feb 12 '23 18:02 SplotyCode

Note that v3 is already only calling this for INTERACT, so you only need to check if the interact action was made with the main hand to prevent double action. It might be an idea to only call the event if the action was performed with the main hand, although if somewhere in the future minecraft actually starts to differentiate between main and off hand, that could be a missing feature. So leaving the hand in will call the event twice, but simply checking for the hand will prevent any issues like this :)

derklaro avatar Feb 20 '23 10:02 derklaro