Skip to content

Commit

Permalink
fix optifine compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
fayer3 committed Sep 15, 2024
1 parent 7ee2cdd commit 9e49613
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,16 @@ public VRTextureTarget(String name, int width, int height, boolean usedepth, boo
RenderSystem.assertOnRenderThreadOrInit();
((RenderTargetExtension) this).vivecraft$setTextid(texid);
((RenderTargetExtension) this).vivecraft$isLinearFilter(linearFilter);
((RenderTargetExtension) this).vivecraft$setUseStencil(useStencil);
this.resize(width, height, onMac);
if (useStencil) {
Xplat.enableRenderTargetStencil(this);

// need to set this first, because the forge/neoforge stencil enabled does a resize
this.viewWidth = width;
this.viewHeight = height;

if (useStencil && !Xplat.enableRenderTargetStencil(this)) {
// use our stencil only if the modloader doesn't support it
((RenderTargetExtension) this).vivecraft$setUseStencil(true);
}
this.resize(width, height, onMac);
this.setClearColor(0, 0, 0, 0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,11 +488,11 @@ public void setupRenderConfiguration() throws Exception {
Tuple<Integer, Integer> cameraSize = getCameraTextureSize(eyeFBWidth, eyeFBHeight);

// main render target
((RenderTargetExtension) WorldRenderPass.stereoXR.target).vivecraft$setUseStencil(dataholder.vrSettings.vrUseStencil);
WorldRenderPass.stereoXR.resize(eyeFBWidth, eyeFBHeight);
if (dataholder.vrSettings.vrUseStencil) {
Xplat.enableRenderTargetStencil(WorldRenderPass.stereoXR.target);
((RenderTargetExtension) WorldRenderPass.stereoXR.target)
.vivecraft$setUseStencil(!Xplat.enableRenderTargetStencil(WorldRenderPass.stereoXR.target));
}
WorldRenderPass.stereoXR.resize(eyeFBWidth, eyeFBHeight);
if (dataholder.vrSettings.useFsaa) {
this.fsaaFirstPassResultFBO.resize(eyew, eyeFBHeight, Minecraft.ON_OSX);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.vivecraft.mixin.client_vr.renderer;


import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Axis;
Expand Down Expand Up @@ -529,13 +531,13 @@ public abstract class GameRendererVRMixin
}
}

@ModifyVariable(at = @At(value = "STORE", ordinal = 1), ordinal = 4, method = "renderLevel")
public float vivecraft$reduceNauseaAffect(float oldVal) {
@WrapOperation(at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Mth;lerp(FFF)F"), method = "renderLevel")
public float vivecraft$reduceNauseaAffect(float partialTick, float oldVal, float newVal, Operation<Float> original) {
if (!RenderPassType.isVanilla()) {
// scales down the effect from (1,0.65) to (1,0.9)
return 1f - (1f - oldVal) * 0.25f;
return original.call(partialTick, oldVal, newVal) * 0.4F;
} else {
return oldVal;
return original.call(partialTick, oldVal, newVal);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.vivecraft.mod_compat_vr.optifine.mixin;

import com.llamalad7.mixinextras.sugar.Local;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Camera;
import net.minecraft.client.Minecraft;
Expand Down Expand Up @@ -48,7 +49,7 @@ public static void updateActiveRenderInfo(Camera activeRenderInfo, Minecraft mc,
}

@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getInstance()Lnet/minecraft/client/Minecraft;", remap = true), method = "renderShadowMap", remap = false, cancellable = true)
private static void vivecraft$shadowsOnlyOnce(GameRenderer gameRenderer, Camera activeRenderInfo, int pass, float partialTicks, long finishTimeNano, CallbackInfo ci) {
private static void vivecraft$shadowsOnlyOnce(CallbackInfo ci, @Local(argsOnly = true) Camera activeRenderInfo, @Local(argsOnly = true) float partialTicks) {
if (!RenderPassType.isVanilla() && ClientDataHolderVR.getInstance().currentPass != RenderPass.LEFT) {
if (vivecraft$setCameraShadow == null) {
try {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ minecraft_version=1.21
enabled_platforms=fabric,forge,neoforge

archives_base_name=vivecraft
mod_version=1.1.12-b1
mod_version=1.1.12-b2
maven_group=org.vivecraft

architectury_version=12.0.26
Expand Down

0 comments on commit 9e49613

Please sign in to comment.