dmmslaver Posted October 4, 2016 Share Posted October 4, 2016 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? Quote Link to comment Share on other sites More sharing options...
Salty as fuck Posted October 5, 2016 Share Posted October 5, 2016 (edited) 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. Edited October 5, 2016 by Paradoxical 1 Quote Link to comment Share on other sites More sharing options...
dmmslaver Posted October 5, 2016 Author Share Posted October 5, 2016 (edited) 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. 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 October 5, 2016 by dmm_slaver Quote Link to comment Share on other sites More sharing options...
Team Cape Posted October 5, 2016 Share Posted October 5, 2016 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; } Quote Link to comment Share on other sites More sharing options...
Khaleesi Posted October 5, 2016 Share Posted October 5, 2016 Why not use a filter? public RS2Object getObject(Position pos, String name) { return getObjects().closest(new Filter<RS2Object>() { @[member='Override'] public boolean match(RS2Object o) { return o != null && o.getName().equals(name)) && o.getPosition().equals(pos); } }); } 1 Quote Link to comment Share on other sites More sharing options...
Salty as fuck Posted October 5, 2016 Share Posted October 5, 2016 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. Quote Link to comment Share on other sites More sharing options...
dmmslaver Posted October 5, 2016 Author Share Posted October 5, 2016 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. Quote Link to comment Share on other sites More sharing options...
Salty as fuck Posted October 5, 2016 Share Posted October 5, 2016 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? Quote Link to comment Share on other sites More sharing options...
Token Posted October 5, 2016 Share Posted October 5, 2016 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. Quote Link to comment Share on other sites More sharing options...