Class FuzzyMatcher
java.lang.Object
net.xun.lib.common.api.item.fuzzy.FuzzyMatcher
Advanced item comparison system with configurable matching rules, supporting both
individual item checks and pairwise item comparisons.
Instances are immutable and thread-safe. Configure using the fluent methods that return new instances with updated settings.
Features
- Durability comparison control
- Enchantment matching toggle
- Data component filtering (whitelist/blacklist)
- Tag-based category matching
- Count comparison modes (exact, at-least, ignore)
- Custom validation rules via
InventoryPredicate - Empty item handling
Preconfigured Matchers
BASIC- Default strict comparison ignoring durability, enchantments, and componentsIGNORE_ALL- Loose matching only checking item typesSTRICT- Exact match of all item properties
Usage Examples
Basic configuration:
FuzzyMatcher matcher = new FuzzyMatcher(
new FuzzyConfig()
.withIgnoreDurability(true)
.withRequiredTag(ItemTags.SWORDS)
);
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final FuzzyMatcherPreconfigured matcher that ignores durability, enchantments, and all data components.static final FuzzyMatcherPreconfigured matcher that ignores count, durability, enchantments, and all data components.static final FuzzyMatcherStrict matcher requiring exact match of: Item type Count Durability Enchantments All other data components -
Method Summary
Modifier and TypeMethodDescriptionbooleanmatches(net.minecraft.world.item.ItemStack a, net.minecraft.world.item.ItemStack b) Tests if two item stacks match according to the configured rules.
-
Field Details
-
BASIC
Preconfigured matcher that ignores durability, enchantments, and all data components. Compares item types and count strictly. -
IGNORE_ALL
Preconfigured matcher that ignores count, durability, enchantments, and all data components. Only compares item types. -
STRICT
Strict matcher requiring exact match of:- Item type
- Count
- Durability
- Enchantments
- All other data components
-
-
Method Details
-
matches
public boolean matches(net.minecraft.world.item.ItemStack a, net.minecraft.world.item.ItemStack b) Tests if two item stacks match according to the configured rules.Execution order:
- Empty item check (both must be empty or both non-empty)
- Core item type/tag verification
- Durability comparison (if enabled)
- Enchantment comparison (if enabled)
- Data component filtering
- Count comparison using configured mode
- Custom predicate validation
- Parameters:
a- First item stack to compareb- Second item stack to compare- Returns:
- true if items match all configured rules, false otherwise
- Throws:
InvalidMatcherConfigurationException- if matcher contains conflicting rules:- Custom rules combined with tag requirements
- Custom rules used with attribute ignoring
NullPointerException- if either input stack is null
-