/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.llamalad7.mixinextras.sugar.Local
 *  com.mojang.blaze3d.systems.RenderSystem
 *  com.mojang.blaze3d.textures.GpuTexture
 *  net.minecraft.class_1309
 *  net.minecraft.class_3695
 *  net.minecraft.class_765
 *  net.minecraft.class_9848
 *  org.spongepowered.asm.mixin.Final
 *  org.spongepowered.asm.mixin.Mixin
 *  org.spongepowered.asm.mixin.Shadow
 *  org.spongepowered.asm.mixin.injection.At
 *  org.spongepowered.asm.mixin.injection.At$Shift
 *  org.spongepowered.asm.mixin.injection.Inject
 *  org.spongepowered.asm.mixin.injection.callback.CallbackInfo
 *  org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable
 */
package meteordevelopment.meteorclient.mixin;

import com.llamalad7.mixinextras.sugar.Local;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.textures.GpuTexture;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.render.Fullbright;
import meteordevelopment.meteorclient.systems.modules.render.NoRender;
import meteordevelopment.meteorclient.systems.modules.render.Xray;
import net.minecraft.class_1309;
import net.minecraft.class_3695;
import net.minecraft.class_765;
import net.minecraft.class_9848;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
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={class_765.class})
public abstract class LightmapTextureManagerMixin {
    @Shadow
    @Final
    private GpuTexture field_57927;

    @Inject(method={"method_3313"}, at={@At(value="INVOKE", target="Lnet/minecraft/class_3695;method_15396(Ljava/lang/String;)V", shift=At.Shift.AFTER)}, cancellable=true)
    private void update$skip(float tickProgress, CallbackInfo ci, @Local class_3695 profiler) {
        if (Modules.get().get(Fullbright.class).getGamma() || Modules.get().isActive(Xray.class)) {
            RenderSystem.getDevice().createCommandEncoder().clearColorTexture(this.field_57927, class_9848.method_61324((int)255, (int)255, (int)255, (int)255));
            profiler.method_15407();
            ci.cancel();
        }
    }

    @Inject(method={"method_42596"}, at={@At(value="HEAD")}, cancellable=true)
    private void getDarknessFactor(class_1309 entity, float factor, float tickProgress, CallbackInfoReturnable<Float> info) {
        if (Modules.get().get(NoRender.class).noDarkness()) {
            info.setReturnValue((Object)Float.valueOf(0.0f));
        }
    }
}

