diff --git a/Fabric/src/main/java/com/autovw/advancednetherite/datagen/ModDataGenerator.java b/Fabric/src/main/java/com/autovw/advancednetherite/datagen/ModDataGenerator.java index ddbce809..2d8283b2 100644 --- a/Fabric/src/main/java/com/autovw/advancednetherite/datagen/ModDataGenerator.java +++ b/Fabric/src/main/java/com/autovw/advancednetherite/datagen/ModDataGenerator.java @@ -15,7 +15,7 @@ public void onInitializeDataGenerator(FabricDataGenerator generator) { FabricDataGenerator.Pack pack = generator.createPack(); - pack.addProvider(ModBlockStatesProvider::new); + pack.addProvider(ModModelProvider::new); pack.addProvider(ModBlockLootTablesProvider::new); pack.addProvider(ModRecipeProvider::new); diff --git a/Fabric/src/main/java/com/autovw/advancednetherite/datagen/providers/ModBlockStatesProvider.java b/Fabric/src/main/java/com/autovw/advancednetherite/datagen/providers/ModBlockStatesProvider.java deleted file mode 100644 index a8ac01b4..00000000 --- a/Fabric/src/main/java/com/autovw/advancednetherite/datagen/providers/ModBlockStatesProvider.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.autovw.advancednetherite.datagen.providers; - -import com.autovw.advancednetherite.core.ModBlocks; -import com.autovw.advancednetherite.core.ModItems; -import com.autovw.advancednetherite.core.util.ModEquipmentAssets; -import net.fabricmc.fabric.api.client.datagen.v1.provider.FabricModelProvider; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.minecraft.client.data.models.BlockModelGenerators; -import net.minecraft.client.data.models.ItemModelGenerators; -import net.minecraft.client.data.models.model.ModelTemplates; - -/** - * @author Autovw - */ -public class ModBlockStatesProvider extends FabricModelProvider -{ - public ModBlockStatesProvider(FabricDataOutput dataOutput) - { - super(dataOutput); - } - - @Override - public void generateBlockStateModels(BlockModelGenerators generator) - { - generator.createTrivialCube(ModBlocks.NETHERITE_IRON_BLOCK); - generator.createTrivialCube(ModBlocks.NETHERITE_GOLD_BLOCK); - generator.createTrivialCube(ModBlocks.NETHERITE_EMERALD_BLOCK); - generator.createTrivialCube(ModBlocks.NETHERITE_DIAMOND_BLOCK); - - //generator.delegateItemModel(ModBlocks.NETHERITE_IRON_BLOCK, ResourceLocation.fromNamespaceAndPath(AdvancedNetherite.MOD_ID, "block/netherite_iron_block")); - //generator.delegateItemModel(ModBlocks.NETHERITE_GOLD_BLOCK, ResourceLocation.fromNamespaceAndPath(AdvancedNetherite.MOD_ID, "block/netherite_gold_block")); - //generator.delegateItemModel(ModBlocks.NETHERITE_EMERALD_BLOCK, ResourceLocation.fromNamespaceAndPath(AdvancedNetherite.MOD_ID, "block/netherite_emerald_block")); - //generator.delegateItemModel(ModBlocks.NETHERITE_DIAMOND_BLOCK, ResourceLocation.fromNamespaceAndPath(AdvancedNetherite.MOD_ID, "block/netherite_diamond_block")); - } - - @Override - public void generateItemModels(ItemModelGenerators generator) - { - generator.generateFlatItem(ModItems.NETHERITE_IRON_INGOT, ModelTemplates.FLAT_ITEM); - generator.generateFlatItem(ModItems.NETHERITE_GOLD_INGOT, ModelTemplates.FLAT_ITEM); - generator.generateFlatItem(ModItems.NETHERITE_EMERALD_INGOT, ModelTemplates.FLAT_ITEM); - generator.generateFlatItem(ModItems.NETHERITE_DIAMOND_INGOT, ModelTemplates.FLAT_ITEM); - - generator.generateTrimmableItem(ModItems.NETHERITE_IRON_HELMET, ModEquipmentAssets.NETHERITE_IRON, "netherite_iron", false); - generator.generateTrimmableItem(ModItems.NETHERITE_IRON_CHESTPLATE, ModEquipmentAssets.NETHERITE_IRON, "netherite_iron", false); - generator.generateTrimmableItem(ModItems.NETHERITE_IRON_LEGGINGS, ModEquipmentAssets.NETHERITE_IRON, "netherite_iron", false); - generator.generateTrimmableItem(ModItems.NETHERITE_IRON_BOOTS, ModEquipmentAssets.NETHERITE_IRON, "netherite_iron", false); - - generator.generateTrimmableItem(ModItems.NETHERITE_GOLD_HELMET, ModEquipmentAssets.NETHERITE_GOLD, "netherite_gold", false); - generator.generateTrimmableItem(ModItems.NETHERITE_GOLD_CHESTPLATE, ModEquipmentAssets.NETHERITE_GOLD, "netherite_gold", false); - generator.generateTrimmableItem(ModItems.NETHERITE_GOLD_LEGGINGS, ModEquipmentAssets.NETHERITE_GOLD, "netherite_gold", false); - generator.generateTrimmableItem(ModItems.NETHERITE_GOLD_BOOTS, ModEquipmentAssets.NETHERITE_GOLD, "netherite_gold", false); - - generator.generateTrimmableItem(ModItems.NETHERITE_EMERALD_HELMET, ModEquipmentAssets.NETHERITE_EMERALD, "netherite_emerald", false); - generator.generateTrimmableItem(ModItems.NETHERITE_EMERALD_CHESTPLATE, ModEquipmentAssets.NETHERITE_EMERALD, "netherite_emerald", false); - generator.generateTrimmableItem(ModItems.NETHERITE_EMERALD_LEGGINGS, ModEquipmentAssets.NETHERITE_EMERALD, "netherite_emerald", false); - generator.generateTrimmableItem(ModItems.NETHERITE_EMERALD_BOOTS, ModEquipmentAssets.NETHERITE_EMERALD, "netherite_emerald", false); - - generator.generateTrimmableItem(ModItems.NETHERITE_DIAMOND_HELMET, ModEquipmentAssets.NETHERITE_DIAMOND, "netherite_diamond", false); - generator.generateTrimmableItem(ModItems.NETHERITE_DIAMOND_CHESTPLATE, ModEquipmentAssets.NETHERITE_DIAMOND, "netherite_diamond", false); - generator.generateTrimmableItem(ModItems.NETHERITE_DIAMOND_LEGGINGS, ModEquipmentAssets.NETHERITE_DIAMOND, "netherite_diamond", false); - generator.generateTrimmableItem(ModItems.NETHERITE_DIAMOND_BOOTS, ModEquipmentAssets.NETHERITE_DIAMOND, "netherite_diamond", false); - - generator.generateFlatItem(ModItems.NETHERITE_IRON_AXE, ModelTemplates.FLAT_HANDHELD_ITEM); - generator.generateFlatItem(ModItems.NETHERITE_IRON_HOE, ModelTemplates.FLAT_HANDHELD_ITEM); - generator.generateFlatItem(ModItems.NETHERITE_IRON_PICKAXE, ModelTemplates.FLAT_HANDHELD_ITEM); - generator.generateFlatItem(ModItems.NETHERITE_IRON_SHOVEL, ModelTemplates.FLAT_HANDHELD_ITEM); - generator.generateFlatItem(ModItems.NETHERITE_IRON_SWORD, ModelTemplates.FLAT_HANDHELD_ITEM); - - generator.generateFlatItem(ModItems.NETHERITE_GOLD_AXE, ModelTemplates.FLAT_HANDHELD_ITEM); - generator.generateFlatItem(ModItems.NETHERITE_GOLD_HOE, ModelTemplates.FLAT_HANDHELD_ITEM); - generator.generateFlatItem(ModItems.NETHERITE_GOLD_PICKAXE, ModelTemplates.FLAT_HANDHELD_ITEM); - generator.generateFlatItem(ModItems.NETHERITE_GOLD_SHOVEL, ModelTemplates.FLAT_HANDHELD_ITEM); - generator.generateFlatItem(ModItems.NETHERITE_GOLD_SWORD, ModelTemplates.FLAT_HANDHELD_ITEM); - - generator.generateFlatItem(ModItems.NETHERITE_EMERALD_AXE, ModelTemplates.FLAT_HANDHELD_ITEM); - generator.generateFlatItem(ModItems.NETHERITE_EMERALD_HOE, ModelTemplates.FLAT_HANDHELD_ITEM); - generator.generateFlatItem(ModItems.NETHERITE_EMERALD_PICKAXE, ModelTemplates.FLAT_HANDHELD_ITEM); - generator.generateFlatItem(ModItems.NETHERITE_EMERALD_SHOVEL, ModelTemplates.FLAT_HANDHELD_ITEM); - generator.generateFlatItem(ModItems.NETHERITE_EMERALD_SWORD, ModelTemplates.FLAT_HANDHELD_ITEM); - - generator.generateFlatItem(ModItems.NETHERITE_DIAMOND_AXE, ModelTemplates.FLAT_HANDHELD_ITEM); - generator.generateFlatItem(ModItems.NETHERITE_DIAMOND_HOE, ModelTemplates.FLAT_HANDHELD_ITEM); - generator.generateFlatItem(ModItems.NETHERITE_DIAMOND_PICKAXE, ModelTemplates.FLAT_HANDHELD_ITEM); - generator.generateFlatItem(ModItems.NETHERITE_DIAMOND_SHOVEL, ModelTemplates.FLAT_HANDHELD_ITEM); - generator.generateFlatItem(ModItems.NETHERITE_DIAMOND_SWORD, ModelTemplates.FLAT_HANDHELD_ITEM); - } -} diff --git a/Fabric/src/main/java/com/autovw/advancednetherite/datagen/providers/ModModelProvider.java b/Fabric/src/main/java/com/autovw/advancednetherite/datagen/providers/ModModelProvider.java new file mode 100644 index 00000000..7879d407 --- /dev/null +++ b/Fabric/src/main/java/com/autovw/advancednetherite/datagen/providers/ModModelProvider.java @@ -0,0 +1,102 @@ +package com.autovw.advancednetherite.datagen.providers; + +import com.autovw.advancednetherite.core.ModBlocks; +import com.autovw.advancednetherite.core.ModItems; +import com.autovw.advancednetherite.core.util.ModEquipmentAssets; +import net.fabricmc.fabric.api.client.datagen.v1.provider.FabricModelProvider; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.minecraft.client.data.models.BlockModelGenerators; +import net.minecraft.client.data.models.ItemModelGenerators; +import net.minecraft.client.data.models.model.ModelTemplates; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.equipment.EquipmentAsset; + +/** + * @author Autovw + */ +public class ModModelProvider extends FabricModelProvider +{ + public ModModelProvider(FabricDataOutput dataOutput) + { + super(dataOutput); + } + + @Override + public void generateBlockStateModels(BlockModelGenerators generator) + { + generator.createTrivialCube(ModBlocks.NETHERITE_IRON_BLOCK); + generator.createTrivialCube(ModBlocks.NETHERITE_GOLD_BLOCK); + generator.createTrivialCube(ModBlocks.NETHERITE_EMERALD_BLOCK); + generator.createTrivialCube(ModBlocks.NETHERITE_DIAMOND_BLOCK); + } + + @Override + public void generateItemModels(ItemModelGenerators generator) + { + itemModel(generator, ModItems.NETHERITE_IRON_INGOT); + itemModel(generator, ModItems.NETHERITE_GOLD_INGOT); + itemModel(generator, ModItems.NETHERITE_EMERALD_INGOT); + itemModel(generator, ModItems.NETHERITE_DIAMOND_INGOT); + + armorModel(generator, ModItems.NETHERITE_IRON_HELMET, ModEquipmentAssets.NETHERITE_IRON); + armorModel(generator, ModItems.NETHERITE_IRON_CHESTPLATE, ModEquipmentAssets.NETHERITE_IRON); + armorModel(generator, ModItems.NETHERITE_IRON_LEGGINGS, ModEquipmentAssets.NETHERITE_IRON); + armorModel(generator, ModItems.NETHERITE_IRON_BOOTS, ModEquipmentAssets.NETHERITE_IRON); + + armorModel(generator, ModItems.NETHERITE_GOLD_HELMET, ModEquipmentAssets.NETHERITE_GOLD); + armorModel(generator, ModItems.NETHERITE_GOLD_CHESTPLATE, ModEquipmentAssets.NETHERITE_GOLD); + armorModel(generator, ModItems.NETHERITE_GOLD_LEGGINGS, ModEquipmentAssets.NETHERITE_GOLD); + armorModel(generator, ModItems.NETHERITE_GOLD_BOOTS, ModEquipmentAssets.NETHERITE_GOLD); + + armorModel(generator, ModItems.NETHERITE_EMERALD_HELMET, ModEquipmentAssets.NETHERITE_EMERALD); + armorModel(generator, ModItems.NETHERITE_EMERALD_CHESTPLATE, ModEquipmentAssets.NETHERITE_EMERALD); + armorModel(generator, ModItems.NETHERITE_EMERALD_LEGGINGS, ModEquipmentAssets.NETHERITE_EMERALD); + armorModel(generator, ModItems.NETHERITE_EMERALD_BOOTS, ModEquipmentAssets.NETHERITE_EMERALD); + + armorModel(generator, ModItems.NETHERITE_DIAMOND_HELMET, ModEquipmentAssets.NETHERITE_DIAMOND); + armorModel(generator, ModItems.NETHERITE_DIAMOND_CHESTPLATE, ModEquipmentAssets.NETHERITE_DIAMOND); + armorModel(generator, ModItems.NETHERITE_DIAMOND_LEGGINGS, ModEquipmentAssets.NETHERITE_DIAMOND); + armorModel(generator, ModItems.NETHERITE_DIAMOND_BOOTS, ModEquipmentAssets.NETHERITE_DIAMOND); + + toolModel(generator, ModItems.NETHERITE_IRON_AXE); + toolModel(generator, ModItems.NETHERITE_GOLD_AXE); + toolModel(generator, ModItems.NETHERITE_EMERALD_AXE); + toolModel(generator, ModItems.NETHERITE_DIAMOND_AXE); + + toolModel(generator, ModItems.NETHERITE_IRON_HOE); + toolModel(generator, ModItems.NETHERITE_GOLD_HOE); + toolModel(generator, ModItems.NETHERITE_EMERALD_HOE); + toolModel(generator, ModItems.NETHERITE_DIAMOND_HOE); + + toolModel(generator, ModItems.NETHERITE_IRON_PICKAXE); + toolModel(generator, ModItems.NETHERITE_GOLD_PICKAXE); + toolModel(generator, ModItems.NETHERITE_EMERALD_PICKAXE); + toolModel(generator, ModItems.NETHERITE_DIAMOND_PICKAXE); + + toolModel(generator, ModItems.NETHERITE_IRON_SHOVEL); + toolModel(generator, ModItems.NETHERITE_GOLD_SHOVEL); + toolModel(generator, ModItems.NETHERITE_EMERALD_SHOVEL); + toolModel(generator, ModItems.NETHERITE_DIAMOND_SHOVEL); + + toolModel(generator, ModItems.NETHERITE_IRON_SWORD); + toolModel(generator, ModItems.NETHERITE_GOLD_SWORD); + toolModel(generator, ModItems.NETHERITE_EMERALD_SWORD); + toolModel(generator, ModItems.NETHERITE_DIAMOND_SWORD); + } + + public void itemModel(ItemModelGenerators itemModels, Item item) + { + itemModels.createFlatItemModel(item, ModelTemplates.FLAT_ITEM); + } + + public void toolModel(ItemModelGenerators itemModels, Item item) + { + itemModels.createFlatItemModel(item, ModelTemplates.FLAT_HANDHELD_ITEM); + } + + public void armorModel(ItemModelGenerators itemModels, Item item, ResourceKey equipmentKey) + { + itemModels.generateTrimmableItem(item, equipmentKey, equipmentKey.location().getPath(), false); + } +} diff --git a/Forge/build.gradle b/Forge/build.gradle index ebf78fac..a70af44c 100644 --- a/Forge/build.gradle +++ b/Forge/build.gradle @@ -12,7 +12,7 @@ minecraft { mappings channel: 'official', version: minecraft_version // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. - // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') + accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') reobf = false diff --git a/Forge/src/main/java/com/autovw/advancednetherite/datagen/ModDataGenerator.java b/Forge/src/main/java/com/autovw/advancednetherite/datagen/ModDataGenerator.java index e4b17cd1..50e7c592 100644 --- a/Forge/src/main/java/com/autovw/advancednetherite/datagen/ModDataGenerator.java +++ b/Forge/src/main/java/com/autovw/advancednetherite/datagen/ModDataGenerator.java @@ -49,8 +49,7 @@ public static void onGatherData(final GatherDataEvent event) generator.addProvider(event.includeServer(), new ModLootModifierProvider(packOutput, AdvancedNetherite.MOD_ID, lookupProvider)); // client - generator.addProvider(event.includeClient(), new ModBlockStatesProvider(packOutput, AdvancedNetherite.MOD_ID, helper)); generator.addProvider(event.includeClient(), new ModEquipmentAssetProvider(packOutput)); - generator.addProvider(event.includeClient(), new ModItemModelProvider(packOutput, AdvancedNetherite.MOD_ID, helper)); + generator.addProvider(event.includeClient(), new ModModelProvider(packOutput, AdvancedNetherite.MOD_ID)); } } diff --git a/Forge/src/main/java/com/autovw/advancednetherite/datagen/providers/ModBlockStatesProvider.java b/Forge/src/main/java/com/autovw/advancednetherite/datagen/providers/ModBlockStatesProvider.java deleted file mode 100644 index 8139ef32..00000000 --- a/Forge/src/main/java/com/autovw/advancednetherite/datagen/providers/ModBlockStatesProvider.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.autovw.advancednetherite.datagen.providers; - -import com.autovw.advancednetherite.AdvancedNetherite; -import com.autovw.advancednetherite.api.annotation.Internal; -import com.autovw.advancednetherite.core.registry.ModBlockRegistry; -import net.minecraft.data.PackOutput; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.Block; -import net.minecraftforge.client.model.generators.BlockStateProvider; -import net.minecraftforge.client.model.generators.ConfiguredModel; -import net.minecraftforge.common.data.ExistingFileHelper; -import net.minecraftforge.registries.ForgeRegistries; -import net.minecraftforge.registries.RegistryObject; - -/** - * @author Autovw - */ -public class ModBlockStatesProvider extends BlockStateProvider -{ - public ModBlockStatesProvider(PackOutput packOutput, String modId, ExistingFileHelper exFileHelper) - { - super(packOutput, modId, exFileHelper); - } - - @Override - protected void registerStatesAndModels() - { - ModBlockRegistry.BLOCKS.getEntries().stream().map(RegistryObject::get).forEach(this::netheriteBlock); - } - - /** - * Helper method for generating blockstates, block models and item models. - * - * @param block The block for which you want to generate blockstates and models - * @param texture The location of the block texture - */ - public void netheriteBlock(Block block, ResourceLocation texture) - { - getVariantBuilder(block).partialState().setModels(new ConfiguredModel(models().cubeAll(ForgeRegistries.BLOCKS.getKey(block).getPath(), texture))); - itemModels().withExistingParent(ForgeRegistries.BLOCKS.getKey(block).getPath(), ResourceLocation.fromNamespaceAndPath(ForgeRegistries.BLOCKS.getKey(block).getNamespace(), "block/" + ForgeRegistries.BLOCKS.getKey(block).getPath())); - } - - @Internal - private void netheriteBlock(Block block) - { - netheriteBlock(block, ResourceLocation.fromNamespaceAndPath(AdvancedNetherite.MOD_ID, "block/" + ForgeRegistries.BLOCKS.getKey(block).getPath())); - } -} diff --git a/Forge/src/main/java/com/autovw/advancednetherite/datagen/providers/ModItemModelProvider.java b/Forge/src/main/java/com/autovw/advancednetherite/datagen/providers/ModItemModelProvider.java deleted file mode 100644 index f0105f4c..00000000 --- a/Forge/src/main/java/com/autovw/advancednetherite/datagen/providers/ModItemModelProvider.java +++ /dev/null @@ -1,189 +0,0 @@ -package com.autovw.advancednetherite.datagen.providers; - -import com.autovw.advancednetherite.AdvancedNetherite; -import com.autovw.advancednetherite.api.annotation.Internal; -import com.autovw.advancednetherite.core.ModItems; -import net.minecraft.data.PackOutput; -import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.packs.PackType; -import net.minecraft.world.item.ArmorItem; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.equipment.trim.TrimMaterial; -import net.minecraft.world.item.equipment.trim.TrimMaterials; -import net.minecraftforge.client.model.generators.ItemModelProvider; -import net.minecraftforge.client.model.generators.ModelFile; -import net.minecraftforge.common.data.ExistingFileHelper; - -import java.util.LinkedHashMap; - -/** - * @author Autovw - */ -public class ModItemModelProvider extends ItemModelProvider -{ - private static final LinkedHashMap, Float> TRIM_MATERIALS = new LinkedHashMap<>(); - static - { - TRIM_MATERIALS.put(TrimMaterials.QUARTZ, 0.1F); - TRIM_MATERIALS.put(TrimMaterials.IRON, 0.2F); - TRIM_MATERIALS.put(TrimMaterials.NETHERITE, 0.3F); - TRIM_MATERIALS.put(TrimMaterials.REDSTONE, 0.4F); - TRIM_MATERIALS.put(TrimMaterials.COPPER, 0.5F); - TRIM_MATERIALS.put(TrimMaterials.GOLD, 0.6F); - TRIM_MATERIALS.put(TrimMaterials.EMERALD, 0.7F); - TRIM_MATERIALS.put(TrimMaterials.DIAMOND, 0.8F); - TRIM_MATERIALS.put(TrimMaterials.LAPIS, 0.9F); - TRIM_MATERIALS.put(TrimMaterials.AMETHYST, 1.0F); - } - - public ModItemModelProvider(PackOutput packOutput, String modId, ExistingFileHelper existingFileHelper) - { - super(packOutput, modId, existingFileHelper); - } - - @Override - protected void registerModels() - { - /* Ingots */ - itemModel(ModItems.NETHERITE_IRON_INGOT); - itemModel(ModItems.NETHERITE_GOLD_INGOT); - itemModel(ModItems.NETHERITE_EMERALD_INGOT); - itemModel(ModItems.NETHERITE_DIAMOND_INGOT); - - /* Armor sets */ - armorModel(ModItems.NETHERITE_IRON_HELMET); - armorModel(ModItems.NETHERITE_IRON_CHESTPLATE); - armorModel(ModItems.NETHERITE_IRON_LEGGINGS); - armorModel(ModItems.NETHERITE_IRON_BOOTS); - - armorModel(ModItems.NETHERITE_GOLD_HELMET); - armorModel(ModItems.NETHERITE_GOLD_CHESTPLATE); - armorModel(ModItems.NETHERITE_GOLD_LEGGINGS); - armorModel(ModItems.NETHERITE_GOLD_BOOTS); - - armorModel(ModItems.NETHERITE_EMERALD_HELMET); - armorModel(ModItems.NETHERITE_EMERALD_CHESTPLATE); - armorModel(ModItems.NETHERITE_EMERALD_LEGGINGS); - armorModel(ModItems.NETHERITE_EMERALD_BOOTS); - - armorModel(ModItems.NETHERITE_DIAMOND_HELMET); - armorModel(ModItems.NETHERITE_DIAMOND_CHESTPLATE); - armorModel(ModItems.NETHERITE_DIAMOND_LEGGINGS); - armorModel(ModItems.NETHERITE_DIAMOND_BOOTS); - - /* Axes */ - toolModel(ModItems.NETHERITE_IRON_AXE); - toolModel(ModItems.NETHERITE_GOLD_AXE); - toolModel(ModItems.NETHERITE_EMERALD_AXE); - toolModel(ModItems.NETHERITE_DIAMOND_AXE); - - /* Hoes */ - toolModel(ModItems.NETHERITE_IRON_HOE); - toolModel(ModItems.NETHERITE_GOLD_HOE); - toolModel(ModItems.NETHERITE_EMERALD_HOE); - toolModel(ModItems.NETHERITE_DIAMOND_HOE); - - /* Pickaxes */ - toolModel(ModItems.NETHERITE_IRON_PICKAXE); - toolModel(ModItems.NETHERITE_GOLD_PICKAXE); - toolModel(ModItems.NETHERITE_EMERALD_PICKAXE); - toolModel(ModItems.NETHERITE_DIAMOND_PICKAXE); - - /* Shovels */ - toolModel(ModItems.NETHERITE_IRON_SHOVEL); - toolModel(ModItems.NETHERITE_GOLD_SHOVEL); - toolModel(ModItems.NETHERITE_EMERALD_SHOVEL); - toolModel(ModItems.NETHERITE_DIAMOND_SHOVEL); - - /* Swords */ - toolModel(ModItems.NETHERITE_IRON_SWORD); - toolModel(ModItems.NETHERITE_GOLD_SWORD); - toolModel(ModItems.NETHERITE_EMERALD_SWORD); - toolModel(ModItems.NETHERITE_DIAMOND_SWORD); - } - - /** - * Helper method for creating a simple item model - * - * @param item The item for which the model is made - * @param texture The location of the item texture - */ - public void itemModel(Item item, ResourceLocation texture) - { - singleTexture(item.toString(), mcLoc("item/generated"), "layer0", texture); - } - - @Internal - private void itemModel(Item item) - { - ResourceLocation itemLoc = AdvancedNetherite.getRegistryHelper().getItemById(item); - itemModel(item, ResourceLocation.fromNamespaceAndPath(AdvancedNetherite.MOD_ID, "item/" + itemLoc.getPath())); - } - - /** - * Helper method for creating a simple item model for tools - * - * @param item The item for which the model is made - * @param texture The location of the item texture - */ - public void toolModel(Item item, ResourceLocation texture) - { - singleTexture(item.toString(), mcLoc("item/handheld"), "layer0", texture); - } - - @Internal - private void toolModel(Item item) - { - ResourceLocation toolLoc = AdvancedNetherite.getRegistryHelper().getItemById(item); - toolModel(item, ResourceLocation.fromNamespaceAndPath(AdvancedNetherite.MOD_ID, "item/" + toolLoc.getPath())); - } - - public void armorModel(Item item) - { - if (!(item instanceof ArmorItem armorItem)) - return; - - TRIM_MATERIALS.forEach((trimMaterial, trimValue) -> - { - ResourceLocation id = AdvancedNetherite.getRegistryHelper().getItemById(armorItem); - String armorType = ""; - if (id.getPath().contains("helmet")) - armorType = "helmet"; - else if (id.getPath().contains("chestplate")) - armorType = "chestplate"; - else if (id.getPath().contains("leggings")) - armorType = "leggings"; - else if (id.getPath().contains("boots")) - armorType = "boots"; - - ResourceLocation armorTexture = ResourceLocation.fromNamespaceAndPath(id.getNamespace(), "item/" + id.getPath()); - ResourceLocation trimTexture = mcLoc("trims/items/" + armorType + "_trim_" + trimMaterial.location().getPath()); - ResourceLocation currentTrimTexture = ResourceLocation.fromNamespaceAndPath(id.getNamespace(), "item/" + id.getPath() + "_" + trimMaterial.location().getPath() + "_trim"); - - // Make sure the ExistingFileHelper does not throw an IllegalArgumentException - this.existingFileHelper.trackGenerated(trimTexture, PackType.CLIENT_RESOURCES, ".png", "textures"); - - this.trimmedArmorModel(currentTrimTexture, armorTexture, trimTexture); - - this.nonTrimmedArmorModel(id, currentTrimTexture, trimValue); - }); - } - - private void trimmedArmorModel(ResourceLocation currentTrimTexture, ResourceLocation armorTexture, ResourceLocation trimTexture) - { - this.getBuilder(currentTrimTexture.getPath()) - .parent(new ModelFile.UncheckedModelFile("item/generated")) - .texture("layer0", armorTexture) - .texture("layer1", trimTexture); - } - - private void nonTrimmedArmorModel(ResourceLocation id, ResourceLocation currentTrimTexture, float trimValue) - { - this.withExistingParent(id.getPath(), mcLoc("item/generated")) - .override() - .model(new ModelFile.UncheckedModelFile(currentTrimTexture)) - .predicate(mcLoc("trim_type"), trimValue).end() - .texture("layer0", ResourceLocation.fromNamespaceAndPath(id.getNamespace(), "item/" + id.getPath())); - } -} diff --git a/Forge/src/main/java/com/autovw/advancednetherite/datagen/providers/ModModelProvider.java b/Forge/src/main/java/com/autovw/advancednetherite/datagen/providers/ModModelProvider.java new file mode 100644 index 00000000..73cb0a8e --- /dev/null +++ b/Forge/src/main/java/com/autovw/advancednetherite/datagen/providers/ModModelProvider.java @@ -0,0 +1,160 @@ +package com.autovw.advancednetherite.datagen.providers; + +import com.autovw.advancednetherite.core.ModBlocks; +import com.autovw.advancednetherite.core.ModItems; +import com.autovw.advancednetherite.core.util.ModEquipmentAssets; +import net.minecraft.client.data.models.BlockModelGenerators; +import net.minecraft.client.data.models.ItemModelGenerators; +import net.minecraft.client.data.models.ModelProvider; +import net.minecraft.client.data.models.model.ModelTemplates; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.data.CachedOutput; +import net.minecraft.data.PackOutput; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.equipment.EquipmentAsset; +import net.minecraft.world.level.block.Block; + +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.stream.Stream; + +/** + * @author Autovw + */ +public class ModModelProvider extends ModelProvider +{ + private final PackOutput.PathProvider blockStatePathProvider; + private final PackOutput.PathProvider itemInfoPathProvider; + private final PackOutput.PathProvider modelPathProvider; + protected final String modId; + + public ModModelProvider(PackOutput packOutput, String modId) + { + super(packOutput); + this.blockStatePathProvider = packOutput.createPathProvider(PackOutput.Target.RESOURCE_PACK, "blockstates"); + this.itemInfoPathProvider = packOutput.createPathProvider(PackOutput.Target.RESOURCE_PACK, "items"); + this.modelPathProvider = packOutput.createPathProvider(PackOutput.Target.RESOURCE_PACK, "models"); + this.modId = modId; + } + + protected void registerModels(BlockModelGenerators blockModels, ItemModelGenerators itemModels) + { + /* Blocks */ + blockModel(blockModels, ModBlocks.NETHERITE_IRON_BLOCK); + blockModel(blockModels, ModBlocks.NETHERITE_GOLD_BLOCK); + blockModel(blockModels, ModBlocks.NETHERITE_EMERALD_BLOCK); + blockModel(blockModels, ModBlocks.NETHERITE_DIAMOND_BLOCK); + + /* Ingots */ + itemModel(itemModels, ModItems.NETHERITE_IRON_INGOT); + itemModel(itemModels, ModItems.NETHERITE_GOLD_INGOT); + itemModel(itemModels, ModItems.NETHERITE_EMERALD_INGOT); + itemModel(itemModels, ModItems.NETHERITE_DIAMOND_INGOT); + + /* Armor sets */ + armorModel(itemModels, ModItems.NETHERITE_IRON_HELMET, ModEquipmentAssets.NETHERITE_IRON); + armorModel(itemModels, ModItems.NETHERITE_IRON_CHESTPLATE, ModEquipmentAssets.NETHERITE_IRON); + armorModel(itemModels, ModItems.NETHERITE_IRON_LEGGINGS, ModEquipmentAssets.NETHERITE_IRON); + armorModel(itemModels, ModItems.NETHERITE_IRON_BOOTS, ModEquipmentAssets.NETHERITE_IRON); + + armorModel(itemModels, ModItems.NETHERITE_GOLD_HELMET, ModEquipmentAssets.NETHERITE_GOLD); + armorModel(itemModels, ModItems.NETHERITE_GOLD_CHESTPLATE, ModEquipmentAssets.NETHERITE_GOLD); + armorModel(itemModels, ModItems.NETHERITE_GOLD_LEGGINGS, ModEquipmentAssets.NETHERITE_GOLD); + armorModel(itemModels, ModItems.NETHERITE_GOLD_BOOTS, ModEquipmentAssets.NETHERITE_GOLD); + + armorModel(itemModels, ModItems.NETHERITE_EMERALD_HELMET, ModEquipmentAssets.NETHERITE_EMERALD); + armorModel(itemModels, ModItems.NETHERITE_EMERALD_CHESTPLATE, ModEquipmentAssets.NETHERITE_EMERALD); + armorModel(itemModels, ModItems.NETHERITE_EMERALD_LEGGINGS, ModEquipmentAssets.NETHERITE_EMERALD); + armorModel(itemModels, ModItems.NETHERITE_EMERALD_BOOTS, ModEquipmentAssets.NETHERITE_EMERALD); + + armorModel(itemModels, ModItems.NETHERITE_DIAMOND_HELMET, ModEquipmentAssets.NETHERITE_DIAMOND); + armorModel(itemModels, ModItems.NETHERITE_DIAMOND_CHESTPLATE, ModEquipmentAssets.NETHERITE_DIAMOND); + armorModel(itemModels, ModItems.NETHERITE_DIAMOND_LEGGINGS, ModEquipmentAssets.NETHERITE_DIAMOND); + armorModel(itemModels, ModItems.NETHERITE_DIAMOND_BOOTS, ModEquipmentAssets.NETHERITE_DIAMOND); + + /* Axes */ + toolModel(itemModels, ModItems.NETHERITE_IRON_AXE); + toolModel(itemModels, ModItems.NETHERITE_GOLD_AXE); + toolModel(itemModels, ModItems.NETHERITE_EMERALD_AXE); + toolModel(itemModels, ModItems.NETHERITE_DIAMOND_AXE); + + /* Hoes */ + toolModel(itemModels, ModItems.NETHERITE_IRON_HOE); + toolModel(itemModels, ModItems.NETHERITE_GOLD_HOE); + toolModel(itemModels, ModItems.NETHERITE_EMERALD_HOE); + toolModel(itemModels, ModItems.NETHERITE_DIAMOND_HOE); + + /* Pickaxes */ + toolModel(itemModels, ModItems.NETHERITE_IRON_PICKAXE); + toolModel(itemModels, ModItems.NETHERITE_GOLD_PICKAXE); + toolModel(itemModels, ModItems.NETHERITE_EMERALD_PICKAXE); + toolModel(itemModels, ModItems.NETHERITE_DIAMOND_PICKAXE); + + /* Shovels */ + toolModel(itemModels, ModItems.NETHERITE_IRON_SHOVEL); + toolModel(itemModels, ModItems.NETHERITE_GOLD_SHOVEL); + toolModel(itemModels, ModItems.NETHERITE_EMERALD_SHOVEL); + toolModel(itemModels, ModItems.NETHERITE_DIAMOND_SHOVEL); + + /* Swords */ + toolModel(itemModels, ModItems.NETHERITE_IRON_SWORD); + toolModel(itemModels, ModItems.NETHERITE_GOLD_SWORD); + toolModel(itemModels, ModItems.NETHERITE_EMERALD_SWORD); + toolModel(itemModels, ModItems.NETHERITE_DIAMOND_SWORD); + } + + public void blockModel(BlockModelGenerators blockModels, Block block) + { + blockModels.createTrivialCube(block); + } + + public void itemModel(ItemModelGenerators itemModels, Item item) + { + itemModels.createFlatItemModel(item, ModelTemplates.FLAT_ITEM); + } + + public void toolModel(ItemModelGenerators itemModels, Item item) + { + itemModels.createFlatItemModel(item, ModelTemplates.FLAT_HANDHELD_ITEM); + } + + public void armorModel(ItemModelGenerators itemModels, Item item, ResourceKey equipmentKey) + { + itemModels.generateTrimmableItem(item, equipmentKey, equipmentKey.location().getPath(), false); + } + + @Override + public CompletableFuture run(CachedOutput output) + { + ItemInfoCollector itemCollector = new ItemInfoCollector(this::getKnownItems); + BlockStateGeneratorCollector blockStateCollector = new BlockStateGeneratorCollector(this::getKnownBlocks); + SimpleModelCollector simpleModelCollector = new SimpleModelCollector(); + this.registerModels(new BlockModelGenerators(blockStateCollector, itemCollector, simpleModelCollector), new ItemModelGenerators(itemCollector, simpleModelCollector)); + blockStateCollector.validate(); + itemCollector.finalizeAndValidate(); + return CompletableFuture.allOf( + blockStateCollector.save(output, this.blockStatePathProvider), + simpleModelCollector.save(output, this.modelPathProvider), + itemCollector.save(output, this.itemInfoPathProvider) + ); + } + + @Override + protected Stream getKnownBlocks() + { + return BuiltInRegistries.BLOCK.stream() + .filter((block) -> Optional.of(BuiltInRegistries.BLOCK.getKey(block)) + .filter((key) -> key.getNamespace().equals(this.modId)) + .isPresent()); + } + + @Override + protected Stream getKnownItems() + { + return BuiltInRegistries.ITEM.stream() + .filter((item) -> Optional.of(BuiltInRegistries.ITEM.getKey(item)) + .filter((key) -> key.getNamespace().equals(this.modId)) + .isPresent()); + } +} diff --git a/Forge/src/main/resources/META-INF/accesstransformer.cfg b/Forge/src/main/resources/META-INF/accesstransformer.cfg new file mode 100644 index 00000000..fe21b64c --- /dev/null +++ b/Forge/src/main/resources/META-INF/accesstransformer.cfg @@ -0,0 +1,2 @@ +public net.minecraft.client.data.models.ItemModelGenerators m_373858_(Lnet/minecraft/world/item/Item;Lnet/minecraft/client/data/models/model/ModelTemplate;)Lnet/minecraft/resources/ResourceLocation; # createFlatItemModel +public net.minecraft.client.data.models.ItemModelGenerators m_372919_(Lnet/minecraft/world/item/Item;Lnet/minecraft/resources/ResourceKey;Ljava/lang/String;Z)V # generateTrimmableItem \ No newline at end of file diff --git a/NeoForge/src/main/java/com/autovw/advancednetherite/datagen/ModDataGenerator.java b/NeoForge/src/main/java/com/autovw/advancednetherite/datagen/ModDataGenerator.java index 0e60687f..cfb0a785 100644 --- a/NeoForge/src/main/java/com/autovw/advancednetherite/datagen/ModDataGenerator.java +++ b/NeoForge/src/main/java/com/autovw/advancednetherite/datagen/ModDataGenerator.java @@ -50,7 +50,6 @@ public static void onGatherData(final GatherDataEvent.Client event) event.addProvider(new ModLootModifierProvider(packOutput, lookupProvider, AdvancedNetherite.MOD_ID)); // client - //event.addProvider(new ModBlockStatesProvider(packOutput, AdvancedNetherite.MOD_ID, helper)); event.addProvider(new ModEquipmentAssetProvider(packOutput)); event.addProvider(new ModModelProvider(packOutput, AdvancedNetherite.MOD_ID)); } diff --git a/NeoForge/src/main/java/com/autovw/advancednetherite/datagen/providers/ModModelProvider.java b/NeoForge/src/main/java/com/autovw/advancednetherite/datagen/providers/ModModelProvider.java index 66b59771..106fc387 100644 --- a/NeoForge/src/main/java/com/autovw/advancednetherite/datagen/providers/ModModelProvider.java +++ b/NeoForge/src/main/java/com/autovw/advancednetherite/datagen/providers/ModModelProvider.java @@ -9,35 +9,15 @@ import net.minecraft.client.data.models.model.ModelTemplates; import net.minecraft.data.PackOutput; import net.minecraft.resources.ResourceKey; -import net.minecraft.world.item.ArmorItem; import net.minecraft.world.item.Item; import net.minecraft.world.item.equipment.EquipmentAsset; -import net.minecraft.world.item.equipment.trim.TrimMaterial; -import net.minecraft.world.item.equipment.trim.TrimMaterials; import net.minecraft.world.level.block.Block; -import java.util.LinkedHashMap; - /** * @author Autovw */ public class ModModelProvider extends ModelProvider { - private static final LinkedHashMap, Float> TRIM_MATERIALS = new LinkedHashMap<>(); - static - { - TRIM_MATERIALS.put(TrimMaterials.QUARTZ, 0.1F); - TRIM_MATERIALS.put(TrimMaterials.IRON, 0.2F); - TRIM_MATERIALS.put(TrimMaterials.NETHERITE, 0.3F); - TRIM_MATERIALS.put(TrimMaterials.REDSTONE, 0.4F); - TRIM_MATERIALS.put(TrimMaterials.COPPER, 0.5F); - TRIM_MATERIALS.put(TrimMaterials.GOLD, 0.6F); - TRIM_MATERIALS.put(TrimMaterials.EMERALD, 0.7F); - TRIM_MATERIALS.put(TrimMaterials.DIAMOND, 0.8F); - TRIM_MATERIALS.put(TrimMaterials.LAPIS, 0.9F); - TRIM_MATERIALS.put(TrimMaterials.AMETHYST, 1.0F); - } - public ModModelProvider(PackOutput packOutput, String modId) { super(packOutput, modId); @@ -127,55 +107,6 @@ public void toolModel(ItemModelGenerators itemModels, Item item) public void armorModel(ItemModelGenerators itemModels, Item item, ResourceKey equipmentKey) { - if (!(item instanceof ArmorItem armorItem)) - return; - itemModels.generateTrimmableItem(item, equipmentKey, equipmentKey.location().getPath(), false); - - /* - TRIM_MATERIALS.forEach((trimMaterial, trimValue) -> - { - ResourceLocation id = AdvancedNetherite.getRegistryHelper().getItemById(armorItem); - String armorType = ""; - if (id.getPath().contains("helmet")) - armorType = "helmet"; - else if (id.getPath().contains("chestplate")) - armorType = "chestplate"; - else if (id.getPath().contains("leggings")) - armorType = "leggings"; - else if (id.getPath().contains("boots")) - armorType = "boots"; - - ResourceLocation armorTexture = ResourceLocation.fromNamespaceAndPath(id.getNamespace(), "item/" + id.getPath()); - ResourceLocation trimTexture = ResourceLocation.withDefaultNamespace("trims/items/" + armorType + "_trim_" + trimMaterial.location().getPath()); - ResourceLocation currentTrimTexture = ResourceLocation.fromNamespaceAndPath(id.getNamespace(), "item/" + id.getPath() + "_" + trimMaterial.location().getPath() + "_trim"); - - // Make sure the ExistingFileHelper does not throw an IllegalArgumentException - //this.existingFileHelper.trackGenerated(trimTexture, PackType.CLIENT_RESOURCES, ".png", "textures"); - - this.trimmedArmorModel(itemModels, currentTrimTexture, armorTexture, trimTexture); - - this.nonTrimmedArmorModel(itemModels, id, currentTrimTexture, trimValue); - }); - */ - } - - /* - private void trimmedArmorModel(ItemModelGenerators itemModels, ResourceLocation currentTrimTexture, ResourceLocation armorTexture, ResourceLocation trimTexture) - { - this.getBuilder(currentTrimTexture.getPath()) - .parent(new ModelFile.UncheckedModelFile("item/generated")) - .texture("layer0", armorTexture) - .texture("layer1", trimTexture); - } - - private void nonTrimmedArmorModel(ItemModelGenerators itemModels, ResourceLocation id, ResourceLocation currentTrimTexture, float trimValue) - { - this.withExistingParent(id.getPath(), mcLoc("item/generated")) - .override() - .model(new ModelFile.UncheckedModelFile(currentTrimTexture)) - .predicate(mcLoc("trim_type"), trimValue).end() - .texture("layer0", ResourceLocation.fromNamespaceAndPath(id.getNamespace(), "item/" + id.getPath())); } - */ }