Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

InteractItemEvent not fired #427

Open
Tran-Antoine opened this issue Apr 23, 2020 · 0 comments
Open

InteractItemEvent not fired #427

Tran-Antoine opened this issue Apr 23, 2020 · 0 comments

Comments

@Tran-Antoine
Copy link

I am currently running

  • SpongeVanilla version: 7.2.1, also tested with 7.1.8
  • Java version: 1.8
  • Operating System: Windows 10
  • Plugins: My testing plugin exclusively

Issue Description
This is a bug that can be consistently reproduced. The nature of the issue is simple: InteractItemEvent.Primary is not fired in some specific cases, though it should be.

From what I've understood from this, this event should be fired when a player left clicks with an item, without aiming at a block (meaning, aiming either at the air or at an entity). In case I'm targetting a block, then InteractBlockEvent.Primary will be fired instead. The item is of course held in my main hand. And to prevent InteractBlockEvent.Primary from being fired along with InteractItemEvent.Primary, I used the following code:

if(event.getTargetBlock().getState().getType() == BlockTypes.AIR) {
    // Meaning that InteractItemEvent.Primary is already being fired
    return;
}

So far so good. In most cases, the InteractItemEvent.Primary event works perfectly fine. However, there is an issue in a very specific case: when I'm interacting with an item and almost targetting a block, but still too far for actually reaching it (proof that I'm too far is: the black lines indicating which block I'm targetting don't appear). In this case, neither InteractItemEvent not InteractBlockEvent are fired. Here is a gif showing an example: particles are fired when the event is called. As you can see, I start by clicking on the grass, firing the InteractBlock.Primary event. Then, I aim at the sky, firing the InteractItemEvent.Primary. But eventually, when I aim at those grass blocks while being too far to reach them, nothing is fired.


I don't believe there is any need for including code samples, let me know if you disagree, I'll post my code.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant