Interface FluidVariantRenderHandler


@Experimental @Environment(CLIENT) public interface FluidVariantRenderHandler
Defines how fluid variants of a given Fluid should be displayed to clients. Register with FluidVariantRendering.register(net.minecraft.fluid.Fluid, net.fabricmc.fabric.api.transfer.v1.client.fluid.FluidVariantRenderHandler).

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.

  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    appendTooltip(FluidVariant fluidVariant, List<Text> tooltip, TooltipContext tooltipContext)
    Append additional tooltips to the passed list if additional information is contained in the fluid variant.
    default int
    getColor(FluidVariant fluidVariant, @Nullable BlockRenderView view, @Nullable BlockPos pos)
    Return the color to use when rendering the sprites of this fluid variant.
    default @Nullable Sprite[]
    getSprites(FluidVariant fluidVariant)
    Return an array of size at least 2 containing the sprites that should be used to render the passed fluid variant, for use in baked models, (block) entity renderers, or user interfaces.
  • Method Details

    • appendTooltip

      default void appendTooltip(FluidVariant fluidVariant, List<Text> tooltip, TooltipContext tooltipContext)
      Append additional tooltips to the passed list if additional information is contained in the fluid variant.

      The name of the fluid, and its identifier if the tooltip context is advanced, should not be appended. They are already added by FluidVariantRendering.getTooltip(net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant).

    • getSprites

      @Nullable default @Nullable Sprite[] getSprites(FluidVariant fluidVariant)
      Return an array of size at least 2 containing the sprites that should be used to render the passed fluid variant, for use in baked models, (block) entity renderers, or user interfaces. The first sprite in the array is the still sprite, and the second is the flowing sprite.

      Null may be returned if the fluid variant should not be rendered, but if an array is returned it must have at least two entries and they may not be null.

    • getColor

      default int getColor(FluidVariant fluidVariant, @Nullable @Nullable BlockRenderView view, @Nullable @Nullable BlockPos pos)
      Return the color to use when rendering the sprites of this fluid variant. Transparency (alpha) will generally be taken into account and should be specified as well.

      The world and position are optional context parameters and may be null. If they are null, this method must return a location-independent color. If they are provided, this method may return a color that depends on the location. For example, water returns the biome-dependent color if the context parameters are specified, or its default color if one of them is null.