Interface FluidRenderHandler

All Known Implementing Classes:
SimpleFluidRenderHandler

public interface FluidRenderHandler
Interface for handling the rendering of a FluidState.
  • Method Summary

    Modifier and Type
    Method
    Description
    default int
    getFluidColor(@Nullable net.minecraft.client.renderer.block.BlockAndTintGetter level, @Nullable net.minecraft.core.BlockPos pos, net.minecraft.world.level.material.FluidState state)
    Get the tint color for a fluid being rendered at a given position.
    net.minecraft.client.renderer.texture.TextureAtlasSprite[]
    getFluidSprites(@Nullable net.minecraft.client.renderer.block.BlockAndTintGetter level, @Nullable net.minecraft.core.BlockPos pos, net.minecraft.world.level.material.FluidState state)
    Get the sprites for a fluid being rendered at a given position.
    default net.minecraft.client.renderer.chunk.ChunkSectionLayer
    reloadTextures(net.minecraft.client.resources.model.sprite.SpriteGetter spriteGetter)
    Look up your Fluid's sprites from the texture atlas.
    default void
    renderFluid(net.minecraft.core.BlockPos pos, net.minecraft.client.renderer.block.BlockAndTintGetter level, com.mojang.blaze3d.vertex.VertexConsumer vertexConsumer, net.minecraft.world.level.block.state.BlockState blockState, net.minecraft.world.level.material.FluidState fluidState)
    Tessellate your fluid.
  • Method Details

    • getFluidSprites

      net.minecraft.client.renderer.texture.TextureAtlasSprite[] getFluidSprites(@Nullable net.minecraft.client.renderer.block.BlockAndTintGetter level, @Nullable net.minecraft.core.BlockPos pos, net.minecraft.world.level.material.FluidState state)
      Get the sprites for a fluid being rendered at a given position. For optimal performance, the sprites should be loaded as part of a resource reload and *not* looked up every time the method is called! You likely want to override reloadTextures(SpriteGetter) to reload your fluid sprites.

      The "fabric-textures" module contains sprite rendering facilities, which may come in handy here.

      Parameters:
      level - The level view pertaining to the fluid. May be null!
      pos - The position of the fluid in the level. May be null!
      state - The current state of the fluid.
      Returns:
      An array of size two or more: the first entry contains the "still" sprite, while the second entry contains the "flowing" sprite. If it contains a third sprite, that sprite is used as overlay behind glass and leaves.
    • getFluidColor

      default int getFluidColor(@Nullable net.minecraft.client.renderer.block.BlockAndTintGetter level, @Nullable net.minecraft.core.BlockPos pos, net.minecraft.world.level.material.FluidState state)
      Get the tint color for a fluid being rendered at a given position.

      Note: As of right now, our hook cannot handle setting a custom alpha tint here - as such, it must be contained in the texture itself!

      Parameters:
      level - The level view pertaining to the fluid. May be null!
      pos - The position of the fluid in the level. May be null!
      state - The current state of the fluid.
      Returns:
      The tint color of the fluid.
    • renderFluid

      default void renderFluid(net.minecraft.core.BlockPos pos, net.minecraft.client.renderer.block.BlockAndTintGetter level, com.mojang.blaze3d.vertex.VertexConsumer vertexConsumer, net.minecraft.world.level.block.state.BlockState blockState, net.minecraft.world.level.material.FluidState fluidState)
      Tessellate your fluid. By default, this method will call the default fluid renderer. Call FluidRenderHandler.super.renderFluid if you want to render over the default fluid renderer. This is the intended way to render default geometry; calling LiquidBlockRenderer.tesselate(BlockAndTintGetter, BlockPos, VertexConsumer, BlockState, FluidState) is not supported. When rendering default geometry, the current handler will be used instead of looking up a new one for the passed fluid state.
      Parameters:
      pos - The position in the level, of the fluid to render.
      level - The level the fluid is in
      vertexConsumer - The vertex consumer to tessellate the fluid in.
      blockState - The block state being rendered.
      fluidState - The fluid state being rendered.
    • reloadTextures

      default net.minecraft.client.renderer.chunk.ChunkSectionLayer reloadTextures(net.minecraft.client.resources.model.sprite.SpriteGetter spriteGetter)
      Look up your Fluid's sprites from the texture atlas. Called when the fluid renderer reloads its textures. This is a convenient way of reloading and does not require an advanced resource manager reload listener.

      The "fabric-textures" module contains sprite rendering facilities, which may come in handy here.

      Parameters:
      spriteGetter - The SpriteGetter to look up sprites.
      Returns:
      A ChunkSectionLayer to indicate the transparency of the fluid.