Jump to content

GroundItem Filter - If closest item doesn't contain string


Recommended Posts

Posted (edited)

Hey, I've fingered through the docs and I don't really grasp the concept of the Filter class, but I'm trying to achieve a goal

 

Essentially

GroundItem item = groundItems.closest(new AreaFilter<GroundItem>(getArea()) && !closestGroundItem.getName().contains("meat"))

is what I'm trying to accomplish, but I don't know how I would define the closestGroundItem before construction. I don't want my player stuck in a conditional statement that just leaves it hung because the closest item is meat, I want it to skip to the next closest item. How would I do this?

 

Edit: I've solved it myself, sorry.

Solution:

List<GroundItem> t = getGroundItems().getAll().stream().filter((n) -> !n.getName().contains("meat")).collect(Collectors.toList());
for(GroundItem item : t) {

    doStuff();

}

 

Edited by Spork

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