Class IngredientMatcherItemStack
java.lang.Object
org.cyclops.commoncapabilities.ingredient.IngredientMatcherItemStack
- All Implemented Interfaces:
Comparator<net.minecraft.world.item.ItemStack>
,IIngredientMatcher<net.minecraft.world.item.ItemStack,
Integer>
public class IngredientMatcherItemStack
extends Object
implements IIngredientMatcher<net.minecraft.world.item.ItemStack,Integer>
Matcher for ItemStacks.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
compare
(net.minecraft.world.item.ItemStack o1, net.minecraft.world.item.ItemStack o2) int
conditionCompare
(Integer a, Integer b) Compare two conditions with each other.net.minecraft.world.item.ItemStack
copy
(net.minecraft.world.item.ItemStack instance) Create a deep copy of the given instance.net.minecraft.network.chat.MutableComponent
getDisplayName
(net.minecraft.world.item.ItemStack instance) Return the display name of the given instance.net.minecraft.world.item.ItemStack
long
long
getQuantity
(net.minecraft.world.item.ItemStack instance) Get the quantity in the given instance.boolean
hasCondition
(Integer matchCondition, Integer searchCondition) Check if the given match condition contains at least the given condition.int
hash
(net.minecraft.world.item.ItemStack instance) Hash the given instance.boolean
isEmpty
(net.minecraft.world.item.ItemStack instance) Check if the given entity matches the empty instance, as provided byIIngredientMatcher.getEmptyInstance()
.boolean
isInstance
(Object object) If the given object is an instance of the ingredient type.localize
(net.minecraft.world.item.ItemStack instance) Return the localized name of the given instance.boolean
matches
(net.minecraft.world.item.ItemStack a, net.minecraft.world.item.ItemStack b, Integer matchCondition) Check if the two given instances match based on the given match conditions.toString
(net.minecraft.world.item.ItemStack instance) Return a stringified version of the given instance.withCondition
(Integer matchCondition, Integer with) Create a new match condition based on the given condition that includes the second condition.withoutCondition
(Integer matchCondition, Integer without) Create a new match condition based on the given condition that excludes the second condition.net.minecraft.world.item.ItemStack
withQuantity
(net.minecraft.world.item.ItemStack instance, long quantity) Create a copy of the given instance with the given quantity.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
Methods inherited from interface org.cyclops.commoncapabilities.api.ingredient.IIngredientMatcher
matchesExactly
-
Constructor Details
-
IngredientMatcherItemStack
public IngredientMatcherItemStack()
-
-
Method Details
-
isInstance
Description copied from interface:IIngredientMatcher
If the given object is an instance of the ingredient type.- Specified by:
isInstance
in interfaceIIngredientMatcher<net.minecraft.world.item.ItemStack,
Integer> - Parameters:
object
- An object.- Returns:
- If the object is a valid instance of the ingredient component type.
-
getAnyMatchCondition
- Specified by:
getAnyMatchCondition
in interfaceIIngredientMatcher<net.minecraft.world.item.ItemStack,
Integer> - Returns:
- The match condition that is used to match any instance based on a prototype.
-
getExactMatchCondition
- Specified by:
getExactMatchCondition
in interfaceIIngredientMatcher<net.minecraft.world.item.ItemStack,
Integer> - Returns:
- The match condition that is used to match instances exactly based on a prototype.
-
getExactMatchNoQuantityCondition
- Specified by:
getExactMatchNoQuantityCondition
in interfaceIIngredientMatcher<net.minecraft.world.item.ItemStack,
Integer> - Returns:
- The match condition that is used to match instances exactly based on a prototype, excluding the quantity.
-
withCondition
Description copied from interface:IIngredientMatcher
Create a new match condition based on the given condition that includes the second condition.- Specified by:
withCondition
in interfaceIIngredientMatcher<net.minecraft.world.item.ItemStack,
Integer> - 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
Description copied from interface:IIngredientMatcher
Create a new match condition based on the given condition that excludes the second condition.- Specified by:
withoutCondition
in interfaceIIngredientMatcher<net.minecraft.world.item.ItemStack,
Integer> - 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
Description copied from interface:IIngredientMatcher
Check if the given match condition contains at least the given condition.- Specified by:
hasCondition
in interfaceIIngredientMatcher<net.minecraft.world.item.ItemStack,
Integer> - 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
public boolean matches(net.minecraft.world.item.ItemStack a, net.minecraft.world.item.ItemStack b, Integer matchCondition) Description copied from interface:IIngredientMatcher
Check if the two given instances match based on the given match conditions.- Specified by:
matches
in interfaceIIngredientMatcher<net.minecraft.world.item.ItemStack,
Integer> - 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.
-
getEmptyInstance
public net.minecraft.world.item.ItemStack getEmptyInstance()- Specified by:
getEmptyInstance
in interfaceIIngredientMatcher<net.minecraft.world.item.ItemStack,
Integer> - Returns:
- The instance that acts as an 'empty' instance. For ItemStacks, this would be ItemStack.EMPTY.
-
isEmpty
public boolean isEmpty(net.minecraft.world.item.ItemStack instance) Description copied from interface:IIngredientMatcher
Check if the given entity matches the empty instance, as provided byIIngredientMatcher.getEmptyInstance()
.- Specified by:
isEmpty
in interfaceIIngredientMatcher<net.minecraft.world.item.ItemStack,
Integer> - Parameters:
instance
- An instance.- Returns:
- If the instance is empty.
-
hash
public int hash(net.minecraft.world.item.ItemStack instance) Description copied from interface:IIngredientMatcher
Hash the given instance. This must be calculated quickly.- Specified by:
hash
in interfaceIIngredientMatcher<net.minecraft.world.item.ItemStack,
Integer> - Parameters:
instance
- An instance.- Returns:
- A hashcode for the given instance.
-
copy
public net.minecraft.world.item.ItemStack copy(net.minecraft.world.item.ItemStack instance) Description copied from interface:IIngredientMatcher
Create a deep copy of the given instance.- Specified by:
copy
in interfaceIIngredientMatcher<net.minecraft.world.item.ItemStack,
Integer> - Parameters:
instance
- An instance.- Returns:
- A copy of the given instance.
-
getQuantity
public long getQuantity(net.minecraft.world.item.ItemStack instance) Description copied from interface:IIngredientMatcher
Get the quantity in the given instance.- Specified by:
getQuantity
in interfaceIIngredientMatcher<net.minecraft.world.item.ItemStack,
Integer> - Parameters:
instance
- An instance.- Returns:
- The instance quantity.
-
withQuantity
public net.minecraft.world.item.ItemStack withQuantity(net.minecraft.world.item.ItemStack instance, long quantity) Description copied from interface:IIngredientMatcher
Create a copy of the given instance with the given quantity.- Specified by:
withQuantity
in interfaceIIngredientMatcher<net.minecraft.world.item.ItemStack,
Integer> - Parameters:
instance
- An instance.quantity
- The new instance quantity.- Returns:
- The copied instance with the new quantity.
-
getMaximumQuantity
public long getMaximumQuantity()- Specified by:
getMaximumQuantity
in interfaceIIngredientMatcher<net.minecraft.world.item.ItemStack,
Integer> - Returns:
- The maximum allowed quantity for instances.
-
conditionCompare
Description copied from interface:IIngredientMatcher
Compare two conditions with each other.- Specified by:
conditionCompare
in interfaceIIngredientMatcher<net.minecraft.world.item.ItemStack,
Integer> - Parameters:
a
- A first condition.b
- A second condition.- Returns:
- The comparison result.
-
localize
Description copied from interface:IIngredientMatcher
Return the localized name of the given instance. This should not include the instance quantity. Should only be called client-side!- Specified by:
localize
in interfaceIIngredientMatcher<net.minecraft.world.item.ItemStack,
Integer> - Parameters:
instance
- An instance.- Returns:
- The localized name of the given instance.
-
getDisplayName
public net.minecraft.network.chat.MutableComponent getDisplayName(net.minecraft.world.item.ItemStack instance) Description copied from interface:IIngredientMatcher
Return the display name of the given instance. This should not include the instance quantity.- Specified by:
getDisplayName
in interfaceIIngredientMatcher<net.minecraft.world.item.ItemStack,
Integer> - Parameters:
instance
- An instance.- Returns:
- The display name of the given instance.
-
toString
Description copied from interface:IIngredientMatcher
Return a stringified version of the given instance. These strings are mainly used for development purposes.- Specified by:
toString
in interfaceIIngredientMatcher<net.minecraft.world.item.ItemStack,
Integer> - Parameters:
instance
- An instance.- Returns:
- The string version of the given instance.
-
compare
public int compare(net.minecraft.world.item.ItemStack o1, net.minecraft.world.item.ItemStack o2) - Specified by:
compare
in interfaceComparator<net.minecraft.world.item.ItemStack>
-