/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.mojang.blaze3d.pipeline.RenderPipeline
 *  com.mojang.blaze3d.systems.RenderPass
 *  net.minecraft.class_10860
 *  net.minecraft.class_10865
 *  org.lwjgl.opengl.GL11C
 *  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.Inject
 *  org.spongepowered.asm.mixin.injection.callback.CallbackInfo
 *  org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable
 */
package meteordevelopment.meteorclient.mixin;

import com.mojang.blaze3d.pipeline.RenderPipeline;
import com.mojang.blaze3d.systems.RenderPass;
import meteordevelopment.meteorclient.mixininterface.IGpuDevice;
import meteordevelopment.meteorclient.mixininterface.IRenderPipeline;
import net.minecraft.class_10860;
import net.minecraft.class_10865;
import org.lwjgl.opengl.GL11C;
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_10860.class})
public abstract class GlCommandEncoderMixin {
    @Shadow
    @Final
    private class_10865 field_57844;

    @Inject(method={"createRenderPass(Ljava/util/function/Supplier;Lcom/mojang/blaze3d/textures/GpuTextureView;Ljava/util/OptionalInt;Lcom/mojang/blaze3d/textures/GpuTextureView;Ljava/util/OptionalDouble;)Lcom/mojang/blaze3d/systems/RenderPass;"}, at={@At(value="RETURN")})
    private void createRenderPass$iGpuDevice(CallbackInfoReturnable<RenderPass> info) {
        ((IGpuDevice)this.field_57844).meteor$onCreateRenderPass((RenderPass)info.getReturnValue());
    }

    @Inject(method={"method_68356"}, at={@At(value="INVOKE", target="Lcom/mojang/blaze3d/opengl/GlStateManager;_polygonMode(II)V")})
    private void setPipelineAndApplyState$lineSmooth(RenderPipeline pipeline, CallbackInfo info) {
        if (((IRenderPipeline)pipeline).meteor$getLineSmooth()) {
            GL11C.glEnable((int)2848);
            GL11C.glLineWidth((float)1.0f);
        } else {
            GL11C.glDisable((int)2848);
        }
    }
}

