InteractBlockEvent, Primary or Secondary?

Hi,

I have some diffilculties to understand how I can know if an interaction is primary or secondary. I tried multiple things like:

@Listener
public void onInteractPrimary(InteractBlockEvent.Primary event) {
	System.out.println("Primary interaction");
}

@Listener
public void onInteractSecondary(InteractBlockEvent.Secondary event) {
	System.out.println("Secondaryinteraction");
}

But it seems that these events are never fired…

@Listener
public void onInteract(InteractBlockEvent event) {
	if (event instanceof InteractBlockEvent.Primary)
	   System.out.println("Primary interaction");
	if (event instanceof InteractBlockEvent.Secondary)
	   System.out.println("Secondaryinteraction");
}

The event is fired but I can’t make the difference. I receive an InteractBlockEvent (and not something which inherits an InteractBlockEvent)

So… I’m probably wrong somewhere. Does someone know how I should do ?
Thanks

Events nested in another Event interface don’t fire the parent Event. Just themselves. Listen to both, have them call one method that shares code and accepts a boolean or whatever depending on its type.

Thanks for you help. So the first method given above should work and fetch the messages ? But as I said, nothing happens as if the events were not fired.

I wrote these methods in the main plugin’s class to be sure I’m not doing a mistake when I register these listeners.

It seems really basic and simple to use, but I don’t understand why it doesn’t work…

They may not be implemented yet. I can’t find it but there was a post on GitHub listing all events and whether they have been implemented yet or not. A lot of things have changed since then so I don’t know if it’s up to date, but I know it exists somewhere.

Thanks for you help. Indeed, it could be the answer to my question. I’ll try to find out this post. :smile:

I guess thats for 1.9 and its dualwielding.

No, Primary is the “primary-button” (left-click) and Secondary the “secondary-button” (right-click) code

1 Like