package com.r3944realms.modernlifepatch.datagen;

import com.r3944realms.modernlifepatch.datagen.provider.*;
import com.r3944realms.modernlifepatch.utils.Enum.LanguageEnum;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.PackOutput;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.data.event.GatherDataEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

import java.util.concurrent.CompletableFuture;

import static com.r3944realms.modernlifepatch.ModernLifePatch.MOD_ID;

@Mod.EventBusSubscriber(modid = MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class DataGeneratorHandler {
    @SubscribeEvent
    public static void generatorDataEvent(GatherDataEvent event) {
        DataGenerator generator = event.getGenerator();
        PackOutput output = generator.getPackOutput();
        CompletableFuture<HolderLookup.Provider> lookupProvider = event.getLookupProvider();
        ExistingFileHelper existingFileHelper = event.getExistingFileHelper();
        ModBlockTagProvider modBlockTagProvider = new ModBlockTagProvider(output, lookupProvider, existingFileHelper);
        generator.addProvider(event.includeClient(), new ModLanguageProvider(output, LanguageEnum.English));
        generator.addProvider(event.includeClient(), new ModLanguageProvider(output, LanguageEnum.SimpleChinese));
        generator.addProvider(event.includeClient(), new ModItemModelProvider(output, existingFileHelper));
        generator.addProvider(event.includeClient(), new ModBlockModelProvider(output, existingFileHelper));
        generator.addProvider(event.includeClient(), new ModBlockStatesProvider(output, existingFileHelper));
        generator.addProvider(event.includeServer(), new ModLootTableProvider(output));
        generator.addProvider(event.includeServer(), new ModRecipeProvider(output));
        generator.addProvider(event.includeServer(), modBlockTagProvider);
        generator.addProvider(event.includeServer(), new ModItemTagProvider(output, lookupProvider, modBlockTagProvider.contentsGetter(), existingFileHelper));
    }
}
