/*
 * Anim Core mod
 *  Copyright (C)  2026  LeisureTimeDock
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

package top.leisuretimedock.animationcore.mixin;

import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import io.zershyan.sccore.animation.data.GenericAnimationData;
import io.zershyan.sccore.animation.register.AnimationRegistry;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import top.leisuretimedock.animationcore.animation.AnimationDataManager;
import top.leisuretimedock.animationcore.animation.LayerDataManager;

import java.util.LinkedHashMap;
import java.util.Map;

@Mixin(value = AnimationRegistry.class, remap = false)
public class MixinAnimationRegistry {
    @WrapMethod(
            method = "getAnimations"
    )
    private static @NotNull Map<ResourceLocation, GenericAnimationData> getAnimations(@NotNull Operation<Map<ResourceLocation, GenericAnimationData>> original) {
        Map<ResourceLocation, GenericAnimationData> wrap = new LinkedHashMap<>(original.call());
        wrap.putAll(AnimationDataManager.ANIMATIONS);
        return wrap;
    }

    @WrapMethod(
            method = "getLayers"
    )
    private static @NotNull Map<ResourceLocation, Integer> getLayers(@NotNull Operation<Map<ResourceLocation, Integer>> original) {
        Map<ResourceLocation, Integer> wrap = new LinkedHashMap<>(original.call());
        wrap.putAll(LayerDataManager.LAYERS);
        return wrap;
    }
}
