Class SizedIngredient
java.lang.Object
net.neoforged.neoforge.common.crafting.SizedIngredient
Standard implementation for an ingredient and a count.
Ingredient
does not perform count checks, so this class is used to wrap an ingredient with a count,
and provide a standard serialization format.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate @Nullable ItemStack[]
private final int
static final com.mojang.serialization.Codec
<SizedIngredient> The "flat" codec forSizedIngredient
.private final Ingredient
static final com.mojang.serialization.Codec
<SizedIngredient> The "nested" codec forSizedIngredient
.static final StreamCodec
<RegistryFriendlyByteBuf, SizedIngredient> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
count()
boolean
getItems()
Returns a list of the stacks from thisingredient
, with an updatedcount
.int
hashCode()
static SizedIngredient
Helper method to create a simple sized ingredient that matches items in a tag.static SizedIngredient
Helper method to create a simple sized ingredient that matches a single item.boolean
Performs a size-sensitive test on the given stack.toString()
-
Field Details
-
FLAT_CODEC
The "flat" codec forSizedIngredient
.The count is serialized inline with the rest of the ingredient, for example:
Array ingredients are serialized using the compound ingredient type:{ "item": "minecraft:apple", "count": 3 }
See{ "type": "neoforge:compound", "ingredients": [ { "item": "minecraft:coal" }, { "item": "minecraft:charcoal" } ], "count": 2 }
Ingredient.MAP_CODEC_NONEMPTY
for details of the ingredient serialization. -
NESTED_CODEC
The "nested" codec forSizedIngredient
.The count is serialized separately from the rest of the ingredient, for example:
{ "ingredient": { "item": "minecraft:apple" }, "count": 3 }
-
STREAM_CODEC
-
ingredient
-
count
private final int count -
cachedStacks
-
-
Constructor Details
-
SizedIngredient
-
-
Method Details
-
of
Helper method to create a simple sized ingredient that matches a single item. -
of
Helper method to create a simple sized ingredient that matches items in a tag. -
ingredient
-
count
public int count() -
test
Performs a size-sensitive test on the given stack.- Returns:
true
if the stack matches the ingredient and has at least the required count.
-
getItems
Returns a list of the stacks from thisingredient
, with an updatedcount
. -
equals
-
hashCode
public int hashCode() -
toString
-