package com.r3944realms.modernlifepatch.datagen.provider;

import com.r3944realms.modernlifepatch.ModernLifePatch;
import com.r3944realms.modernlifepatch.content.item.ModItems;
import net.minecraft.data.PackOutput;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraftforge.client.model.generators.ItemModelProvider;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.registries.ForgeRegistries;

import java.util.Objects;

public class ModItemModelProvider extends ItemModelProvider {
    public static final String GENERATED = "item/generated";
    public ModItemModelProvider(PackOutput packOutput, ExistingFileHelper existingFileHelper) {
        super(packOutput, ModernLifePatch.MOD_ID, existingFileHelper);
    }

    @Override
    protected void registerModels() {
        itemGeneratedModel(ModItems.MIRROR_ITEM.get(), new ResourceLocation(ModernLifePatch.MOD_ID, "item/mirror_item"));
        itemGeneratedModel(ModItems.TALL_MIRROR_ITEM.get(), new ResourceLocation(ModernLifePatch.MOD_ID, "item/tall_mirror_item"));
        itemGeneratedModel(ModItems.LARGE_MIRROR_ITEM.get(), new ResourceLocation(ModernLifePatch.MOD_ID, "item/large_mirror_item"));
        itemGeneratedModel(ModItems.MASSIVE_MIRROR_ITEM.get(), new ResourceLocation(ModernLifePatch.MOD_ID, "item/massive_mirror_item"));
    }

    public void itemGeneratedModel(Item item, ResourceLocation texture) {
        withExistingParent(itemName(item), GENERATED).texture("layer0", texture);
    }

    private String itemName(Item item) {
        return Objects.requireNonNull(ForgeRegistries.ITEMS.getKey(item)).getPath();
    }

    public ResourceLocation resourceItem(String path) {
        return new ResourceLocation(ModernLifePatch.MOD_ID, "item/" + path);
    }

}
