Class CauldronFluidContent

java.lang.Object
net.fabricmc.fabric.api.transfer.v1.fluid.CauldronFluidContent

@Experimental public final class CauldronFluidContent extends Object
Entrypoint to expose cauldrons to the Fluid Transfer API. Empty, water and lava cauldrons are registered by default, and additional cauldrons must be registered with registerCauldron(net.minecraft.block.Block, net.minecraft.fluid.Fluid, long, net.minecraft.state.property.IntProperty). Contents can be queried with getForBlock(net.minecraft.block.Block) and getForFluid(net.minecraft.fluid.Fluid).

The CauldronFluidContent itself defines:

  • The block of the cauldron.
  • The fluid that can be accepted by the cauldron. NBT is discarded when entering the cauldron.
  • Which fluid amounts can be stored in the cauldron, and how they map to the level property of the cauldron. If levelProperty is null, then maxLevel = 1, and there is only one level. Otherwise, the levels are all the integer values between 1 and maxLevel (included).
  • amountPerLevel defines how much fluid (in droplets) there is in one level of the cauldron.

Experimental feature, we reserve the right to remove or change it without further notice. The transfer API is a complex addition, and we want to be able to correct possible design mistakes.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final long
    Amount in droplets for each level of levelProperty.
    final net.minecraft.block.Block
    Block of the cauldron.
    final net.minecraft.fluid.Fluid
    Fluid stored inside the cauldron.
    final @Nullable net.minecraft.state.property.IntProperty
    Property storing the level of the cauldron.
    final int
    Maximum level for levelProperty.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    currentLevel(net.minecraft.block.BlockState state)
    Return the current level of the cauldron given its block state, or 0 if it's an empty cauldron.
    static @Nullable CauldronFluidContent
    getForBlock(net.minecraft.block.Block block)
    Get the cauldron fluid content for a cauldron block, or null if none was registered (yet).
    static @Nullable CauldronFluidContent
    getForFluid(net.minecraft.fluid.Fluid fluid)
    Get the cauldron fluid content for a fluid, or null if no cauldron was registered for that fluid (yet).
    registerCauldron(net.minecraft.block.Block block, net.minecraft.fluid.Fluid fluid, long amountPerLevel, @Nullable net.minecraft.state.property.IntProperty levelProperty)
    Attempt to register a new cauldron if not already registered, allowing it to be filled and emptied through the Fluid Transfer API.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • block

      public final net.minecraft.block.Block block
      Block of the cauldron.
    • fluid

      public final net.minecraft.fluid.Fluid fluid
      Fluid stored inside the cauldron.
    • amountPerLevel

      public final long amountPerLevel
      Amount in droplets for each level of levelProperty.
    • maxLevel

      public final int maxLevel
      Maximum level for levelProperty. 1 if levelProperty is null, otherwise a number >= 1. The minimum level is always 1.
    • levelProperty

      @Nullable public final @Nullable net.minecraft.state.property.IntProperty levelProperty
      Property storing the level of the cauldron. If it's null, only one level is possible.
  • Method Details

    • getForBlock

      @Nullable public static @Nullable CauldronFluidContent getForBlock(net.minecraft.block.Block block)
      Get the cauldron fluid content for a cauldron block, or null if none was registered (yet).
    • getForFluid

      @Nullable public static @Nullable CauldronFluidContent getForFluid(net.minecraft.fluid.Fluid fluid)
      Get the cauldron fluid content for a fluid, or null if no cauldron was registered for that fluid (yet).
    • registerCauldron

      public static CauldronFluidContent registerCauldron(net.minecraft.block.Block block, net.minecraft.fluid.Fluid fluid, long amountPerLevel, @Nullable @Nullable net.minecraft.state.property.IntProperty levelProperty)
      Attempt to register a new cauldron if not already registered, allowing it to be filled and emptied through the Fluid Transfer API. In both cases, return the content of the cauldron, either the existing one, or the newly registered one.
      Parameters:
      block - The block of the cauldron.
      fluid - The fluid stored in this cauldron.
      amountPerLevel - How much fluid is contained in one level of the cauldron, in droplets.
      levelProperty - The property used by the cauldron to store its levels. null if the cauldron only has one level.
    • currentLevel

      public int currentLevel(net.minecraft.block.BlockState state)
      Return the current level of the cauldron given its block state, or 0 if it's an empty cauldron.