Interface IIngredientMatcher<T,M>
- Type Parameters:
T
- The instance type to match.M
- The matching condition parameter.
- All Superinterfaces:
Comparator<T>
- All Known Implementing Classes:
IngredientMatcherEnergy
,IngredientMatcherFluidStack
,IngredientMatcherItemStack
An instance matcher for certain instance and condition types.
-
Method Summary
Modifier and TypeMethodDescriptionint
conditionCompare
(M a, M b) Compare two conditions with each other.Create a deep copy of the given instance.net.minecraft.network.chat.MutableComponent
getDisplayName
(T instance) Return the display name of the given instance.long
long
getQuantity
(T instance) Get the quantity in the given instance.boolean
hasCondition
(M matchCondition, M searchCondition) Check if the given match condition contains at least the given condition.int
Hash the given instance.default boolean
Check if the given entity matches the empty instance, as provided bygetEmptyInstance()
.boolean
isInstance
(Object object) If the given object is an instance of the ingredient type.Return the localized name of the given instance.boolean
Check if the two given instances match based on the given match conditions.default boolean
matchesExactly
(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 java.util.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.
-
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
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
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
Create a deep copy of the given instance.- Parameters:
instance
- An instance.- Returns:
- A copy of the given instance.
-
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
Compare two conditions with each other.- Parameters:
a
- A first condition.b
- A second condition.- Returns:
- The comparison result.
-
localize
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
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
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.
-