Jump to content

Objects.get(ln:138) ArrayIndexOutOfBoundsException: -156


dmmslaver

Recommended Posts

java.lang.ArrayIndexOutOfBoundsException: -156
at org.osbot.rs07.api.Objects.get(ln:138)
at ChefBot.onLoop(ChefBot.java:107)
at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(ao:83)
at java.lang.Thread.run(Unknown Source)

Offending line:
List<RS2Object> doorTile = objects.get(3242, 3212);

Am I doing something wrong or is this a bug?

 
Link to comment
Share on other sites

Why are you making a list for one tile?

Edit: okay, that's pretty weird. I never had to make a list for the position.. here's a quick mock-up. It worked for me. You always have to null check.

 

6zHSqpl.png

You didn't try my coordinates. I'm using the same code.. The list is the only way to get the object that that coords, there can be multiple objects per coordinate, up to 10.

Edited by dmm_slaver
Link to comment
Share on other sites

very strange... if you can't get this to work, maybe use something like this in the meantime:

 

List<RS2Object> getObjectsAt(int x, int y) {

      List<RS2Object> objects = new ArrayList<>();

      for(RS2Object o: objects.getAll()) {

            if(o != null && o.getPosition().getX() == x && o.getPosition().getY() == y) {

                  objects.add(o);

            }

      }

      return objects;

}

Link to comment
Share on other sites

You didn't try my coordinates. I'm using the same code.. The list is the only way to get the object that that coords, there can be multiple objects per coordinate, up to 10.

Well, I'm not exactly where you're at, so it's rather pointless to try your coords.

Also, post more of the script. One line doesn't really help us in helping you much.

 

Here's another filter if @@Khaleesi's didn't work out for you.

Entity doors = objects.getAll().stream().filter(n -> n.getName().equals("Door") && n.getX() == 1234 && n.getY() == 1234 && n.getModel().equals(1234)).findFirst().get();

You can put in x, y coords, add in model number if it's a different object, or you can remove that part and simply change the getname string.

Link to comment
Share on other sites

very strange... if you can't get this to work, maybe use something like this in the meantime:

 

List<RS2Object> getObjectsAt(int x, int y) {

      List<RS2Object> objects = new ArrayList<>();

      for(RS2Object o: objects.getAll()) {

            if(o != null && o.getPosition().getX() == x && o.getPosition().getY() == y) {

                  objects.add(o);

            }

      }

      return objects;

}

I tried that, and the door is NOT in the list. I am assuming because of the same error that is causing the exception i experienced. 

Link to comment
Share on other sites

According to the stacktrace the offending line is not in your code. If your code meets common sense standards such as following the API documentation on that method, what you encounter is an error in the API. The only error you can produce on your side with that code is by attempting to call it for a x-y pair which is not on the minimap. If this is not the case feel free to make a thread in the Client Bugs & Suggestions section.

 

 

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