Skip to content

Commit

Permalink
Blur compat
Browse files Browse the repository at this point in the history
  • Loading branch information
Wyvest committed Jun 22, 2024
1 parent f769045 commit 1bcc706
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 0 deletions.
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ val modShade: Configuration by configurations.creating {

// Configures the output directory for when building from the `src/resources` directory.
sourceSets {
val dummy by creating
main {
compileClasspath += dummy.output
output.setResourcesDir(java.classesDirectory)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package cc.polyfrost.oneconfig.internal.gui.impl;

public class BlurHandlerImpl {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.polyfrost.colorsaturation.mixin;

import cc.polyfrost.oneconfig.internal.gui.impl.BlurHandlerImpl;
import cc.polyfrost.oneconfig.libs.universal.UMinecraft;
import org.polyfrost.colorsaturation.EntityRendererHook;
import org.spongepowered.asm.mixin.Dynamic;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Pseudo;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Pseudo
@Mixin(targets = "cc.polyfrost.oneconfig.internal.gui.impl.BlurHandlerImpl", remap = false)
public abstract class BlurHandlerImplMixin {

@Shadow abstract boolean isShaderActive();

@Dynamic("OneConfig")
@Redirect(method = "reloadBlur", at = @At(value = "INVOKE", target = "Lcc/polyfrost/oneconfig/internal/gui/impl/BlurHandlerImpl;isShaderActive()Z", ordinal = 0))
private boolean redirectShaderActive(BlurHandlerImpl a) { // works without any params in 0.7.11 but in 0.8 things got stricter
if (
//#if MC<=11202
net.minecraft.client.renderer.OpenGlHelper.shadersSupported
//#else
//$$ true
//#endif
&& ((EntityRendererHook) UMinecraft.getMinecraft().entityRenderer).colorSaturation$getSaturationShader() != null
) {
return false;
}
return isShaderActive();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.polyfrost.colorsaturation.mixin;

import cc.polyfrost.oneconfig.libs.universal.UMinecraft;
import net.minecraft.client.renderer.EntityRenderer;
import org.polyfrost.colorsaturation.EntityRendererHook;
import org.spongepowered.asm.mixin.Dynamic;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Pseudo;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Pseudo
@Mixin(targets = "com.tterrag.blur.Blur", remap = false)
public class BlurModMixin {
@Dynamic("Blur Mod")
@Redirect(method = "onGuiChange", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/EntityRenderer;isShaderActive()Z", ordinal = 0, remap = true), remap = false)
private boolean isShaderActive(EntityRenderer er) {
if (
//#if MC<=11202
net.minecraft.client.renderer.OpenGlHelper.shadersSupported
//#else
//$$ true
//#endif
&& ((EntityRendererHook) UMinecraft.getMinecraft().entityRenderer).colorSaturation$getSaturationShader() != null
) {
return false;
}
return er.isShaderActive();
}
}
2 changes: 2 additions & 0 deletions src/main/resources/mixins.colorsaturation.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"maxShiftBy": 5
},
"client": [
"BlurHandlerImplMixin",
"BlurModMixin",
"EntityRendererMixin",
"OptifineConfigMixin",
"ShaderGroupAccessor"
Expand Down

0 comments on commit 1bcc706

Please sign in to comment.