/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.llamalad7.mixinextras.injector.ModifyExpressionValue
 *  net.minecraft.class_758
 *  org.joml.Vector4f
 *  org.spongepowered.asm.mixin.Mixin
 *  org.spongepowered.asm.mixin.injection.At
 *  org.spongepowered.asm.mixin.injection.ModifyVariable
 */
package meteordevelopment.meteorclient.mixin;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.render.NoRender;
import meteordevelopment.meteorclient.systems.modules.world.Ambience;
import net.minecraft.class_758;
import org.joml.Vector4f;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;

@Mixin(value={class_758.class})
public abstract class FogRendererMixin {
    @ModifyVariable(method={"method_71110(Ljava/nio/ByteBuffer;ILorg/joml/Vector4f;FFFFFF)V"}, at=@At(value="HEAD"), argsOnly=true)
    private Vector4f modifyFogDistance(Vector4f original) {
        if (Modules.get() == null) {
            return original;
        }
        Ambience ambience = Modules.get().get(Ambience.class);
        if (ambience.isActive() && ambience.customFogColor.get().booleanValue()) {
            return ambience.fogColor.get().getVec4f();
        }
        return original;
    }

    @ModifyExpressionValue(method={"method_71109"}, at={@At(value="FIELD", target="Lnet/minecraft/class_758;field_54018:Z")})
    private boolean modifyFogEnabled(boolean original) {
        if (Modules.get() == null) {
            return original;
        }
        return original && !Modules.get().get(NoRender.class).noFog();
    }
}

