Class SimpleFluidRenderHandler
java.lang.Object
net.fabricmc.fabric.api.client.render.fluid.v1.SimpleFluidRenderHandler
- All Implemented Interfaces:
FluidRenderHandler
A simple fluid render handler that uses and loads sprites given by their
identifiers. Most fluids don't need more than this. In fact, if a fluid just
needs the vanilla water texture with a custom color,
coloredWater(int)
can be used to easily create a fluid render handler for that.
Note that it's assumed that the fluid textures are assumed to be registered to the blocks sprite atlas. If they are not, you have to manually register the fluid textures. The "fabric-textures" API may come in handy for that.
-
Field Summary
Modifier and TypeFieldDescriptionprotected final net.minecraft.util.Identifier
static final net.minecraft.util.Identifier
The vanilla flowing lava texture identifier.static final net.minecraft.util.Identifier
The vanilla still lava texture identifier.protected final net.minecraft.util.Identifier
protected final net.minecraft.client.texture.Sprite[]
protected final net.minecraft.util.Identifier
protected final int
static final net.minecraft.util.Identifier
The vanilla flowing water texture identifier.static final net.minecraft.util.Identifier
The vanilla water overlay texture identifier.static final net.minecraft.util.Identifier
The vanilla still water texture identifier. -
Constructor Summary
ConstructorDescriptionSimpleFluidRenderHandler
(net.minecraft.util.Identifier stillTexture, net.minecraft.util.Identifier flowingTexture) Creates a fluid render handler without an overlay texture and no tint.SimpleFluidRenderHandler
(net.minecraft.util.Identifier stillTexture, net.minecraft.util.Identifier flowingTexture, int tint) Creates a fluid render handler without an overlay texture and a custom, fixed tint.SimpleFluidRenderHandler
(net.minecraft.util.Identifier stillTexture, net.minecraft.util.Identifier flowingTexture, @Nullable net.minecraft.util.Identifier overlayTexture, int tint) Creates a fluid render handler with an overlay texture and a custom, fixed tint.SimpleFluidRenderHandler
(net.minecraft.util.Identifier stillTexture, net.minecraft.util.Identifier flowingTexture, net.minecraft.util.Identifier overlayTexture) Creates a fluid render handler with an overlay texture and no tint. -
Method Summary
Modifier and TypeMethodDescriptionstatic SimpleFluidRenderHandler
coloredWater
(int tint) Creates a fluid render handler that uses the vanilla water texture with a fixed, custom color.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.void
reloadTextures
(net.minecraft.client.texture.SpriteAtlasTexture textureAtlas) Look up your Fluid's sprites from the texture atlas.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandler
renderFluid
-
Field Details
-
WATER_STILL
public static final net.minecraft.util.Identifier WATER_STILLThe vanilla still water texture identifier. -
WATER_FLOWING
public static final net.minecraft.util.Identifier WATER_FLOWINGThe vanilla flowing water texture identifier. -
WATER_OVERLAY
public static final net.minecraft.util.Identifier WATER_OVERLAYThe vanilla water overlay texture identifier. -
LAVA_STILL
public static final net.minecraft.util.Identifier LAVA_STILLThe vanilla still lava texture identifier. -
LAVA_FLOWING
public static final net.minecraft.util.Identifier LAVA_FLOWINGThe vanilla flowing lava texture identifier. -
stillTexture
protected final net.minecraft.util.Identifier stillTexture -
flowingTexture
protected final net.minecraft.util.Identifier flowingTexture -
overlayTexture
protected final net.minecraft.util.Identifier overlayTexture -
sprites
protected final net.minecraft.client.texture.Sprite[] sprites -
tint
protected final int tint
-
-
Constructor Details
-
SimpleFluidRenderHandler
public SimpleFluidRenderHandler(net.minecraft.util.Identifier stillTexture, net.minecraft.util.Identifier flowingTexture, @Nullable @Nullable net.minecraft.util.Identifier overlayTexture, int tint) Creates a fluid render handler with an overlay texture and a custom, fixed tint.- Parameters:
stillTexture
- The texture for still fluid.flowingTexture
- The texture for flowing/falling fluid.overlayTexture
- The texture behind glass, leaves and other registered transparent blocks.tint
- The fluid color RGB. Alpha is ignored.
-
SimpleFluidRenderHandler
public SimpleFluidRenderHandler(net.minecraft.util.Identifier stillTexture, net.minecraft.util.Identifier flowingTexture, net.minecraft.util.Identifier overlayTexture) Creates a fluid render handler with an overlay texture and no tint.- Parameters:
stillTexture
- The texture for still fluid.flowingTexture
- The texture for flowing/falling fluid.overlayTexture
- The texture behind glass, leaves and other registered transparent blocks.
-
SimpleFluidRenderHandler
public SimpleFluidRenderHandler(net.minecraft.util.Identifier stillTexture, net.minecraft.util.Identifier flowingTexture, int tint) Creates a fluid render handler without an overlay texture and a custom, fixed tint.- Parameters:
stillTexture
- The texture for still fluid.flowingTexture
- The texture for flowing/falling fluid.tint
- The fluid color RGB. Alpha is ignored.
-
SimpleFluidRenderHandler
public SimpleFluidRenderHandler(net.minecraft.util.Identifier stillTexture, net.minecraft.util.Identifier flowingTexture) Creates a fluid render handler without an overlay texture and no tint.- Parameters:
stillTexture
- The texture for still fluid.flowingTexture
- The texture for flowing/falling fluid.
-
-
Method Details
-
coloredWater
Creates a fluid render handler that uses the vanilla water texture with a fixed, custom color.- Parameters:
tint
- The fluid color RGB. Alpha is ignored.- See Also:
-
getFluidSprites
public 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 overrideFluidRenderHandler.reloadTextures(net.minecraft.client.texture.SpriteAtlasTexture)
to reload your fluid sprites.The "fabric-textures" module contains sprite rendering facilities, which may come in handy here.
- Specified by:
getFluidSprites
in interfaceFluidRenderHandler
- 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.
-
reloadTextures
public 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.
- Specified by:
reloadTextures
in interfaceFluidRenderHandler
- Parameters:
textureAtlas
- The blocks texture atlas, provided for convenience.
-
getFluidColor
public 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!
- Specified by:
getFluidColor
in interfaceFluidRenderHandler
- 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.
-