Line of Blocks between two Locations

Discussion in 'Plugin Development' started by iAlltonHD, Mar 2, 2015.

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

    iAlltonHD

    I do not want to generate a cuboid, but a diagonal line of blocks or "line of sight", between 2 points. The blocks should consist of all the blocks that a line from location A to B would intersect. This can be achieved between a player and there target location with player.getLineOfSight, but I want to do this with two defined locations.
    A method to take in the 2 locations as parameters and return a list of blocks would be greatly appreciated.
     
  2. Offline

    NathanWolf

    BlockIterator is what you want.

    I'd link to javadocs, but I guess the official ones are down and I'm unsure what the policy is on linking to JDs hosted by "other implementations".
     
  3. Offline

    artish1

    @iAlltonHD
    I'd use vectors.
    Just get the vector of the first block then the vector of the other block (Or location). Then subtract from eachother and normalize so that it will have a vector that goes from 1 block to the other. Then create a new location of the first location, and add the vector (Location ofcourse) to the current location that you are using to travel, loop, and u'll get all the locations eventually. or blocks.
     
  4. Offline

    1Rogue

    SpookyIterator
     
    NathanWolf likes this.
Thread Status:
Not open for further replies.

Share This Page