Interface ItemFilter
- All Known Subinterfaces:
ReadableItemFilter,ResolvableItemFilter
- All Known Implementing Classes:
AggregateItemFilter,ConstantItemFilter,ExactItemFilter,ExactItemSetFilter,ExactItemStackFilter,InvertedItemFilter,ItemClassFilter,ItemInsertableFilter,ItemTagFilter
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A specialised version of the
Predicate functional interface for ItemStacks.
5 basic implementations are provided:
ConstantItemFilterfor filters that always match or never match.ExactItemFilterfor a filter that matches on a singleItem, and rejects others.ExactItemStackFilterfor a filter that matches on a singleItemStack(using .ItemClassFilterfor a filter that only matches onItems whose#getClass()is an instanceof the class specified by the filter.AggregateItemFilterfor a filter that either AND's or OR's several otherItemFilter's into one.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptiondefault ItemFilterand(ItemFilter other)default Predicate<net.minecraft.item.ItemStack>booleanmatches(net.minecraft.item.ItemStack stack)Checks to see if this filter matches the given stack.default ItemFilternegate()default ItemFilteror(ItemFilter other)
-
Method Details
-
matches
boolean matches(net.minecraft.item.ItemStack stack)Checks to see if this filter matches the given stack. Note that this must not care aboutItemStack.getCount(), except in the case where the stack isItemStack.isEmpty(), which isn't expected to return a useful result. -
negate
-
and
-
or
-
asPredicate
- Returns:
- A
Predicatethat delegates to thismatches(ItemStack). The default implementation returnsItemFilter.ItemFilterAsPredicate, which is probably always what you want.
-