Interface IIngredientMatcher<T,M>

Type Parameters:
T - The instance type to match.
M - The matching condition parameter.
All Superinterfaces:
Comparator<T>

public interface IIngredientMatcher<T,M> extends Comparator<T>
An instance matcher for certain instance and condition types.
  • Method Details

    • isInstance

      boolean isInstance(Object object)
      If the given object is an instance of the ingredient type.
      Parameters:
      object - An object.
      Returns:
      If the object is a valid instance of the ingredient component type.
    • getAnyMatchCondition

      M getAnyMatchCondition()
      Returns:
      The match condition that is used to match any instance based on a prototype.
    • getExactMatchCondition

      M getExactMatchCondition()
      Returns:
      The match condition that is used to match instances exactly based on a prototype.
    • getExactMatchNoQuantityCondition

      M getExactMatchNoQuantityCondition()
      Returns:
      The match condition that is used to match instances exactly based on a prototype, excluding the quantity.
    • withCondition

      M withCondition(M matchCondition, M with)
      Create a new match condition based on the given condition that includes the second condition.
      Parameters:
      matchCondition - The match condition to start from.
      with - The match condition to include.
      Returns:
      A new match condition that is the combination of both.
    • withoutCondition

      M withoutCondition(M matchCondition, M without)
      Create a new match condition based on the given condition that excludes the second condition.
      Parameters:
      matchCondition - The match condition to start from.
      without - A match condition to exclude.
      Returns:
      A new match condition that is the first one without the second one.
    • hasCondition

      boolean hasCondition(M matchCondition, M searchCondition)
      Check if the given match condition contains at least the given condition.
      Parameters:
      matchCondition - The match condition to start from.
      searchCondition - A match condition to search for.
      Returns:
      If the first condition contains at least the second condition.
    • matches

      boolean matches(T a, T b, M matchCondition)
      Check if the two given instances match based on the given match conditions.
      Parameters:
      a - A first instance.
      b - A second instance.
      matchCondition - A condition under which the matching should be done.
      Returns:
      If the two given instances match under the given conditions.
    • matchesExactly

      default boolean matchesExactly(T a, T b)
      Check if the two given instances are equal.
      Parameters:
      a - A first instance.
      b - A second instance.
      Returns:
      If the two given instances are equal.
    • getEmptyInstance

      T getEmptyInstance()
      Returns:
      The instance that acts as an 'empty' instance. For ItemStacks, this would be ItemStack.EMPTY.
    • isEmpty

      default boolean isEmpty(T instance)
      Check if the given entity matches the empty instance, as provided by getEmptyInstance().
      Parameters:
      instance - An instance.
      Returns:
      If the instance is empty.
    • hash

      int hash(T instance)
      Hash the given instance. This must be calculated quickly.
      Parameters:
      instance - An instance.
      Returns:
      A hashcode for the given instance.
    • copy

      T copy(T instance)
      Create a deep copy of the given instance.
      Parameters:
      instance - An instance.
      Returns:
      A copy of the given instance.
    • getQuantity

      long getQuantity(T instance)
      Get the quantity in the given instance.
      Parameters:
      instance - An instance.
      Returns:
      The instance quantity.
    • withQuantity

      T withQuantity(T instance, long quantity) throws ArithmeticException
      Create a copy of the given instance with the given quantity.
      Parameters:
      instance - An instance.
      quantity - The new instance quantity.
      Returns:
      The copied instance with the new quantity.
      Throws:
      ArithmeticException - If the given quantity does not fit into the instance anymore.
    • getMaximumQuantity

      long getMaximumQuantity()
      Returns:
      The maximum allowed quantity for instances.
    • conditionCompare

      int conditionCompare(M a, M b)
      Compare two conditions with each other.
      Parameters:
      a - A first condition.
      b - A second condition.
      Returns:
      The comparison result.
    • localize

      String localize(T instance)
      Return the localized name of the given instance. This should not include the instance quantity. Should only be called client-side!
      Parameters:
      instance - An instance.
      Returns:
      The localized name of the given instance.
    • getDisplayName

      net.minecraft.network.chat.MutableComponent getDisplayName(T instance)
      Return the display name of the given instance. This should not include the instance quantity.
      Parameters:
      instance - An instance.
      Returns:
      The display name of the given instance.
    • toString

      String toString(T instance)
      Return a stringified version of the given instance. These strings are mainly used for development purposes.
      Parameters:
      instance - An instance.
      Returns:
      The string version of the given instance.