From cbd90a07f317e276bb57b1a1057f0ef9594f374d Mon Sep 17 00:00:00 2001 From: Asek3 <64613894+Asek3@users.noreply.github.com> Date: Sat, 10 Feb 2024 22:42:57 +0200 Subject: [PATCH] Correct behaviour for coloring modded fluids Fixes #11 --- .../client/render/pipeline/FluidRenderer.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main/java/me/jellysquid/mods/sodium/client/render/pipeline/FluidRenderer.java b/src/main/java/me/jellysquid/mods/sodium/client/render/pipeline/FluidRenderer.java index 1cadf6b5c..ca011e735 100644 --- a/src/main/java/me/jellysquid/mods/sodium/client/render/pipeline/FluidRenderer.java +++ b/src/main/java/me/jellysquid/mods/sodium/client/render/pipeline/FluidRenderer.java @@ -40,8 +40,10 @@ import java.util.Objects; public class FluidRenderer { - - private static final float EPSILON = 0.001f; + + private static final float EPSILON = 0.001f; + + private static final IBlockColor FLUID_COLOR_PROVIDER = (state, world, pos, tintIndex) -> WorldUtil.getFluid(state).getColor(); private final BlockPos.MutableBlockPos scratchPos = new BlockPos.MutableBlockPos(); @@ -78,7 +80,7 @@ private boolean isFluidOccluded(IBlockAccess world, int x, int y, int z, EnumFac if (blockState.getMaterial().isOpaque()) { return fluid == adjFluid || blockState.isSideSolid(world,pos,dir); // fluidlogged or next to water, occlude sides that are solid or the same liquid - } + } return fluid == adjFluid; } @@ -310,7 +312,7 @@ public boolean render(IBlockAccess world, IBlockState fluidState, BlockPos pos, TextureAtlasSprite oSprite = sprites[2]; if (oSprite != null) { - BlockPos adjPos = this.scratchPos.setPos(adjX, adjY, adjZ); + BlockPos adjPos = this.scratchPos.setPos(adjX, adjY, adjZ); IBlockState adjBlock = world.getBlockState(adjPos); if (adjBlock.getBlockFaceShape(world, adjPos, dir.getOpposite()) == net.minecraft.block.state.BlockFaceShape.SOLID) { @@ -334,7 +336,7 @@ public boolean render(IBlockAccess world, IBlockState fluidState, BlockPos pos, float br = dir.getAxis() == EnumFacing.Axis.Z ? 0.8F : 0.6F; ModelQuadFacing facing = ModelQuadFacing.fromDirection(dir); - + this.calculateQuadColors(quad, world, pos, lighter, dir, br, hc); this.flushQuad(buffers, quad, facing, false); @@ -363,8 +365,18 @@ private void calculateQuadColors(ModelQuadView quad, IBlockAccess world, BlockPo if (colorized) { IBlockState state = world.getBlockState(pos); IBlockColor colorProvider = ((BlockColorsExtended)this.vanillaBlockColors).getColorProvider(state); + boolean containsColoredQuad = false; if(colorProvider != null) { biomeColors = this.biomeColorBlender.getColors(colorProvider, world, state, pos, quad); + for(int color : biomeColors) { + if(color != 0xFFFFFF) { + containsColoredQuad = true; + break; + } + } + } + if(!containsColoredQuad) { + biomeColors = this.biomeColorBlender.getColors(FLUID_COLOR_PROVIDER, world, state, pos, quad); } }