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 Details

    • block

      public final Block block
      Block of the cauldron.
    • fluid

      public final 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 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(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(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(Block block, Fluid fluid, long amountPerLevel, @Nullable @Nullable 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(BlockState state)
      Return the current level of the cauldron given its block state, or 0 if it's an empty cauldron.