/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  net.minecraft.class_322
 *  net.minecraft.class_324
 *  org.spongepowered.asm.mixin.Mixin
 *  org.spongepowered.asm.mixin.Unique
 *  org.spongepowered.asm.mixin.injection.At
 *  org.spongepowered.asm.mixin.injection.ModifyArg
 */
package meteordevelopment.meteorclient.mixin;

import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.world.Ambience;
import net.minecraft.class_322;
import net.minecraft.class_324;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;

@Mixin(value={class_324.class})
public abstract class BlockColorsMixin {
    @ModifyArg(method={"method_1689"}, at=@At(value="INVOKE", target="Lnet/minecraft/class_324;method_1690(Lnet/minecraft/class_322;[Lnet/minecraft/class_2248;)V", ordinal=3), index=0)
    private static class_322 modifySpruceLeavesColor(class_322 provider) {
        return (state, world, pos, tintIndex) -> BlockColorsMixin.getModifiedColor(-10380959);
    }

    @ModifyArg(method={"method_1689"}, at=@At(value="INVOKE", target="Lnet/minecraft/class_324;method_1690(Lnet/minecraft/class_322;[Lnet/minecraft/class_2248;)V", ordinal=4), index=0)
    private static class_322 modifyBirchLeavesColor(class_322 provider) {
        return (state, world, pos, tintIndex) -> BlockColorsMixin.getModifiedColor(-8345771);
    }

    @Unique
    private static int getModifiedColor(int original) {
        if (Modules.get() == null) {
            return original;
        }
        Ambience ambience = Modules.get().get(Ambience.class);
        if (ambience.isActive() && ambience.customFoliageColor.get().booleanValue()) {
            return ambience.foliageColor.get().getPacked();
        }
        return original;
    }
}

