Record Class FluidStackTemplate
java.lang.Object
java.lang.Record
net.neoforged.neoforge.fluids.FluidStackTemplate
- All Implemented Interfaces:
DataComponentGetter, TypedInstance<Fluid>, FluidInstance
public record FluidStackTemplate(Holder<Fluid> fluid, int amount, DataComponentPatch components)
extends Record
implements FluidInstance
Fluid variant of ItemStackTemplate.
The main difference is that fluid templates are required to have an amount, while item templates default to 1.
Most methods in this class are adopted from ItemStackTemplate.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final intThe field for theamountrecord component.static final com.mojang.serialization.Codec<FluidStackTemplate> private final DataComponentPatchThe field for thecomponentsrecord component.The field for thefluidrecord component.static final com.mojang.serialization.MapCodec<FluidStackTemplate> static final StreamCodec<RegistryFriendlyByteBuf, FluidStackTemplate> Fields inherited from interface FluidInstance
FIELD_AMOUNT, FIELD_COMPONENTS, FIELD_ID, FLUID_HOLDER_CODEC, FLUID_HOLDER_CODEC_WITH_BOUND_COMPONENTS, FLUID_HOLDER_STREAM_CODEC -
Constructor Summary
ConstructorsConstructorDescriptionFluidStackTemplate(Holder<Fluid> fluid, int amount) FluidStackTemplate(Holder<Fluid> fluid, int amount, DataComponentPatch components) Creates an instance of aFluidStackTemplaterecord class.FluidStackTemplate(Fluid fluid, int amount) FluidStackTemplate(Fluid fluid, int amount, DataComponentPatch components) -
Method Summary
Modifier and TypeMethodDescriptionintamount()Returns the value of theamountrecord component.apply(int amount, DataComponentPatch additionalPatch) apply(DataComponentPatch additionalPatch) Returns the value of thecomponentsrecord component.create()final booleanIndicates whether some other object is "equal to" this one.static com.mojang.serialization.Codec<FluidStackTemplate> fixedAmountCodec(int amount) fixedAmountStreamCodec(int amount) fluid()Returns the value of thefluidrecord component.static FluidStackTemplatefromNonEmptyStack(FluidStack stack) <T> @Nullable Tget(DataComponentType<? extends T> type) final inthashCode()Returns a hash code value for this object.final StringtoString()Returns a string representation of this record class.withAmount(int amount) Methods inherited from interface DataComponentGetter
get, getOrDefault, getOrDefault, getTyped, has, hasMethods inherited from interface FluidInstance
getFluidType, is
-
Field Details
-
fluid
-
amount
private final int amountThe field for theamountrecord component. -
components
The field for thecomponentsrecord component. -
MAP_CODEC
-
CODEC
-
STREAM_CODEC
-
-
Constructor Details
-
FluidStackTemplate
Creates an instance of aFluidStackTemplaterecord class.- Parameters:
fluid- the value for thefluidrecord componentamount- the value for theamountrecord componentcomponents- the value for thecomponentsrecord component
-
FluidStackTemplate
-
FluidStackTemplate
-
FluidStackTemplate
-
-
Method Details
-
fromNonEmptyStack
-
withAmount
-
create
-
apply
-
apply
-
typeHolder
- Specified by:
typeHolderin interfaceTypedInstance<Fluid>
-
get
- Specified by:
getin interfaceDataComponentGetter
-
fixedAmountCodec
-
fixedAmountStreamCodec
public static StreamCodec<RegistryFriendlyByteBuf, FluidStackTemplate> fixedAmountStreamCodec(int amount) -
toString
-
hashCode
-
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 thecomparemethod from their corresponding wrapper classes. -
fluid
-
amount
public int amount()Returns the value of theamountrecord component.- Specified by:
amountin interfaceFluidInstance- Returns:
- the value of the
amountrecord component
-
components
Returns the value of thecomponentsrecord component.- Returns:
- the value of the
componentsrecord component
-