Jump to content

getObjects().closest() in larger area?


Recommended Posts

Posted
3 hours ago, elbojoloco said:

Hey, how do I get the closest to me from the getObjects().getAll() part?

getObjects().closest("Ore vein") 	

That will return the closest object with that name from all the objects in getObjects().getAll(), which returns all the objects in the loaded region. If you want to use getAll() use Java's stream API.

getObjects().getAll().stream().filter(obj -> obj.getName().equalsIgnoreCase("Ore vein")).findFirst().orElse(null); 

That will return the first object in the collection with the name "Ore vein". If you want to compare distance that you have to use .min() 

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