Skip to content

Commit 27e9b74

Browse files
Asek3IMS212
andcommitted
Do not apply modelview bobbing with shaders off
Co-Authored-By: IMS <[email protected]>
1 parent 9a0790f commit 27e9b74

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/main/java/net/coderbot/iris/mixin/MixinModelViewBobbing.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.coderbot.iris.mixin;
22

3+
import net.irisshaders.iris.api.v0.IrisApi;
34
import org.spongepowered.asm.mixin.Mixin;
45
import org.spongepowered.asm.mixin.Unique;
56
import org.spongepowered.asm.mixin.injection.At;
@@ -27,10 +28,20 @@ public class MixinModelViewBobbing {
2728
@Unique
2829
private Matrix4f bobbingEffectsModel;
2930

31+
@Unique
32+
private boolean areShadersOn;
33+
34+
@Inject(method = "renderLevel", at = @At("HEAD"))
35+
private void iris$saveShadersOn(float pGameRenderer0, long pLong1, PoseStack pPoseStack2, CallbackInfo ci) {
36+
areShadersOn = IrisApi.getInstance().isShaderPackInUse();
37+
}
38+
3039
@ModifyArg(method = "renderLevel", index = 0,
3140
at = @At(value = "INVOKE",
3241
target = "Lnet/minecraft/client/renderer/GameRenderer;bobHurt(Lcom/mojang/blaze3d/vertex/PoseStack;F)V"))
3342
private PoseStack iris$separateViewBobbing(PoseStack stack) {
43+
if (!areShadersOn) return stack;
44+
3445
stack.pushPose();
3546
stack.last().pose().setIdentity();
3647

@@ -43,6 +54,8 @@ public class MixinModelViewBobbing {
4354
slice = @Slice(from = @At(value = "INVOKE",
4455
target = "Lnet/minecraft/client/renderer/GameRenderer;bobHurt(Lcom/mojang/blaze3d/vertex/PoseStack;F)V")))
4556
private PoseStack.Pose iris$saveBobbing(PoseStack stack) {
57+
if (!areShadersOn) return stack.last();
58+
4659
bobbingEffectsModel = stack.last().pose().copy();
4760

4861
stack.popPose();
@@ -54,6 +67,8 @@ public class MixinModelViewBobbing {
5467
at = @At(value = "INVOKE",
5568
target = "Lnet/minecraft/client/renderer/GameRenderer;resetProjectionMatrix(Lcom/mojang/math/Matrix4f;)V"))
5669
private void iris$applyBobbingToModelView(float tickDelta, long limitTime, PoseStack matrix, CallbackInfo ci) {
70+
if (!areShadersOn) return;
71+
5772
matrix.last().pose().multiply(bobbingEffectsModel);
5873

5974
bobbingEffectsModel = null;

0 commit comments

Comments
 (0)