From f8ed5df41defc1850d5443969ebde7e8f85fa191 Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Sat, 8 Jan 2022 17:42:32 -0800 Subject: [PATCH 1/2] Update changelog --- changelog.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/changelog.txt b/changelog.txt index 5efc1aa0b..ccd0e4240 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,13 @@ +0.5.1: +Fixes + - Fix crash on resource reload with backend off + - Fix artifacts while using Optifine shaders + - Fix crash when trying to access biomes in a VirtualRenderWorld +Technical/API + - Refactor instance renderer registration to separate client and server logic (thanks Pepper!) + - VirtualRenderWorlds now have a "biomeOffset" field which gets added when looking up biomes + - Added GlStateTracker which hooks into GlStateManager to track changes in buffer, vertex array, and program bindings + 0.5.0a: Fixes - Address crash experienced by some users while rendering any tile. From e228427e72a16f5f05de4a83d311b919b484199b Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Mon, 10 Jan 2022 15:08:02 -0800 Subject: [PATCH 2/2] Sodium compatibility --- .../flywheel/mixin/LevelRendererMixin.java | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/jozufozu/flywheel/mixin/LevelRendererMixin.java b/src/main/java/com/jozufozu/flywheel/mixin/LevelRendererMixin.java index 026105389..6980e4608 100644 --- a/src/main/java/com/jozufozu/flywheel/mixin/LevelRendererMixin.java +++ b/src/main/java/com/jozufozu/flywheel/mixin/LevelRendererMixin.java @@ -3,7 +3,9 @@ package com.jozufozu.flywheel.mixin; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Group; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -33,7 +35,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.MinecraftForge; @OnlyIn(Dist.CLIENT) -@Mixin(LevelRenderer.class) +@Mixin(value = LevelRenderer.class, priority = 1001) // Higher priority to go after sodium public class LevelRendererMixin { @Shadow @@ -48,14 +50,33 @@ public class LevelRendererMixin { MinecraftForge.EVENT_BUS.post(new BeginFrameEvent(level, camera, frustum)); } + @Unique + private boolean flywheel$LayerRendered; + /** - * JUSTIFICATION: This method is called once per layer per frame. It allows us to perform - * layer-correct custom rendering. RenderWorldLast is not refined enough for rendering world objects. - * This should probably be a forge event. + * This only gets injected if renderChunkLayer is not Overwritten */ + @Group(name = "flywheel$renderLayer", min = 1, max = 2) @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/ShaderInstance;clear()V"), method = "renderChunkLayer") private void renderLayer(RenderType type, PoseStack stack, double camX, double camY, double camZ, Matrix4f p_172999_, CallbackInfo ci) { + flywheel$renderLayer(type, stack, camX, camY, camZ); + flywheel$LayerRendered = true; + } + /** + * This always gets injected. + */ + @Group(name = "flywheel$renderLayer") + @Inject(at = @At("TAIL"), method = "renderChunkLayer") + private void renderLayerSodium(RenderType type, PoseStack stack, double camX, double camY, double camZ, Matrix4f p_172999_, CallbackInfo ci) { + if (!flywheel$LayerRendered) { + flywheel$renderLayer(type, stack, camX, camY, camZ); + } + flywheel$LayerRendered = false; + } + + @Unique + private void flywheel$renderLayer(RenderType type, PoseStack stack, double camX, double camY, double camZ) { RenderBuffers renderBuffers = this.renderBuffers; GlStateTracker.State restoreState = GlStateTracker.getRestoreState();