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 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
-
Method Summary
Modifier and TypeMethodDescriptiondefault ItemFilter
and(ItemFilter other)
default Predicate<net.minecraft.item.ItemStack>
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
- Returns:
- A
Predicate
that delegates to thismatches(ItemStack)
. The default implementation returnsItemFilter.ItemFilterAsPredicate
, which is probably always what you want.
-