Locations Problem

Discussion in 'Spigot Plugin Development' started by RonFarkash, May 25, 2015.

  1. This will explain everything:
    http://www.sketchtoy.com/65202578

    or in screenshots:
    Straight Example:
    [​IMG]
    The bedrock line is the center line.

    The lapis is secondary, Basically I want to get location of all of those blocks.

    Diagonal Example:
    [​IMG]
    Same for the diagonal one :).
     
  2. I'm kind of unsure on what you want this to do? Do you want it to auto build something like this?
     
    • Agree Agree x 1
  3. Kind of like a brush thing, so when you left click it draws the shown above, depends where you're looking.
     
  4. That should be no problem. Take the look vector of the player:

    Vector v = player.getLocation().getDirection();

    And get the Block at which he is looking:

    Block b = player.getTargetBlock(null, 70);

    Then calculate your other Blocks ;)
     
  5. I want to calculate the other ones, like from the sides too.
     
  6. Vector v = player.getLocation().getDirection();
    v.setY(0);
    Block b = player.getTargetBlock(null, 70);
    Block secondMidline = b.getLocation().add(0.5, 0.5, 0.5).add(v).getBlock();
    Vector diff = b.getLocation().substract(secondMidline);

    Now you even got the vector of the Block behind. Now use your math skills to get the other ones.
    For example the block 2 behind the one you are pointing at is:

    Block thirdMidline = b.getLocation().add(diff).getBlock();
     
  7. This seems like itll get me 1 line.

    My intention is this :
    If i am looking straight to one of the 4 main directions it will simply select a rectangle (I select the sizes), If I look a little off to the side or completly diagonally for example if i look north-east i want it to select a diagonal rectangles (Sizes i choose)

    So if I got the center line, I want it to clone center line to the right and left of it. All depends on the direction I look in.
     
  8. By diagonal I dont mean rectangle's diagonals. I mean when i face a diagonal direction (north-east, south-east, north-west, etc).
     
  9. Thats what I provided source for. Just think about how to get the left and right block next to the line and you got it :)
     
  10. That's my only problem, to actually get the left and right blocks.
     
  11. Could you explain me how the BlockIterator would get me the locations of the right and left blocks of the center line?
     
  12. You want five lines, each of those lines can be iterated through with that utility. All that remains is supplying the start-coordinates.
     

  13. Could you give me an example, I never used BlockIterator before.
     
  14. It implements Iterator<Block>, so you can use it like any other iterator (with hasNext() and next()).
     
  15. I mean getting the left and right lines. It cant just detect that I want 5 lines xD.
     
  16. You could calculate the cross product between straight down and the direction the main line goes and then go along the resulting vector to get starting points, couldn't you?
     
  17. I'm just a beginner, I got no idea what you are talking about xD. If you are trying to teach me I'll need some visual examples. If you want to solve this thread, A code example would fit exactly.
     
  18. I'm clearly not good at math, By any chance you could send me the code to it and end this thread?