aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/chrisoft/trashyaddon/mixin/meteorclient/PostProcessShadersMixin.java
blob: 565e670676fad167606f6fecdd32bfe795b92af9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package org.chrisoft.trashyaddon.mixin.meteorclient;

import com.mojang.logging.LogUtils;
import meteordevelopment.meteorclient.utils.render.postprocess.EntityShader;
import net.minecraft.client.render.VertexConsumerProvider;
import org.chrisoft.trashyaddon.misc.AddonPostProcessingShaders;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(value = meteordevelopment.meteorclient.utils.render.postprocess.PostProcessShaders.class, remap = false)
public abstract class PostProcessShadersMixin {
    @Inject(method = "beginRender()V", at = @At("TAIL"))
    private static void beginRender(CallbackInfo __) {
        for (EntityShader es : AddonPostProcessingShaders.entityShaders)
            es.beginRender();
    }

    @Inject(method = "endRender()V", at = @At("TAIL"))
    private static void endRender(CallbackInfo __) {
        for (EntityShader es : AddonPostProcessingShaders.entityShaders)
            es.endRender();
    }

    @Inject(method = "onResized(II)V", at = @At("TAIL"))
    private static void onResized(int width, int height, CallbackInfo __) {
        for (EntityShader es : AddonPostProcessingShaders.entityShaders)
            es.onResized(width, height);
    }

    @Inject(method = "isCustom(Lnet/minecraft/client/render/VertexConsumerProvider;)Z", at = @At("HEAD"), cancellable = true, remap = true)
    private static void isCustom(VertexConsumerProvider vcp, CallbackInfoReturnable<Boolean> info) {
        for (EntityShader es : AddonPostProcessingShaders.entityShaders)
            if (vcp == es.vertexConsumerProvider) {
                info.setReturnValue(true);
                info.cancel();
            }
    }
}