Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Resolved Getting an Array of GameObjects

Joined
Jul 8, 2016
Messages
1
Sorry i'm pretty new to Java and i'm working on my first bot if someone could explain to me how i could get an array of nearby GameObjects so i can possibly sort them by how close they are and the by the GameObjects animation ID that would be awesome! :D
 
( ͡° ͜ʖ ͡°)
Joined
Mar 30, 2015
Messages
2,416
Sorry i'm pretty new to Java and i'm working on my first bot if someone could explain to me how i could get an array of nearby GameObjects so i can possibly sort them by how close they are and the by the GameObjects animation ID that would be awesome! :D

in probably the simplest form:

GameObject[] array = GameObjects.getLoaded().toArray();

There are also methods in each of the interactable classes so you don't really have to sort them yourself. Check out the jdocs.
 
Last edited:
Client Developer
Joined
Oct 12, 2015
Messages
3,769
in probably the simplest form:

GameObject[] array = GameObjects.getLoaded().toArray();

Code:
GameObjects.newQuery().filter(new Predicate(){
      private boolean test(GameObject o){
            return o.getAnimationId() == your animation id;
      }
}).results().sortByDistance();
 
Joined
Sep 30, 2015
Messages
86
You can also use LocatableEntityQueryResults

Code:
LocatableEntityQueryResults results = GameObjects.newQuery().results();
 
Top