-
Notifications
You must be signed in to change notification settings - Fork 424
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fluid rendering fixes - Fix default overlay block check using TransparentBlock instead of TranslucentBlock - Fix setBlockTransparency/isBlockTransparent not being thread-safe - Reuse the same render handler objects for water and lava * Fix implementation issues - Fix custom geometry being buffered twice if FluidRenderHandler#renderFluid is invoked directly - Fix calling FluidRenderHandler.super.renderFluid not using passed arguments to calculate color - Fix calling FluidRenderHandler.super.renderFluid more than once producing incorrect geometry - Fix fluids with no handler never receiving water overlay instead of using default behavior * Add way to render fluid with non-vanilla default - Fix testmod
- Loading branch information
1 parent
6dfc9a7
commit e761c66
Showing
8 changed files
with
263 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...ids-v1/src/client/java/net/fabricmc/fabric/api/client/render/fluid/v1/FluidRendering.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.fabricmc.fabric.api.client.render.fluid.v1; | ||
|
||
import net.minecraft.block.BlockState; | ||
import net.minecraft.client.render.VertexConsumer; | ||
import net.minecraft.client.render.block.FluidRenderer; | ||
import net.minecraft.fluid.FluidState; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.BlockRenderView; | ||
|
||
import net.fabricmc.fabric.impl.client.rendering.fluid.FluidRenderingImpl; | ||
|
||
/** | ||
* A class containing some utilities for rendering fluids. | ||
*/ | ||
public final class FluidRendering { | ||
private FluidRendering() { | ||
} | ||
|
||
/** | ||
* Renders a fluid using the given handler, default renderer, and context. Internally, this just invokes | ||
* {@link FluidRenderHandler#renderFluid}, but the passed default renderer is invoked instead of the vanilla | ||
* renderer whenever the handler requests default geometry to be rendered. | ||
* | ||
* @param handler the render handler to invoke {@link FluidRenderHandler#renderFluid} on | ||
* @param world the world | ||
* @param pos the pos | ||
* @param vertexConsumer the vertex consumer | ||
* @param blockState the block state | ||
* @param fluidState the fluid state | ||
* @param defaultRenderer the renderer to use whenever the handler requests default geometry | ||
*/ | ||
public static void render(FluidRenderHandler handler, BlockRenderView world, BlockPos pos, VertexConsumer vertexConsumer, BlockState blockState, FluidState fluidState, DefaultRenderer defaultRenderer) { | ||
FluidRenderingImpl.render(handler, world, pos, vertexConsumer, blockState, fluidState, defaultRenderer); | ||
} | ||
|
||
public interface DefaultRenderer { | ||
/** | ||
* Render the default geometry when it is requested by {@link FluidRenderHandler#renderFluid}. The default | ||
* implementation invokes the vanilla renderer. Calling {@link FluidRenderer#render} directly is not supported | ||
* but using {@code DefaultRenderer.super.render} is supported. Note that the parameter values passed to this | ||
* call are provided by the render handler, meaning they are not necessarily the same as those provided to the | ||
* initial rendering call. As per the documentation of {@link FluidRenderHandler#renderFluid}, a new handler | ||
* should not be retrieved and only the passed one should be used. | ||
* | ||
* @param handler the handler that {@link FluidRenderHandler#renderFluid} was invoked on | ||
* @param world the world | ||
* @param pos the pos | ||
* @param vertexConsumer the vertex consumer | ||
* @param blockState the block state | ||
* @param fluidState the fluid state | ||
*/ | ||
default void render(FluidRenderHandler handler, BlockRenderView world, BlockPos pos, VertexConsumer vertexConsumer, BlockState blockState, FluidState fluidState) { | ||
FluidRenderingImpl.renderVanillaDefault(handler, world, pos, vertexConsumer, blockState, fluidState); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.