Skip to content

Commit

Permalink
Fix fluid rendering occlusion check
Browse files Browse the repository at this point in the history
Thanks cortex and moul
  • Loading branch information
IMS212 committed Apr 12, 2024
1 parent 52fbc41 commit bc38d56
Showing 1 changed file with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,12 @@ public DefaultFluidRenderer(ColorProviderRegistry colorProviderRegistry, LightPi
}

private boolean isFluidOccluded(BlockAndTintGetter world, int x, int y, int z, Direction dir, Fluid fluid) {
BlockPos pos = this.scratchPos.set(x, y, z);
BlockState blockState = world.getBlockState(pos);
BlockPos adjPos = this.scratchPos.set(x + dir.getStepX(), y + dir.getStepY(), z + dir.getStepZ());

if (blockState.canOcclude()) {
return world.getFluidState(adjPos).getType().isSame(fluid) || blockState.isFaceSturdy(world, pos, dir, SupportType.FULL);
var adjPos = this.scratchPos.set(x + dir.getStepX(), y + dir.getStepY(), z + dir.getStepZ());
BlockState blockState = world.getBlockState(adjPos);
if (blockState.getFluidState().getType().isSame(fluid)) {
return true;
}
return world.getFluidState(adjPos).getType().isSame(fluid);
return blockState.isFaceSturdy(world, adjPos, dir.getOpposite(), SupportType.FULL);
}

private boolean isSideExposed(BlockAndTintGetter world, int x, int y, int z, Direction dir, float height) {
Expand All @@ -89,10 +87,7 @@ private boolean isSideExposed(BlockAndTintGetter world, int x, int y, int z, Dir
VoxelShape shape = blockState.getOcclusionShape(world, pos);

// Hoist these checks to avoid allocating the shape below
if (shape == Shapes.block()) {
// The top face always be inset, so if the shape above is a full cube it can't possibly occlude
return dir == Direction.UP;
} else if (shape.isEmpty()) {
if (shape.isEmpty()) {
return true;
}

Expand Down

0 comments on commit bc38d56

Please sign in to comment.