mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-12-27 07:26:48 +01:00
Sodium compatibility
This commit is contained in:
parent
f8ed5df41d
commit
e228427e72
1 changed files with 25 additions and 4 deletions
|
@ -3,7 +3,9 @@ package com.jozufozu.flywheel.mixin;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
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.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Group;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
@ -33,7 +35,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@Mixin(LevelRenderer.class)
|
@Mixin(value = LevelRenderer.class, priority = 1001) // Higher priority to go after sodium
|
||||||
public class LevelRendererMixin {
|
public class LevelRendererMixin {
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
|
@ -48,14 +50,33 @@ public class LevelRendererMixin {
|
||||||
MinecraftForge.EVENT_BUS.post(new BeginFrameEvent(level, camera, frustum));
|
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
|
* This only gets injected if renderChunkLayer is not Overwritten
|
||||||
* layer-correct custom rendering. RenderWorldLast is not refined enough for rendering world objects.
|
|
||||||
* This should probably be a forge event.
|
|
||||||
*/
|
*/
|
||||||
|
@Group(name = "flywheel$renderLayer", min = 1, max = 2)
|
||||||
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/ShaderInstance;clear()V"), method = "renderChunkLayer")
|
@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) {
|
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;
|
RenderBuffers renderBuffers = this.renderBuffers;
|
||||||
|
|
||||||
GlStateTracker.State restoreState = GlStateTracker.getRestoreState();
|
GlStateTracker.State restoreState = GlStateTracker.getRestoreState();
|
||||||
|
|
Loading…
Reference in a new issue