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
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.Codec<FluidHolder>
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
    default FluidHolder
    copyWithAmount(long amount)
    Does not set amount if the holder is empty.
    void
    deserialize(net.minecraft.nbt.CompoundTag tag)
    Deserializes a FluidHolder from a given CompoundTag.
    Returns an empty FluidHolder.
    fromCompound(net.minecraft.nbt.CompoundTag tag)
    Creates a FluidHolder from a CompoundTag.
    net.minecraft.nbt.CompoundTag
     
    net.minecraft.world.level.material.Fluid
     
    long
     
    default net.minecraft.core.Holder<net.minecraft.world.level.material.Fluid>
     
    default boolean
    is(Predicate<net.minecraft.core.Holder<net.minecraft.world.level.material.Fluid>> predicate)
     
    default boolean
    is(net.minecraft.core.Holder<net.minecraft.world.level.material.Fluid> fluid)
     
    default boolean
    is(net.minecraft.tags.TagKey<net.minecraft.world.level.material.Fluid> tagKey)
     
    default boolean
    is(net.minecraft.world.level.material.Fluid fluid)
     
    boolean
     
    boolean
    matches(FluidHolder fluidHolder)
    Compares the FluidHolder to another FluidHolder ignoring the amount.
    of(net.minecraft.world.level.material.Fluid fluid)
    Creates a FluidHolder with the given Fluid and a default of 1 bucket.
    of(net.minecraft.world.level.material.Fluid fluid, long amount)
    Creates a FluidHolder with the specified Fluid and amount.
    of(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.
    readFromBuffer(net.minecraft.network.FriendlyByteBuf buffer)
     
    net.minecraft.nbt.CompoundTag
     
    void
    setAmount(long amount)
    Sets the amount of fluid in the holder.
    void
    setCompound(net.minecraft.nbt.CompoundTag tag)
    Sets the CompoundTag in the holder.
    void
    setFluid(net.minecraft.world.level.material.Fluid fluid)
    Sets the Fluid in the holder.
    default void
    writeToBuffer(net.minecraft.network.FriendlyByteBuf buffer)
     
  • Field Details

    • CODEC

      static final com.mojang.serialization.Codec<FluidHolder> CODEC
  • Method Details

    • of

      static FluidHolder of(net.minecraft.world.level.material.Fluid fluid)
      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

      static FluidHolder of(net.minecraft.world.level.material.Fluid fluid, long amount)
      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.
    • fromCompound

      static FluidHolder fromCompound(net.minecraft.nbt.CompoundTag tag)
      Creates a FluidHolder from a CompoundTag.
      Parameters:
      tag - The CompoundTag to create the FluidHolder from.
      Returns:
      The created FluidHolder.
    • empty

      @ImplementedByExtension static FluidHolder empty()
      Returns an empty FluidHolder.
      Returns:
      The empty FluidHolder.
    • writeToBuffer

      default void writeToBuffer(net.minecraft.network.FriendlyByteBuf buffer)
    • readFromBuffer

      static FluidHolder readFromBuffer(net.minecraft.network.FriendlyByteBuf buffer)
    • getFluid

      net.minecraft.world.level.material.Fluid getFluid()
      Returns:
      The Fluid in the holder.
    • setFluid

      void setFluid(net.minecraft.world.level.material.Fluid fluid)
      Sets the Fluid in the holder.
      Parameters:
      fluid - The Fluid to 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 CompoundTag in the holder.
    • setCompound

      void setCompound(net.minecraft.nbt.CompoundTag tag)
      Sets the CompoundTag in the holder.
      Parameters:
      tag - The CompoundTag to set in the holder.
    • isEmpty

      boolean isEmpty()
      Returns:
      True if the holder is empty, false otherwise.
    • matches

      boolean matches(FluidHolder fluidHolder)
      Compares the FluidHolder to another FluidHolder ignoring the amount.
      Parameters:
      fluidHolder - The FluidHolder to 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 FluidHolder into a CompoundTag.
    • deserialize

      void deserialize(net.minecraft.nbt.CompoundTag tag)
      Deserializes a FluidHolder from a given CompoundTag.
      Parameters:
      tag - The CompoundTag to deserialize from.
    • copyWithAmount

      default FluidHolder copyWithAmount(long amount)
      Does not set amount if the holder is empty.
      Parameters:
      amount - The amount to set in the copy.
      Returns:
      A copy of the FluidHolder with 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)