Fabric API

Fabric API

106M Downloads

Feature request: custom liquid block renderer

FoxSamu opened this issue ยท 1 comments

commented

The fabric-rendering-fluid provides an easy and compatible way to assign custom textures to modded fluid blocks. However, when it comes to more customized implementations of fluid blocks, the builtin fluid renderer may not be enough.

As an example, I'll use the idea of a fluid that acts entirely upside down (there could be actual uses for that). The default FlowingFluid implementation does not work for this, so this needs a custom implementation of Fluid: UpwardsFlowingFluid. Implementing and registering the custom fluid block is not an issue, but the vanilla fluid renderer is not made to render fluid blocks upside down. Instead, we want a custom fluid renderer implementation to render the fluid upside down.

Currently, the fluid rendering API allows a modder to register a FluidRenderHandler for a custom fluid, which allows to select custom textures for a fluid (bypasses the hardcoded fluid textures in vanilla), or use a custom tint for the fluid:

FluidRenderHandlerRegistry.INSTANCE.register(ModFluids.STILL_FLUID, (level, pos, state) -> new TextureAtlasSprite[] {
    still,
    flow
});

FluidRenderHandlerRegistry.INSTANCE.register(ModFluids.FLOWING_FLUID, (level, pos, state) -> new TextureAtlasSprite[] {
    still,
    flow
});

This is the existing functionality of the API. I wanna propose a CustomFluidRenderer, which is called instead of the vanilla fluid renderer, as soon as the fluid it is registered for is rendered.

FluidRendererRegistry.INSTANCE.register(ModFluids.STILL_FLUID, ModFluidRenderer.INSTANCE);
FluidRendererRegistry.INSTANCE.register(ModFluids.FLOWING_FLUID, ModFluidRenderer.INSTANCE);

I somehow failed to clone and set up the Fabric API project locally, but I could make a PR as soon as that works for me. This works now, see #1687.

commented

Closing this as this is now a pull request: see #1687