Jump to content

Casting Entity to RS2Object


Recommended Posts

Posted

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?

Posted (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 by Explv

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...