Line of sight problems

Discussion in 'Plugin Development' started by willeb96, Mar 2, 2013.

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

    willeb96

    When I use player.getLineOfSight(null, 12) it returns the block the player is standing in and all blocks inbetween that block and the targetblock.
    I want all blocks. I don't want the line to stop at the targetblock, I want it to stop at the number I define (12).

    I would greatly appreciate any help I can get :)
     
  2. Offline

    Zettelkasten

    As the Bukkit API says:

    getLineOfSight

    List<Block> getLineOfSight(HashSet<Byte> transparent, int maxDistance)
    Gets all blocks along the player's line of sight List iterates from player's position to target inclusive

    Parameters:
    transparent - HashSet containing all transparent block IDs. If set to null only air is considered transparent.
    maxDistance - This is the maximum distance to scan. This may be further limited by the server, but never to less than 100 blocks.
    Returns:
    List containing all blocks along the player's line of sight
    Source: http://jd.bukkit.org/rb/apidocs/

    By default, the HashSet only contains AIR, so it will stop if something that isnt air is in the way. Set the HashSet, so that it will not stop when it hits something else.
     
  3. Offline

    microgeek

    You can use a BlockIterator with getLineOfSight to get the wanted result.
     
Thread Status:
Not open for further replies.

Share This Page