package codechicken.enderstorage.init;

import net.minecraft.data.DataGenerator;
import net.minecraftforge.client.model.generators.BlockStateProvider;
import net.minecraftforge.client.model.generators.ItemModelProvider;
import net.minecraftforge.client.model.generators.ModelFile;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.GatherDataEvent;

import javax.annotation.Nonnull;

import static codechicken.enderstorage.EnderStorage.MOD_ID;

/**
 * Created by covers1624 on 4/25/20.
 */
@Mod.EventBusSubscriber (modid = MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class DataGenerators {

    @SubscribeEvent
    public static void gatherDataGenerators(GatherDataEvent event) {
        DataGenerator gen = event.getGenerator();
        ExistingFileHelper files = event.getExistingFileHelper();
        if (event.includeClient()) {
            gen.addProvider(new BlockStates(gen, files));
            gen.addProvider(new ItemModels(gen, files));
        }
    }

    private static class ItemModels extends ItemModelProvider {

        public ItemModels(DataGenerator generator, ExistingFileHelper existingFileHelper) {
            super(generator, MOD_ID, existingFileHelper);
        }

        @Override
        protected void registerModels() {
            getBuilder("ender_chest")//
                    .parent(new ModelFile.UncheckedModelFile("builtin/generated"));
            getBuilder("ender_tank")//
                    .parent(new ModelFile.UncheckedModelFile("builtin/generated"));
            getBuilder("ender_pouch")//
                    .parent(new ModelFile.UncheckedModelFile("builtin/generated"));
        }

        @Override
        public String getName() {
            return "Ender Storage Item models.";
        }
    }

    private static class BlockStates extends BlockStateProvider {

        public BlockStates(DataGenerator gen, ExistingFileHelper exFileHelper) {
            super(gen, MOD_ID, exFileHelper);
        }

        @Nonnull
        @Override
        public String getName() {
            return "Ender Storage BlockStates.";
        }

        @Override
        protected void registerStatesAndModels() {
            ModelFile model = models()//
                    .withExistingParent("dummy", "block")//
                    .texture("particle", "minecraft:block/obsidian");
            simpleBlock(ModContent.blockEnderChest, model);
            simpleBlock(ModContent.blockEnderTank, model);
        }
    }
}

@@ -29,24 +29,74 @@
 rage.init;%0A%0A
+import codechicken.lib.datagen.ItemModelProvider;%0A
 import net.m
@@ -198,77 +198,8 @@
 er;%0A
-import net.minecraftforge.client.model.generators.ItemModelProvider;%0A
 impo
@@ -1400,364 +1400,142 @@
     
-getBuilder(%22ender_chest%22)//%0A                    .parent(new ModelFile.UncheckedModelFile(%22builtin/generated%22));%0A            getBuilder(%22ender_tank%22)//%0A                    .parent(new ModelFile.UncheckedModelFile(%22builtin/generated%22));%0A            getBuilder(%22ender_pouch%22)//%0A                    .parent(new ModelFile.UncheckedModelFile(%22builtin/generated%22)
+noTexture(ModContent.itemEnderChest);%0A            noTexture(ModContent.itemEnderTank);%0A            noTexture(ModContent.itemEnderPouch
 );%0A 
@@ -1613,33 +1613,32 @@
    return %22Ender
- 
 Storage Item mod
@@ -1640,17 +1640,16 @@
 m models
-.
 %22;%0A     
@@ -1959,17 +1959,16 @@
 n %22Ender
- 
 Storage 
@@ -1978,17 +1978,16 @@
 ckStates
-.
 %22;%0A     

Simplify data generators