Class CauldronFluidContent
java.lang.Object
net.fabricmc.fabric.api.transfer.v1.fluid.CauldronFluidContent
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
levelPropertyisnull, thenmaxLevel = 1, and there is only one level. Otherwise, the levels are all the integer values between1andmaxLevel(included). amountPerLeveldefines 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
FieldsModifier and TypeFieldDescriptionfinal longAmount in droplets for each level oflevelProperty.final BlockBlock of the cauldron.final FluidFluid stored inside the cauldron.final @Nullable IntPropertyProperty storing the level of the cauldron.final intMaximum level forlevelProperty. -
Method Summary
Modifier and TypeMethodDescriptionintcurrentLevel(BlockState state) Return the current level of the cauldron given its block state, or 0 if it's an empty cauldron.static @Nullable CauldronFluidContentgetForBlock(Block block) Get the cauldron fluid content for a cauldron block, ornullif none was registered (yet).static @Nullable CauldronFluidContentgetForFluid(Fluid fluid) Get the cauldron fluid content for a fluid, ornullif no cauldron was registered for that fluid (yet).static CauldronFluidContentregisterCauldron(Block block, Fluid fluid, long amountPerLevel, @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.
-
Field Details
-
block
Block of the cauldron. -
fluid
Fluid stored inside the cauldron. -
amountPerLevel
public final long amountPerLevelAmount in droplets for each level oflevelProperty. -
maxLevel
public final int maxLevelMaximum level forlevelProperty.1iflevelPropertyis null, otherwise a number>= 1. The minimum level is always 1. -
levelProperty
Property storing the level of the cauldron. If it's null, only one level is possible.
-
-
Method Details
-
getForBlock
Get the cauldron fluid content for a cauldron block, ornullif none was registered (yet). -
getForFluid
Get the cauldron fluid content for a fluid, ornullif 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.nullif the cauldron only has one level.
-
currentLevel
Return the current level of the cauldron given its block state, or 0 if it's an empty cauldron.
-