How to cancel a villager trade event

Discussion in 'Plugin Development' started by john2342, Jul 26, 2014.

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

    john2342

    If I want to open an inventory when you right click a villager, how do I do it? The normal villager trade GUI interferes, I'm sure this works because I tested the inventory with a command an it works, but I just need to know how to cancel the villager trade gui.
     
  2. Offline

    Niknea

    john2342
    PHP:
    @EventHandler //Needed for every event
    public void onClick(PlayerInteractEntityEvent e){//Event to check if a player clicked a villager
    if(e.getRightedClick().getType() == EntityType.VILLAGER){ //Checks if the entity clicked was an villager
      
    e.setCancelled(true); //cancel the event (so the villager GUI won't pop up)
      //Open your inventory GUI.
    }
    }
     
    john2342 likes this.
Thread Status:
Not open for further replies.

Share This Page