How to differ between PlayerInteractEvent and PlayerInteractEntityEvent?

Discussion in 'Plugin Development' started by blablubbabc, Dec 21, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    blablubbabc

    Hey,
    my problem is, whenever my PlayerInteractEntityEvent is called, I also receive it as PlayerInteractEvent..

    I want to be able to differ between, so when a player right clicks air and not an entity, something happens.
    And when the player right clisks an entity, something else happens.

    Right now, if I click an entity, both events a fired and both things happen.. :(

    What would be the best and easiest way to accomplish this ?

    Thanks,
    bla
     
  2. Offline

    Hoolean

    Code:java
    1. @EventHandler
    2. public void onBleh(PlayerInteractEvent event) {
    3.  
    4. if(event instanceof PlayerInteractEntityEvent) {
    5.  
    6. //me thinks this will mean that it is an entity one :D
    7.  
    8. }
    9.  
    10. }
     
  3. Offline

    nisovin

    MrBluebear3 PlayerInteractEntityEvent does not extend PlayerInteractEvent, so that won't work.

    You're confusing interact events with damage events.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  4. Offline

    Hoolean

    I had too many tabs open :p
     
    gomeow likes this.
  5. Offline

    blablubbabc

    soo ? no ideas ? :(
     
  6. Offline

    fireblast709

    Not really -_-... You could try scheduling your interact events 1 tick later, and try to have a way to match events
     
Thread Status:
Not open for further replies.

Share This Page