Class FuzzyMatcher

java.lang.Object
net.xun.lib.common.api.item.fuzzy.FuzzyMatcher

public class FuzzyMatcher extends Object
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 components
  • IGNORE_ALL - Loose matching only checking item types
  • STRICT - 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

    Fields
    Modifier and Type
    Field
    Description
    static final FuzzyMatcher
    Preconfigured matcher that ignores durability, enchantments, and all data components.
    static final FuzzyMatcher
    Preconfigured matcher that ignores count, durability, enchantments, and all data components.
    static final FuzzyMatcher
    Strict matcher requiring exact match of: Item type Count Durability Enchantments All other data components
  • Method Summary

    Modifier and Type
    Method
    Description
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • BASIC

      public static final FuzzyMatcher BASIC
      Preconfigured matcher that ignores durability, enchantments, and all data components. Compares item types and count strictly.
    • IGNORE_ALL

      public static final FuzzyMatcher IGNORE_ALL
      Preconfigured matcher that ignores count, durability, enchantments, and all data components. Only compares item types.
    • STRICT

      public static final FuzzyMatcher 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:

      1. Empty item check (both must be empty or both non-empty)
      2. Core item type/tag verification
      3. Durability comparison (if enabled)
      4. Enchantment comparison (if enabled)
      5. Data component filtering
      6. Count comparison using configured mode
      7. Custom predicate validation
      Parameters:
      a - First item stack to compare
      b - 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