Interface IIngredientMatcher<T,M>
- Type Parameters:
T- The instance type to match.M- The matching condition parameter.
- All Superinterfaces:
Comparator<T>
An instance matcher for certain instance and condition types.
-
Method Summary
Modifier and TypeMethodDescriptionintconditionCompare(M a, M b) Compare two conditions with each other.Create a deep copy of the given instance.net.minecraft.network.chat.MutableComponentgetDisplayName(T instance) Return the display name of the given instance.longlonggetQuantity(T instance) Get the quantity in the given instance.booleanhasCondition(M matchCondition, M searchCondition) Check if the given match condition contains at least the given condition.intHash the given instance.default booleanCheck if the given entity matches the empty instance, as provided bygetEmptyInstance().booleanisInstance(Object object) If the given object is an instance of the ingredient type.Return the localized name of the given instance.booleanCheck if the two given instances match based on the given match conditions.default booleanmatchesExactly(T a, T b) Check if the two given instances are equal.Return a stringified version of the given instance.withCondition(M matchCondition, M with) Create a new match condition based on the given condition that includes the second condition.withoutCondition(M matchCondition, M without) Create a new match condition based on the given condition that excludes the second condition.withQuantity(T instance, long quantity) Create a copy of the given instance with the given quantity.Methods inherited from interface Comparator
compare, equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Method Details
-
isInstance
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.
-
getQuantityMatchCondition
M getQuantityMatchCondition()- Returns:
- The match condition that is used to match instances by quantity 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
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
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
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
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
-
getEmptyInstance
T getEmptyInstance()- Returns:
- The instance that acts as an 'empty' instance. For ItemStacks, this would be ItemStack.EMPTY.
-
getNonEmptyInstance
T getNonEmptyInstance()- Returns:
- An instance.
-
isEmpty
Check if the given entity matches the empty instance, as provided bygetEmptyInstance().- Parameters:
instance- An instance.- Returns:
- If the instance is empty.
-
hash
Hash the given instance. This must be calculated quickly.- Parameters:
instance- An instance.- Returns:
- A hashcode for the given instance.
-
copy
-
getQuantity
Get the quantity in the given instance.- Parameters:
instance- An instance.- Returns:
- The instance quantity.
-
withQuantity
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
-
localize
-
getDisplayName
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
-