Jump to content

Accurate Region Checking


jca

Recommended Posts

Haven’t found a clean solution to check what region my player is in. 

At the moment using getMap().getBaseX() and getMap().getBaseY() but this varies slightly depending on how my player accessed the position in the region.

With a rough calc I’m able to work it out, but as I said it’s a bit dirty. Are there any cleaner solutions? 

Edited by jca
Link to comment
Share on other sites

6 minutes ago, Eliot said:

Why not just use areas?

 


if (area.contains(myPlayer()) {
     ...
}

 

Yeah... well that’s one option. 

The area I need to check is huge (the size of the region, basically 104x104). My logic is if it’s already defined as a region and I could check that then it makes more sense then defining a massive area. 

But if there’s not really a better way then areas will have to do. 

Link to comment
Share on other sites

5 minutes ago, jca said:

Yeah... well that’s one option. 

The area I need to check is huge (the size of the region, basically 104x104). My logic is if it’s already defined as a region and I could check that then it makes more sense then defining a massive area. 

But if there’s not really a better way then areas will have to do. 

You don't need to define the area. Since it's big just get the bottom left and top right coordinates and that's all you need to check and see if you're within an area.

Link to comment
Share on other sites

3 minutes ago, dreameo said:

You don't need to define the area. Since it's big just get the bottom left and top right coordinates and that's all you need to check and see if you're within an area.

That’s still defining an area... it’s not an issue. Just if there was an option with regions it feels better to use. But maybe it’s not possible. 

Link to comment
Share on other sites

1 minute ago, jca said:

That’s still defining an area... it’s not an issue. Just if there was an option with regions it feels better to use. But maybe it’s not possible. 

You made it sound like it's an issue when you said the area is large. Which I said, you don't need to actually define an area.. you just need 2 coordinates.

You're doing the same with with a region that you would with an area. Idk why you're hard stuck on regions.

Link to comment
Share on other sites

6 minutes ago, dreameo said:

You made it sound like it's an issue when you said the area is large. Which I said, you don't need to actually define an area.. you just need 2 coordinates.

You're doing the same with with a region that you would with an area. Idk why you're hard stuck on regions.

Ah I’m not really, I just wondered if there was a way. Again, theoretically dealing with a large area feels like it should be handled by region checking. 

But I can stick with areas, thanks for your thoughts and @Eliot

Edited by jca
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...