编辑

通过


BlockFluidContainerComponent Class

Extends

Represents the fluid container of a block in the world. Used with blocks like cauldrons.

Properties

fillLevel

fillLevel: number;

Relative fill level of the fluid container.

Type: number

Notes:

  • This property can't be edited in restricted-execution mode.

fluidColor

fluidColor: RGBA;

Custom color of the fluid in the container.

Type: RGBA

Notes:

  • This property can't be edited in restricted-execution mode.

Methods

addDye

addDye(dye: ItemType): void

Adds a dye to the fluid. The dye color is combined with any existing custom color.

Parameters

Notes:

  • This function can't be called in restricted-execution mode.
  • This function can throw errors.

getFluidType

getFluidType(): FluidType

Gets the current fluid type in the container.

Returns FluidType

Notes:

  • This function can't be called in restricted-execution mode.
  • This function can throw errors.

setFluidType

setFluidType(fluidType: FluidType): void

Sets the current fluid type in the container.

Parameters

Notes:

  • This function can't be called in restricted-execution mode.
  • This function can throw errors.

setPotion

setPotion(itemStack: ItemStack): void

Sets a potion item in the container. Changes the container's fluid type to potion.

Parameters

Notes:

  • This function can't be called in restricted-execution mode.
  • This function can throw errors.

Constants

componentId

static read-only componentId = "minecraft:fluid_container";

Type: string