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
levelProperty
isnull
, thenmaxLevel = 1
, and there is only one level. Otherwise, the levels are all the integer values between1
andmaxLevel
(included). amountPerLevel
defines how much fluid (in droplets) there is in one level of the cauldron.
-
Field Summary
Modifier and TypeFieldDescriptionfinal long
Amount in droplets for each level oflevelProperty
.final Block
Block of the cauldron.final Fluid
Fluid stored inside the cauldron.final @Nullable IntProperty
Property storing the level of the cauldron.final int
Maximum level forlevelProperty
. -
Method Summary
Modifier and TypeMethodDescriptionint
currentLevel
(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
(Block block) Get the cauldron fluid content for a cauldron block, ornull
if none was registered (yet).static @Nullable CauldronFluidContent
getForFluid
(Fluid fluid) Get the cauldron fluid content for a fluid, ornull
if no cauldron was registered for that fluid (yet).static CauldronFluidContent
registerCauldron
(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
.1
iflevelProperty
is 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, ornull
if none was registered (yet). -
getForFluid
Get the cauldron fluid content for a fluid, ornull
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
Return the current level of the cauldron given its block state, or 0 if it's an empty cauldron.
-