Package forestry.api.core
Record Class FluidProduct
java.lang.Object
java.lang.Record
forestry.api.core.FluidProduct
- Record Components:
stack- The fluid stack this product always produces. Must not be empty.
- All Implemented Interfaces:
IFluidProduct
public record FluidProduct(net.neoforged.neoforge.fluids.FluidStack stack)
extends Record
implements IFluidProduct
Default implementation of
IFluidProduct: a fixed fluid output. Used by all of Forestry's own squeezer
recipes. Wraps a FluidStack so fluid, amount, and data components are captured together.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<FluidProduct> static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf, FluidProduct> static final FluidProductType<FluidProduct> The default product type.Fields inherited from interface forestry.api.core.IFluidProduct
CODEC, TYPE_KEY -
Constructor Summary
ConstructorsConstructorDescriptionFluidProduct(net.neoforged.neoforge.fluids.FluidStack stack) Creates an instance of aFluidProductrecord class. -
Method Summary
Modifier and TypeMethodDescriptionnet.neoforged.neoforge.fluids.FluidStackCreates a new, non-random stack to represent this product in recipe viewers.net.neoforged.neoforge.fluids.FluidStackcreateRandomFluidStack(net.minecraft.util.RandomSource random) Used to produce a fluid stack from this product, taking randomness into account.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static FluidProductof(net.minecraft.world.level.material.Fluid fluid, int amount) static FluidProductof(net.neoforged.neoforge.fluids.FluidStack stack) net.neoforged.neoforge.fluids.FluidStackstack()Returns the value of thestackrecord component.final StringtoString()Returns a string representation of this record class.type()The type of this product, used to (de)serialize it viaIFluidProduct.CODEC.
-
Field Details
-
MAP_CODEC
-
STREAM_CODEC
public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,FluidProduct> STREAM_CODEC -
TYPE
The default product type. The dispatch codecIFluidProduct.CODECtreats this type specially: products of this type serialize without a"type"key, and a missing"type"key on decode resolves back to it.
-
-
Constructor Details
-
FluidProduct
public FluidProduct(net.neoforged.neoforge.fluids.FluidStack stack) Creates an instance of aFluidProductrecord class.- Parameters:
stack- the value for thestackrecord component
-
-
Method Details
-
createFluidStack
public net.neoforged.neoforge.fluids.FluidStack createFluidStack()Description copied from interface:IFluidProductCreates a new, non-random stack to represent this product in recipe viewers.The fluid amount should be the MAXIMUM amount of fluid a stack returned by this product's
IFluidProduct.createRandomFluidStack(RandomSource)can have. For example, if your recipe produces 100-300 mB of some fluid, this method should return a stack with 300 mB of fluid. This ensures machines like the Squeezer know how much space must be available to fit this fluid product into the output tank.This can return empty, like in the case where the product is a modded fluid not present in the current instance. However, in these cases, your recipe should use the proper conditions to disable itself rather than relying on this behavior.
- Specified by:
createFluidStackin interfaceIFluidProduct- Returns:
- A new stack representing this product. If your product is dynamic, return a "default" stack.
-
createRandomFluidStack
public net.neoforged.neoforge.fluids.FluidStack createRandomFluidStack(net.minecraft.util.RandomSource random) Description copied from interface:IFluidProductUsed to produce a fluid stack from this product, taking randomness into account. This is the final result produced by machines.- Specified by:
createRandomFluidStackin interfaceIFluidProduct- Parameters:
random- The random source. If no randomness is desired, this defaults toIFluidProduct.createFluidStack().- Returns:
- A new stack for this cycle, possibly empty or smaller than the representative stack.
-
type
Description copied from interface:IFluidProductThe type of this product, used to (de)serialize it viaIFluidProduct.CODEC. PlainFluidProductinstances returnTYPE, which the dispatch codec treats as the default: it serializes without a"type"key.- Specified by:
typein interfaceIFluidProduct- Returns:
- The type of this product.
-
of
-
of
-
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. All components in this record class are compared withObjects::equals(Object,Object). -
stack
public net.neoforged.neoforge.fluids.FluidStack stack()Returns the value of thestackrecord component.- Returns:
- the value of the
stackrecord component
-