Interface FluidHolder
- All Known Implementing Classes:
ForgeFluidHolder
public interface FluidHolder
An object that holds a fluid with an amount and a tag.
Similar to
ItemStack, but for fluids.-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault FluidHoldercopyWithAmount(long amount) Does not set amount if the holder is empty.voiddeserialize(net.minecraft.nbt.CompoundTag tag) Deserializes aFluidHolderfrom a givenCompoundTag.static FluidHolderempty()Returns an empty FluidHolder.static FluidHolderfromCompound(net.minecraft.nbt.CompoundTag tag) Creates a FluidHolder from a CompoundTag.net.minecraft.nbt.CompoundTagnet.minecraft.world.level.material.FluidgetFluid()longdefault net.minecraft.core.Holder<net.minecraft.world.level.material.Fluid>default booleandefault booleanis(net.minecraft.core.Holder<net.minecraft.world.level.material.Fluid> fluid) default booleanis(net.minecraft.tags.TagKey<net.minecraft.world.level.material.Fluid> tagKey) default booleanis(net.minecraft.world.level.material.Fluid fluid) booleanisEmpty()booleanmatches(FluidHolder fluidHolder) Compares theFluidHolderto anotherFluidHolderignoring the amount.static FluidHolderof(net.minecraft.world.level.material.Fluid fluid) Creates a FluidHolder with the given Fluid and a default of 1 bucket.static FluidHolderof(net.minecraft.world.level.material.Fluid fluid, long amount) Creates a FluidHolder with the specified Fluid and amount.static FluidHolderof(net.minecraft.world.level.material.Fluid fluid, long amount, @Nullable net.minecraft.nbt.CompoundTag tag) Creates a FluidHolder with the specified Fluid, amount, and CompoundTag.static FluidHolderofMillibuckets(net.minecraft.world.level.material.Fluid fluid, long millibuckets) static FluidHolderofMillibuckets(net.minecraft.world.level.material.Fluid fluid, long millibuckets, @Nullable net.minecraft.nbt.CompoundTag tag) static FluidHolderreadFromBuffer(net.minecraft.network.FriendlyByteBuf buffer) net.minecraft.nbt.CompoundTagvoidsetAmount(long amount) Sets the amount of fluid in the holder.voidsetCompound(net.minecraft.nbt.CompoundTag tag) Sets theCompoundTagin the holder.voidsetFluid(net.minecraft.world.level.material.Fluid fluid) Sets theFluidin the holder.default voidwriteToBuffer(net.minecraft.network.FriendlyByteBuf buffer)
-
Field Details
-
CODEC
-
-
Method Details
-
of
Creates a FluidHolder with the given Fluid and a default of 1 bucket.- Parameters:
fluid- The Fluid to set in the holder.- Returns:
- The FluidHolder with the specified Fluid.
-
of
Creates a FluidHolder with the specified Fluid and amount.- Parameters:
fluid- The Fluid to set in the holder.amount- The amount of fluid to set in the holder.- Returns:
- The created FluidHolder.
-
of
@ImplementedByExtension static FluidHolder of(net.minecraft.world.level.material.Fluid fluid, long amount, @Nullable @Nullable net.minecraft.nbt.CompoundTag tag) Creates a FluidHolder with the specified Fluid, amount, and CompoundTag.- Parameters:
fluid- The Fluid to set in the holder.amount- The amount of fluid to set in the holder.tag- The CompoundTag to set in the holder.- Returns:
- The created FluidHolder.
-
ofMillibuckets
static FluidHolder ofMillibuckets(net.minecraft.world.level.material.Fluid fluid, long millibuckets, @Nullable @Nullable net.minecraft.nbt.CompoundTag tag) -
ofMillibuckets
static FluidHolder ofMillibuckets(net.minecraft.world.level.material.Fluid fluid, long millibuckets) -
fromCompound
Creates a FluidHolder from a CompoundTag.- Parameters:
tag- The CompoundTag to create the FluidHolder from.- Returns:
- The created FluidHolder.
-
empty
Returns an empty FluidHolder.- Returns:
- The empty FluidHolder.
-
writeToBuffer
default void writeToBuffer(net.minecraft.network.FriendlyByteBuf buffer) -
readFromBuffer
-
getFluid
net.minecraft.world.level.material.Fluid getFluid()- Returns:
- The
Fluidin the holder.
-
setFluid
void setFluid(net.minecraft.world.level.material.Fluid fluid) Sets theFluidin the holder.- Parameters:
fluid- TheFluidto set in the holder.
-
getFluidAmount
long getFluidAmount()- Returns:
- The amount of fluid in the holder.
-
setAmount
void setAmount(long amount) Sets the amount of fluid in the holder.- Parameters:
amount- The amount of fluid to set in the holder.
-
getCompound
net.minecraft.nbt.CompoundTag getCompound()- Returns:
- The
CompoundTagin the holder.
-
setCompound
void setCompound(net.minecraft.nbt.CompoundTag tag) Sets theCompoundTagin the holder.- Parameters:
tag- TheCompoundTagto set in the holder.
-
isEmpty
boolean isEmpty()- Returns:
- True if the holder is empty, false otherwise.
-
matches
Compares theFluidHolderto anotherFluidHolderignoring the amount.- Parameters:
fluidHolder- TheFluidHolderto compare to.- Returns:
- True if the given holder is equal to this holder, false otherwise.
-
copyHolder
FluidHolder copyHolder()- Returns:
- A copy of the
FluidHolder.
-
serialize
net.minecraft.nbt.CompoundTag serialize()- Returns:
- A serialized version of the
FluidHolderinto aCompoundTag.
-
deserialize
void deserialize(net.minecraft.nbt.CompoundTag tag) Deserializes aFluidHolderfrom a givenCompoundTag.- Parameters:
tag- TheCompoundTagto deserialize from.
-
copyWithAmount
Does not set amount if the holder is empty.- Parameters:
amount- The amount to set in the copy.- Returns:
- A copy of the
FluidHolderwith the given amount.
-
getFluidHolder
default net.minecraft.core.Holder<net.minecraft.world.level.material.Fluid> getFluidHolder() -
is
default boolean is(net.minecraft.tags.TagKey<net.minecraft.world.level.material.Fluid> tagKey) -
is
default boolean is(net.minecraft.world.level.material.Fluid fluid) -
is
default boolean is(Predicate<net.minecraft.core.Holder<net.minecraft.world.level.material.Fluid>> predicate) -
is
default boolean is(net.minecraft.core.Holder<net.minecraft.world.level.material.Fluid> fluid)
-