Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

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?

 

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

Edited by Paradoxical

  • Author

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

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;

}

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.

  • Author

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. 

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. 

Did Khal's or my filter work?

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.

 

 

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.