Solved Detect right click villager?

Discussion in 'Plugin Development' started by ArthurHoeke, Jan 16, 2014.

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

    ArthurHoeke

    Hello
    How to detect if a player right clicks on a villager?

    Thanks
     
  2. Offline

    ArthurHoeke

    Assist How to make it special for a villager?
     
  3. Offline

    lycano

    Code:java
    1.  
    2. @EventHandler
    3. public void onPlayerInteractEntityEvent(PlayerInteractEntityEvent event) {
    4. Entity entity = event.getRightClicked();
    5. if (!(entity instanceof NPC))
    6. return;
    7.  
    8. // do stuff
    9. }
    10.  


    Whenever the check fails "entity is not instanceof NPC" it will process the code and do stuff.
     
  4. Offline

    Garris0n

    instanceof Villager
     
  5. Offline

    ArthurHoeke

    Thanks! works!
     
  6. ArthurHoeke
    Check if the entity is an instance of Villager with the instanceof keyword.

    Edit: Oops, too late.
     
Thread Status:
Not open for further replies.

Share This Page