Class SizedFluidIngredient
java.lang.Object
net.neoforged.neoforge.fluids.crafting.SizedFluidIngredient
Standard implementation for a FluidIngredient with an amount.
FluidIngredient, like its item counterpart, explicitly does not perform count checks,
so this class is used to (a) wrap a standard FluidIngredient with an amount and (b) provide a
standard serialization format for mods to use.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final intprivate @Nullable FluidStack[]static final com.mojang.serialization.Codec<SizedFluidIngredient> The "flat" codec forSizedFluidIngredient.private final FluidIngredientstatic final com.mojang.serialization.Codec<SizedFluidIngredient> The "nested" codec forSizedFluidIngredient.static final StreamCodec<RegistryFriendlyByteBuf, SizedFluidIngredient> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintamount()booleanReturns a list of the stacks from thisingredient, with an updatedamount.inthashCode()static SizedFluidIngredientHelper method to create a simple sized ingredient that matches fluids in a tag.static SizedFluidIngredientstatic SizedFluidIngredientof(FluidStack stack) Helper method to create a simple sized ingredient that matches the given fluid stackbooleantest(FluidStack stack) Performs a size-sensitive test on the given stack.toString()
-
Field Details
-
FLAT_CODEC
The "flat" codec forSizedFluidIngredient.The amount is serialized inline with the rest of the ingredient, for example:
{ "fluid": "minecraft:water", "amount": 250 }Compound fluid ingredients are always serialized using the map codec, i.e.
{ "type": "neoforge:compound", "ingredients": [ { "fluid": "minecraft:water" }, { "fluid": "minecraft:milk" } ], "amount": 500 } -
NESTED_CODEC
The "nested" codec forSizedFluidIngredient.With this codec, the amount is always serialized separately from the ingredient itself, for example:
{ "ingredient": { "fluid": "minecraft:lava" }, "amount": 1000 } -
STREAM_CODEC
-
ingredient
-
amount
private final int amount -
cachedStacks
-
-
Constructor Details
-
SizedFluidIngredient
-
-
Method Details
-
of
-
of
Helper method to create a simple sized ingredient that matches the given fluid stack -
of
Helper method to create a simple sized ingredient that matches fluids in a tag. -
ingredient
-
amount
public int amount() -
test
Performs a size-sensitive test on the given stack.- Returns:
trueif the stack matches the ingredient and has at least the required amount.
-
getFluids
Returns a list of the stacks from thisingredient, with an updatedamount. -
equals
-
hashCode
public int hashCode() -
toString
-