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.
@FunctionalInterface
public interface ItemFilter
A specialised version of the
Predicate
functional interface for ItemStack
s.
5 basic implementations are provided:
ConstantItemFilter
for filters that always match or never match.ExactItemFilter
for a filter that matches on a singleItem
, and rejects others.ExactItemStackFilter
for a filter that matches on a singleItemStack
(using .ItemClassFilter
for a filter that only matches onItem
s whose#getClass()
is an instance
of the class specified by the filter.AggregateItemFilter
for a filter that either AND's or OR's several otherItemFilter
's into one.
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
ItemFilter.ItemFilterAsPredicate
Predicate
wrapper around anItemFilter
. -
Method Summary
Modifier and Type Method Description default ItemFilter
and(ItemFilter other)
default java.util.function.Predicate<net.minecraft.item.ItemStack>
asPredicate()
boolean
matches(net.minecraft.item.ItemStack stack)
Checks to see if this filter matches the given stack.default ItemFilter
negate()
default ItemFilter
or(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
default java.util.function.Predicate<net.minecraft.item.ItemStack> asPredicate()- Returns:
- A
Predicate
that delegates to thismatches(ItemStack)
. The default implementation returnsItemFilter.ItemFilterAsPredicate
, which is probably always what you want.
-