mirror of
https://github.com/FabricMC/fabric.git
synced 2024-11-27 10:05:35 -05:00
Fix After Translucent Render Event (#4155)
This commit is contained in:
parent
118941c0e0
commit
6e4c084dbc
2 changed files with 17 additions and 7 deletions
|
@ -17,6 +17,7 @@
|
|||
package net.fabricmc.fabric.mixin.client.rendering;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import org.joml.Matrix4f;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
@ -33,12 +34,14 @@ import net.minecraft.client.MinecraftClient;
|
|||
import net.minecraft.client.option.CloudRenderMode;
|
||||
import net.minecraft.client.render.BufferBuilderStorage;
|
||||
import net.minecraft.client.render.Camera;
|
||||
import net.minecraft.client.render.DefaultFramebufferSet;
|
||||
import net.minecraft.client.render.Fog;
|
||||
import net.minecraft.client.render.FrameGraphBuilder;
|
||||
import net.minecraft.client.render.Frustum;
|
||||
import net.minecraft.client.render.GameRenderer;
|
||||
import net.minecraft.client.render.LightmapTextureManager;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.RenderPass;
|
||||
import net.minecraft.client.render.RenderTickCounter;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.WorldRenderer;
|
||||
|
@ -63,6 +66,9 @@ public abstract class WorldRendererMixin {
|
|||
@Final
|
||||
@Shadow
|
||||
private MinecraftClient client;
|
||||
@Shadow
|
||||
@Final
|
||||
private DefaultFramebufferSet framebufferSet;
|
||||
@Unique private final WorldRenderContextImpl context = new WorldRenderContextImpl();
|
||||
|
||||
@Inject(method = "render", at = @At("HEAD"))
|
||||
|
@ -151,8 +157,11 @@ public abstract class WorldRendererMixin {
|
|||
}
|
||||
|
||||
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/GameOptions;getCloudRenderModeValue()Lnet/minecraft/client/option/CloudRenderMode;"))
|
||||
private void beforeClouds(CallbackInfo ci) {
|
||||
WorldRenderEvents.AFTER_TRANSLUCENT.invoker().afterTranslucent(context);
|
||||
private void beforeClouds(CallbackInfo ci, @Local FrameGraphBuilder frameGraphBuilder) {
|
||||
RenderPass afterTranslucentPass = frameGraphBuilder.createPass("afterTranslucent");
|
||||
framebufferSet.mainFramebuffer = afterTranslucentPass.transfer(framebufferSet.mainFramebuffer);
|
||||
|
||||
afterTranslucentPass.setRenderer(() -> WorldRenderEvents.AFTER_TRANSLUCENT.invoker().afterTranslucent(context));
|
||||
}
|
||||
|
||||
@Inject(method = "method_62214", at = @At("RETURN"))
|
||||
|
|
|
@ -34,6 +34,7 @@ import net.minecraft.util.math.Vec3d;
|
|||
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext;
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
|
||||
|
||||
public class WorldRenderEventsTests implements ClientModInitializer {
|
||||
private static boolean onBlockOutline(WorldRenderContext wrc, WorldRenderContext.BlockOutlineContext blockOutlineContext) {
|
||||
|
@ -59,7 +60,7 @@ public class WorldRenderEventsTests implements ClientModInitializer {
|
|||
}
|
||||
|
||||
/**
|
||||
* Renders a translucent box at (0, 100, 0).
|
||||
* Renders a translucent filled box at (0, 100, 0).
|
||||
*/
|
||||
private static void renderAfterTranslucent(WorldRenderContext context) {
|
||||
MatrixStack matrices = context.matrixStack();
|
||||
|
@ -75,7 +76,7 @@ public class WorldRenderEventsTests implements ClientModInitializer {
|
|||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
|
||||
VertexRendering.drawBox(matrices, buffer, 0, 100, 0, 1, 101, 1, 0, 1, 0, 0.5f);
|
||||
VertexRendering.drawFilledBox(matrices, buffer, 0, 100, 0, 1, 101, 1, 0, 1, 0, 0.5f);
|
||||
BufferRenderer.drawWithGlobalProgram(buffer.end());
|
||||
|
||||
matrices.pop();
|
||||
|
@ -85,8 +86,8 @@ public class WorldRenderEventsTests implements ClientModInitializer {
|
|||
@Override
|
||||
public void onInitializeClient() {
|
||||
// Renders a diamond block above diamond blocks when they are looked at.
|
||||
//WorldRenderEvents.BLOCK_OUTLINE.register(WorldRenderEventsTests::onBlockOutline);
|
||||
// Renders a translucent box at (0, 100, 0)
|
||||
//WorldRenderEvents.AFTER_TRANSLUCENT.register(WorldRenderEventsTests::renderAfterTranslucent);
|
||||
WorldRenderEvents.BLOCK_OUTLINE.register(WorldRenderEventsTests::onBlockOutline);
|
||||
// Renders a translucent filled box at (0, 100, 0)
|
||||
WorldRenderEvents.AFTER_TRANSLUCENT.register(WorldRenderEventsTests::renderAfterTranslucent);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue