Search in sources :

Example 1 with ItemModelProvider

use of net.minecraftforge.client.model.generators.ItemModelProvider in project MinecraftForge by MinecraftForge.

the class NewModelLoaderTest method datagen.

private void datagen(GatherDataEvent event) {
    DataGenerator gen = event.getGenerator();
    if (event.includeClient()) {
        // Let blockstate provider see generated item models by passing its existing file helper
        ItemModelProvider itemModels = new ItemModels(gen, event.getExistingFileHelper());
        gen.addProvider(itemModels);
        gen.addProvider(new BlockStates(gen, itemModels.existingFileHelper));
    }
}
Also used : ItemModelProvider(net.minecraftforge.client.model.generators.ItemModelProvider) DataGenerator(net.minecraft.data.DataGenerator)

Example 2 with ItemModelProvider

use of net.minecraftforge.client.model.generators.ItemModelProvider in project MinecraftForge by MinecraftForge.

the class DataGeneratorTest method gatherData.

@SubscribeEvent
public static void gatherData(GatherDataEvent event) {
    GSON = new GsonBuilder().registerTypeAdapter(Variant.class, new Variant.Deserializer()).registerTypeAdapter(ItemTransforms.class, new ItemTransforms.Deserializer()).registerTypeAdapter(ItemTransform.class, new ItemTransform.Deserializer()).create();
    DataGenerator gen = event.getGenerator();
    if (event.includeClient()) {
        gen.addProvider(new Lang(gen));
        // Let blockstate provider see generated item models by passing its existing file helper
        ItemModelProvider itemModels = new ItemModels(gen, event.getExistingFileHelper());
        gen.addProvider(itemModels);
        gen.addProvider(new BlockStates(gen, itemModels.existingFileHelper));
        gen.addProvider(new SoundDefinitions(gen, event.getExistingFileHelper()));
    }
    if (event.includeServer()) {
        gen.addProvider(new Recipes(gen));
        gen.addProvider(new Tags(gen, event.getExistingFileHelper()));
        gen.addProvider(new Advancements(gen, event.getExistingFileHelper()));
    }
}
Also used : ItemModelProvider(net.minecraftforge.client.model.generators.ItemModelProvider) GsonBuilder(com.google.gson.GsonBuilder) ItemTransforms(net.minecraft.client.renderer.block.model.ItemTransforms) Variant(net.minecraft.client.renderer.block.model.Variant) ItemTransform(net.minecraft.client.renderer.block.model.ItemTransform) DataGenerator(net.minecraft.data.DataGenerator) BlockTags(net.minecraft.tags.BlockTags) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

DataGenerator (net.minecraft.data.DataGenerator)2 ItemModelProvider (net.minecraftforge.client.model.generators.ItemModelProvider)2 GsonBuilder (com.google.gson.GsonBuilder)1 ItemTransform (net.minecraft.client.renderer.block.model.ItemTransform)1 ItemTransforms (net.minecraft.client.renderer.block.model.ItemTransforms)1 Variant (net.minecraft.client.renderer.block.model.Variant)1 BlockTags (net.minecraft.tags.BlockTags)1 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)1