/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  net.minecraft.class_12076
 *  net.minecraft.class_2874$class_12326
 *  net.minecraft.class_4184
 *  net.minecraft.class_638
 *  net.minecraft.class_9975
 *  org.joml.Vector4fc
 *  org.spongepowered.asm.mixin.Mixin
 *  org.spongepowered.asm.mixin.injection.At
 *  org.spongepowered.asm.mixin.injection.Inject
 *  org.spongepowered.asm.mixin.injection.ModifyArg
 *  org.spongepowered.asm.mixin.injection.callback.CallbackInfo
 */
package meteordevelopment.meteorclient.mixin;

import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.world.Ambience;
import net.minecraft.class_12076;
import net.minecraft.class_2874;
import net.minecraft.class_4184;
import net.minecraft.class_638;
import net.minecraft.class_9975;
import org.joml.Vector4fc;
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.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(value={class_9975.class})
public class SkyRenderingMixin {
    @Inject(method={"method_74926"}, at={@At(value="TAIL")})
    private void updateRenderState(class_638 world, float tickProgress, class_4184 camera, class_12076 state, CallbackInfo ci) {
        Ambience ambience = Modules.get().get(Ambience.class);
        if (!ambience.isActive()) {
            return;
        }
        if (ambience.endSky.get().booleanValue()) {
            state.field_64464 = class_2874.class_12326.field_64387;
        }
        if (ambience.customSkyColor.get().booleanValue()) {
            state.field_63097 = ambience.skyColor().getPacked();
        }
    }

    @ModifyArg(method={"method_62312"}, at=@At(value="INVOKE", target="Lnet/minecraft/class_11282;method_71106(Lorg/joml/Matrix4fc;Lorg/joml/Vector4fc;Lorg/joml/Vector3fc;Lorg/joml/Matrix4fc;)Lcom/mojang/blaze3d/buffers/GpuBufferSlice;"))
    private Vector4fc modifyEndSkyColor(Vector4fc original) {
        Ambience ambience = Modules.get().get(Ambience.class);
        if (ambience.isActive() && ambience.endSky.get().booleanValue() && ambience.customSkyColor.get().booleanValue()) {
            return ambience.skyColor().getVec4f();
        }
        return original;
    }
}

