Jump to content

GroundItem Filter - If closest item doesn't contain string


Spork

Recommended Posts

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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