aboutsummaryrefslogblamecommitdiff
path: root/src/main/java/org/chrisoft/trashyaddon/mixin/meteorclient/PostProcessShadersMixin.java
blob: 565e670676fad167606f6fecdd32bfe795b92af9 (plain) (tree)








































                                                                                                                                           
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();
            }
    }
}