Check if block is within 2 locations.

Discussion in 'Plugin Development' started by iPhysX, Jan 17, 2012.

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

    iPhysX

    Code:java
    1.  
    2. protected final Location pos1 = new Location(Bukkit.getServer().getWorld("world"), 384.0, 0.0, 442.0);
    3. protected final Location pos2 = new Location(Bukkit.getServer().getWorld("world"), 628.0, 127.0, 681.0);
    4.  


    How would i check if a block broken is between these points?
    THANKS!
     
  2. Offline

    bergerkiller

  3. Offline

    iPhysX

  4. Offline

    Father Of Time

    like, literally between or just somewhere that resides in between those two points (can be above, but just located between).

    If you want a literal between then I would do the following:
    1) get point a
    2) get point b
    4) get distance from point A to point B
    3) get direction from point a to point b
    4) convert direction to vector
    5) use a block iterator to get the blocks in the vector direction from above in the distance from above.
    6) iterate through the blocks in the block iterator to see if any are the block broken.

    again, this method will give you a literal straight line between point A and point B, and only return the blocks on that path; the method suggested by burgerkiller will return every block in the general area, from the highest to lowest point, from the farthest to nearest point.

    I would imagine you need burgers method more, but I figured I would throw this out as well just in case.

    Good luck with your project!
     
    iPhysX likes this.
Thread Status:
Not open for further replies.

Share This Page