dungeonqueer Posted September 28, 2017 Posted September 28, 2017 I'm attempting to find all Objects on my cursor that fall under a specific set of attributes. getMouse().getEntitiesOnCursor().stream().filter(obj -> obj.exists() && obj.hasAction("Chop")).forEach(setup::manage); However, getObjects().closest(trees); only accepts an RS2Object an not an Entity which is given by getMouse().getEntitiesOnCursor() How would I go about finding the closest Entity that I've found through using #getEntitiesOnCursor()? Could I check for it to be an instanceof RS2Object and cast it as such?
liverare Posted September 28, 2017 Posted September 28, 2017 List<RS2Object> objectsUnderCursor = getMouse().getEntitiesOnCursor() .stream() .filter(RS2Object.class::isInstance) .map(RS2Object.class::cast) .collect(Collectors.toList()); Try that.
Explv Posted September 28, 2017 Posted September 28, 2017 (edited) 10 minutes ago, dungeonqueer said: I'm attempting to find all Objects on my cursor that fall under a specific set of attributes. getMouse().getEntitiesOnCursor().stream().filter(obj -> obj.exists() && obj.hasAction("Chop")).forEach(setup::manage); However, getObjects().closest(trees); only accepts an RS2Object an not an Entity which is given by getMouse().getEntitiesOnCursor() How would I go about finding the closest Entity that I've found through using #getEntitiesOnCursor()? Could I check for it to be an instanceof RS2Object and cast it as such? Pretty sure you can just filter objects using getObjects().closest() and the method isOnCursor() Sorry on phone but: getObjects().closest(obj -> obj.hasAction("Chop") && obj.isOnCursor()) Edited September 28, 2017 by Explv
dungeonqueer Posted September 28, 2017 Author Posted September 28, 2017 18 minutes ago, Explv said: Pretty sure you can just filter objects using getObjects().closest() and the method isOnCursor() Sorry on phone but: getObjects().closest(obj -> obj.hasAction("Chop") && obj.isOnCursor()) There is no #isOnCursor() method
Explv Posted September 28, 2017 Posted September 28, 2017 6 minutes ago, dungeonqueer said: There is no #isOnCursor() method Sorry I meant && getMouse().isOnCursor(obj)