Package com.minecolonies.api.crafting
Record Class CountedIngredient
java.lang.Object
java.lang.Record
com.minecolonies.api.crafting.CountedIngredient
- Record Components:
child- the underlying ingredient.count- the number of items required.
- All Implemented Interfaces:
net.neoforged.neoforge.common.crafting.ICustomIngredient
public record CountedIngredient(@NotNull net.minecraft.world.item.crafting.Ingredient child, int count)
extends Record
implements net.neoforged.neoforge.common.crafting.ICustomIngredient
An ingredient that can be used in a vanilla recipe to require more than one item in a particular input slot.
Similar to
SizedIngredient, but this deliberately skips the
count check in test(ItemStack) to more easily support consuming across multiple inventory slots --
and unlike that, it participates as a custom ingredient directly.
{
"type": "minecolonies:counted",
"item": {
"item": "minecraft:cobblestone" // could be a tag or something else
},
"count": 16
}-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<CountedIngredient> -
Constructor Summary
ConstructorsConstructorDescriptionCountedIngredient(@NotNull net.minecraft.world.item.crafting.Ingredient child, int count) Creates an instance of aCountedIngredientrecord class. -
Method Summary
Modifier and TypeMethodDescription@NotNull net.minecraft.world.item.crafting.Ingredientchild()Returns the value of thechildrecord component.intcount()Returns the value of thecountrecord component.final booleanIndicates whether some other object is "equal to" this one.@NotNull Stream<net.minecraft.world.item.ItemStack> getItems()@NotNull net.neoforged.neoforge.common.crafting.IngredientType<?> getType()final inthashCode()Returns a hash code value for this object.booleanisSimple()static net.minecraft.world.item.crafting.Ingredientof(@NotNull net.minecraft.world.item.crafting.Ingredient child, int count) Creates a counted ingredient.booleantest(@Nullable net.minecraft.world.item.ItemStack stack) Tests if the given stack matches the base ingredient.final StringtoString()Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.neoforged.neoforge.common.crafting.ICustomIngredient
toVanilla
-
Field Details
-
CODEC
-
-
Constructor Details
-
Method Details
-
of
public static net.minecraft.world.item.crafting.Ingredient of(@NotNull @NotNull net.minecraft.world.item.crafting.Ingredient child, int count) Creates a counted ingredient.- Parameters:
child- the underlying ingredient.count- the number of items required.- Returns:
- the counted ingredient.
-
test
public boolean test(@Nullable @Nullable net.minecraft.world.item.ItemStack stack) Tests if the given stack matches the base ingredient. Note: deliberately does *not* verify the count.- Specified by:
testin interfacenet.neoforged.neoforge.common.crafting.ICustomIngredient- Parameters:
stack- the stack to test- Returns:
- true if the stack is the matching ingredient, regardless of count.
-
isSimple
public boolean isSimple()- Specified by:
isSimplein interfacenet.neoforged.neoforge.common.crafting.ICustomIngredient
-
getType
@NotNull public @NotNull net.neoforged.neoforge.common.crafting.IngredientType<?> getType()- Specified by:
getTypein interfacenet.neoforged.neoforge.common.crafting.ICustomIngredient
-
getItems
- Specified by:
getItemsin interfacenet.neoforged.neoforge.common.crafting.ICustomIngredient
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
child
@NotNull public @NotNull net.minecraft.world.item.crafting.Ingredient child()Returns the value of thechildrecord component.- Returns:
- the value of the
childrecord component
-
count
public int count()Returns the value of thecountrecord component.- Returns:
- the value of the
countrecord component
-