# Locations Problem

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

1. ### RonFarkash

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

or in screenshots:
Straight Example:

The bedrock line is the center line.

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

Diagonal Example:

Same for the diagonal one .

2. ### MnMaxon

I'm kind of unsure on what you want this to do? Do you want it to auto build something like this?

• Agree x 1
3. ### RonFarkash

Kind of like a brush thing, so when you left click it draws the shown above, depends where you're looking.

4. ### Friwi

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);

5. ### RonFarkash

I want to calculate the other ones, like from the sides too.

6. ### Friwi

Vector v = player.getLocation().getDirection();
v.setY(0);
Block b = player.getTargetBlock(null, 70);
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:

7. ### RonFarkash

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. ### RonFarkash

By diagonal I dont mean rectangle's diagonals. I mean when i face a diagonal direction (north-east, south-east, north-west, etc).

9. ### Friwi

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. ### RonFarkash

That's my only problem, to actually get the left and right blocks.

12. ### RonFarkash

Could you explain me how the BlockIterator would get me the locations of the right and left blocks of the center line?

13. ### dxdy

You want five lines, each of those lines can be iterated through with that utility. All that remains is supplying the start-coordinates.

14. ### RonFarkash

Could you give me an example, I never used BlockIterator before.

15. ### dxdy

It implements Iterator<Block>, so you can use it like any other iterator (with hasNext() and next()).

16. ### RonFarkash

I mean getting the left and right lines. It cant just detect that I want 5 lines xD.

17. ### dxdy

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?

18. ### RonFarkash

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.

20. ### RonFarkash

I'm clearly not good at math, By any chance you could send me the code to it and end this thread?