/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.llamalad7.mixinextras.injector.ModifyExpressionValue
 *  net.minecraft.class_10055
 *  net.minecraft.class_11659
 *  net.minecraft.class_12079$class_10726
 *  net.minecraft.class_12079$class_12081
 *  net.minecraft.class_1297
 *  net.minecraft.class_1657
 *  net.minecraft.class_2960
 *  net.minecraft.class_4587
 *  net.minecraft.class_972
 *  org.spongepowered.asm.mixin.Mixin
 *  org.spongepowered.asm.mixin.injection.At
 */
package meteordevelopment.meteorclient.mixin;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import meteordevelopment.meteorclient.MeteorClient;
import meteordevelopment.meteorclient.mixininterface.IEntityRenderState;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.donut.CapeChanger;
import meteordevelopment.meteorclient.utils.network.Capes;
import net.minecraft.class_10055;
import net.minecraft.class_11659;
import net.minecraft.class_12079;
import net.minecraft.class_1297;
import net.minecraft.class_1657;
import net.minecraft.class_2960;
import net.minecraft.class_4587;
import net.minecraft.class_972;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(value={class_972.class})
public abstract class CapeFeatureRendererMixin {
    @ModifyExpressionValue(method={"method_4177(Lnet/minecraft/class_4587;Lnet/minecraft/class_11659;ILnet/minecraft/class_10055;FF)V"}, at={@At(value="INVOKE", target="Lnet/minecraft/class_8685;comp_1627()Lnet/minecraft/class_12079$class_12081;")})
    private class_12079.class_12081 modifyCapeTexture(class_12079.class_12081 original, class_4587 matrices, class_11659 entityRenderCommandQueue, int i, class_10055 state, float f, float g) {
        class_1297 class_12972 = ((IEntityRenderState)state).meteor$getEntity();
        if (class_12972 instanceof class_1657) {
            class_2960 id;
            class_1657 player = (class_1657)class_12972;
            if (MeteorClient.mc.field_1724 != null && player.method_5667().equals(MeteorClient.mc.field_1724.method_5667())) {
                class_2960 customId;
                CapeChanger capeChanger;
                CapeChanger capeChanger2 = capeChanger = Modules.get() != null ? Modules.get().get(CapeChanger.class) : null;
                if (capeChanger != null && capeChanger.isActive() && (customId = capeChanger.getCapeIdentifier()) != null) {
                    return new class_12079.class_10726(customId, customId);
                }
            }
            return (id = Capes.get(player)) == null ? original : new class_12079.class_10726(id, id);
        }
        return original;
    }
}

