Interface FluidRenderHandler
- All Known Implementing Classes:
SimpleFluidRenderHandler
public interface FluidRenderHandler
Interface for handling the rendering of a FluidState.
-
Method Summary
Modifier and TypeMethodDescriptiondefault int
getFluidColor
(@Nullable net.minecraft.world.BlockRenderView view, @Nullable net.minecraft.util.math.BlockPos pos, net.minecraft.fluid.FluidState state) Get the tint color for a fluid being rendered at a given position.net.minecraft.client.texture.Sprite[]
getFluidSprites
(@Nullable net.minecraft.world.BlockRenderView view, @Nullable net.minecraft.util.math.BlockPos pos, net.minecraft.fluid.FluidState state) Get the sprites for a fluid being rendered at a given position.default void
reloadTextures
(net.minecraft.client.texture.SpriteAtlasTexture textureAtlas) Look up your Fluid's sprites from the texture atlas.default boolean
renderFluid
(net.minecraft.util.math.BlockPos pos, net.minecraft.world.BlockRenderView world, net.minecraft.client.render.VertexConsumer vertexConsumer, net.minecraft.block.BlockState blockState, net.minecraft.fluid.FluidState fluidState) Tessellate your fluid.
-
Method Details
-
getFluidSprites
net.minecraft.client.texture.Sprite[] getFluidSprites(@Nullable @Nullable net.minecraft.world.BlockRenderView view, @Nullable @Nullable net.minecraft.util.math.BlockPos pos, net.minecraft.fluid.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 overridereloadTextures(net.minecraft.client.texture.SpriteAtlasTexture)
to reload your fluid sprites.The "fabric-textures" module contains sprite rendering facilities, which may come in handy here.
- Parameters:
view
- The world view pertaining to the fluid. May be null!pos
- The position of the fluid in the world. 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 @Nullable net.minecraft.world.BlockRenderView view, @Nullable @Nullable net.minecraft.util.math.BlockPos pos, net.minecraft.fluid.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:
view
- The world view pertaining to the fluid. May be null!pos
- The position of the fluid in the world. May be null!state
- The current state of the fluid.- Returns:
- The tint color of the fluid.
-
renderFluid
default boolean renderFluid(net.minecraft.util.math.BlockPos pos, net.minecraft.world.BlockRenderView world, net.minecraft.client.render.VertexConsumer vertexConsumer, net.minecraft.block.BlockState blockState, net.minecraft.fluid.FluidState fluidState) Tessellate your fluid. This method will be invoked before the default fluid renderer. By default it will call the default fluid renderer. CallFluidRenderHandler.super.renderFluid
if you want to render over the default fluid renderer.Note that this method must *only* return
true
if at least one face is tessellated. If no faces are tessellated this method must returnfalse
.- Parameters:
pos
- The position in the world, of the fluid to render.world
- The world the fluid is invertexConsumer
- The vertex consumer to tessellate the fluid in.blockState
- The block state being rendered.fluidState
- The fluid state being rendered.- Returns:
- Whether anything is tessellated.
-
reloadTextures
default void reloadTextures(net.minecraft.client.texture.SpriteAtlasTexture textureAtlas) 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:
textureAtlas
- The blocks texture atlas, provided for convenience.
-