Solved Player rights click water

Discussion in 'Plugin Development' started by MrFrozen, Sep 28, 2015.

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

    MrFrozen

    Hey Bukkit,

    I found this code:
    Code:
    if (e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_AIR) {
                  List<Block> los = e.getPlayer().getLineOfSight(null, 5);
                  for (Block b : los) {
                    if (b.getType() == Material.STATIONARY_WATER) {
                      System.out.println("statioanry water");
                      break;
                    }
                  }
                }
    For checking if the players right clicks water, because I wanna check when the players fills a empty bottle with water. But I cannot figure out how to so I searched a code for rightclicking water but if I use this I get a error 'The method getLineOfSight(HashSet<Byte>, int) is ambiguous for the type Player'

    Please can some1 help me out?
     
  2. Offline

    RoboticPlayer

    It may be a part of the PlayerInteractEvent.
     
  3. Offline

    Zombie_Striker

    I thought it was ".getTargetBlock(null,distance)"
     
    Gonmarte likes this.
  4. Offline

    Gonmarte

    @MrFrozen use the method getTargetBlock(); i think its decreapted but you can still use it because decrepeted just mean to avoid it =)
     
  5. @MrFrozen
    Instead of putting null as the first argument, use (HashSet<Material>) null. There's something in the bukkit API that has chosen this to happen, if you change that you will get a deprecated sign, but you can ignore that.

    @Zombie_Striker @Gonmarte
    getLineOfSight returns a whole row of blocks, while getTargetBlock returns only the first block in the sight, I think getLineOfSight would be better here
     
Thread Status:
Not open for further replies.

Share This Page