Jump to content

Accurate Region Checking


Recommended Posts

Posted (edited)

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
Posted
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. 

Posted
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.

Posted
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. 

Posted
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.

Posted (edited)
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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