Difference between right and left clicking

Hello I am just starting on the development of sponge plugins.
I am trying to do something on right clicking an entity, though I can’t figure out how to differ left from right clicking.
My code:

public void onRightClick(InteractEntityEvent event) {
    if (event.getCause().last(Player.class) != null) {
	    Player player = event.getCause().last(Player.class).get();
	    if (isSneaking(player)) {

private boolean isSneaking(Player player) {
	return player.get(Keys.IS_SNEAKING).orElse(false);

But if I punch an entity it still counts as an interaction, is there anyway to check if the interaction is made with right click only?


The event is SpongeAPI/InteractEntityEvent.java at e2a1f7efb43c8285c30d65946b3bb6b1c17836ca · SpongePowered/SpongeAPI · GitHub

Primary: Normally left click
Secondary: Normally right click

1 Like

Thank you, it works now!