Skip to content

Commit

Permalink
🚧 Fix datagen, equipment models, and more
Browse files Browse the repository at this point in the history
  • Loading branch information
Autovw committed Nov 1, 2024
1 parent 7dd2b8b commit 3bf25a1
Show file tree
Hide file tree
Showing 90 changed files with 506 additions and 448 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
import com.autovw.advancednetherite.common.item.*;
import com.autovw.advancednetherite.core.util.ModArmorMaterials;
import com.autovw.advancednetherite.core.util.ModToolMaterials;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.equipment.ArmorType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,23 @@
*/
public final class ModEquipmentModels
{
public static final EquipmentModel NETHERITE_IRON = humanoidModel(key("netherite_iron"));
public static final EquipmentModel NETHERITE_GOLD = humanoidModel(key("netherite_gold"));
public static final EquipmentModel NETHERITE_EMERALD = humanoidModel(key("netherite_emerald"));
public static final EquipmentModel NETHERITE_DIAMOND = humanoidModel(key("netherite_diamond"));
public static final ResourceLocation ID_NETHERITE_IRON = key("netherite_iron");
public static final ResourceLocation ID_NETHERITE_GOLD = key("netherite_gold");
public static final ResourceLocation ID_NETHERITE_EMERALD = key("netherite_emerald");
public static final ResourceLocation ID_NETHERITE_DIAMOND = key("netherite_diamond");

public static final EquipmentModel NETHERITE_IRON = humanoidModel(ID_NETHERITE_IRON);
public static final EquipmentModel NETHERITE_GOLD = humanoidModel(ID_NETHERITE_GOLD);
public static final EquipmentModel NETHERITE_EMERALD = humanoidModel(ID_NETHERITE_EMERALD);
public static final EquipmentModel NETHERITE_DIAMOND = humanoidModel(ID_NETHERITE_DIAMOND);

/*
public static void bootstrap(BiConsumer<ResourceLocation, EquipmentModel> consumer)
{
consumer.accept(NETHERITE_IRON, humanoidModel(NETHERITE_IRON));
consumer.accept(NETHERITE_GOLD, humanoidModel(NETHERITE_GOLD));
consumer.accept(NETHERITE_EMERALD, humanoidModel(NETHERITE_EMERALD));
consumer.accept(NETHERITE_DIAMOND, humanoidModel(NETHERITE_DIAMOND));
consumer.accept(ID_NETHERITE_IRON, NETHERITE_IRON);
consumer.accept(ID_NETHERITE_GOLD, NETHERITE_GOLD);
consumer.accept(ID_NETHERITE_EMERALD, NETHERITE_EMERALD);
consumer.accept(ID_NETHERITE_DIAMOND, NETHERITE_DIAMOND);
}
*/

private static EquipmentModel humanoidModel(ResourceLocation location)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"layers": {
"humanoid": [
{
"texture": "advancednetherite:netherite_diamond"
}
],
"humanoid_leggings": [
{
"texture": "advancednetherite:netherite_diamond"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"layers": {
"humanoid": [
{
"texture": "advancednetherite:netherite_emerald"
}
],
"humanoid_leggings": [
{
"texture": "advancednetherite:netherite_emerald"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"layers": {
"humanoid": [
{
"texture": "advancednetherite:netherite_gold"
}
],
"humanoid_leggings": [
{
"texture": "advancednetherite:netherite_gold"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"layers": {
"humanoid": [
{
"texture": "advancednetherite:netherite_iron"
}
],
"humanoid_leggings": [
{
"texture": "advancednetherite:netherite_iron"
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.autovw.advancednetherite.datagen.providers.*;
import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint;
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
import net.minecraft.data.DataGenerator;

/**
* @author Autovw
Expand All @@ -21,5 +22,8 @@ public void onInitializeDataGenerator(FabricDataGenerator generator)
pack.addProvider(ModBlockTagsProvider::new);
pack.addProvider(ModItemTagsProvider::new);
pack.addProvider(ModEnchantmentTagsProvider::new);

DataGenerator.PackGenerator secondaryPack = generator.createPack();
secondaryPack.addProvider(ModEquipmentModelProvider::new);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.autovw.advancednetherite.datagen.providers;

import com.autovw.advancednetherite.core.util.ModEquipmentModels;
import net.minecraft.data.CachedOutput;
import net.minecraft.data.DataProvider;
import net.minecraft.data.PackOutput;
import net.minecraft.data.models.EquipmentModelProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.equipment.EquipmentModel;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CompletableFuture;

/**
* @author Autovw
*/
public class ModEquipmentModelProvider extends EquipmentModelProvider
{
protected final PackOutput.PathProvider pathProvider;

public ModEquipmentModelProvider(PackOutput packOutput)
{
super(packOutput);
this.pathProvider = packOutput.createPathProvider(PackOutput.Target.RESOURCE_PACK, "models/equipment");
}

@Override
public CompletableFuture<?> run(CachedOutput output)
{
Map<ResourceLocation, EquipmentModel> map = new HashMap<>();
ModEquipmentModels.bootstrap((id, model) -> {
if (map.putIfAbsent(id, model) != null)
{
throw new IllegalStateException("Duplicate equipment model for id: " + id.toString());
}
});
return DataProvider.saveAll(output, EquipmentModel.CODEC, this.pathProvider, map);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"layers": {
"humanoid": [
{
"texture": "advancednetherite:netherite_diamond"
}
],
"humanoid_leggings": [
{
"texture": "advancednetherite:netherite_diamond"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"layers": {
"humanoid": [
{
"texture": "advancednetherite:netherite_emerald"
}
],
"humanoid_leggings": [
{
"texture": "advancednetherite:netherite_emerald"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"layers": {
"humanoid": [
{
"texture": "advancednetherite:netherite_gold"
}
],
"humanoid_leggings": [
{
"texture": "advancednetherite:netherite_gold"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"layers": {
"humanoid": [
{
"texture": "advancednetherite:netherite_iron"
}
],
"humanoid_leggings": [
{
"texture": "advancednetherite:netherite_iron"
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public static void onGatherData(final GatherDataEvent event)

// client
generator.addProvider(event.includeClient(), new ModBlockStatesProvider(packOutput, AdvancedNetherite.MOD_ID, helper));
generator.addProvider(event.includeClient(), new ModEquipmentModelProvider(packOutput));
generator.addProvider(event.includeClient(), new ModItemModelProvider(packOutput, AdvancedNetherite.MOD_ID, helper));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.autovw.advancednetherite.datagen.providers;

import com.autovw.advancednetherite.core.util.ModEquipmentModels;
import net.minecraft.data.CachedOutput;
import net.minecraft.data.DataProvider;
import net.minecraft.data.PackOutput;
import net.minecraft.data.models.EquipmentModelProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.equipment.EquipmentModel;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CompletableFuture;

/**
* @author Autovw
*/
public class ModEquipmentModelProvider extends EquipmentModelProvider
{
protected final PackOutput.PathProvider pathProvider;

public ModEquipmentModelProvider(PackOutput packOutput)
{
super(packOutput);
this.pathProvider = packOutput.createPathProvider(PackOutput.Target.RESOURCE_PACK, "models/equipment");
}

@Override
public CompletableFuture<?> run(CachedOutput output)
{
Map<ResourceLocation, EquipmentModel> map = new HashMap<>();
ModEquipmentModels.bootstrap((id, model) -> {
if (map.putIfAbsent(id, model) != null)
{
throw new IllegalStateException("Duplicate equipment model for id: " + id.toString());
}
});
return DataProvider.saveAll(output, EquipmentModel.CODEC, this.pathProvider, map);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,15 @@ public void armorModel(Item item)
TRIM_MATERIALS.forEach((trimMaterial, trimValue) ->
{
ResourceLocation id = AdvancedNetherite.getRegistryHelper().getItemById(armorItem);
String armorType = switch (armorItem.getEquipmentSlot(armorItem.getDefaultInstance()))
{
case HEAD -> "helmet";
case CHEST -> "chestplate";
case LEGS -> "leggings";
case FEET -> "boots";
default -> "";
};
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());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"layers": {
"humanoid": [
{
"texture": "advancednetherite:netherite_diamond"
}
],
"humanoid_leggings": [
{
"texture": "advancednetherite:netherite_diamond"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"layers": {
"humanoid": [
{
"texture": "advancednetherite:netherite_emerald"
}
],
"humanoid_leggings": [
{
"texture": "advancednetherite:netherite_emerald"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"layers": {
"humanoid": [
{
"texture": "advancednetherite:netherite_gold"
}
],
"humanoid_leggings": [
{
"texture": "advancednetherite:netherite_gold"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"layers": {
"humanoid": [
{
"texture": "advancednetherite:netherite_iron"
}
],
"humanoid_leggings": [
{
"texture": "advancednetherite:netherite_iron"
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
"type": "minecraft:crafting_shaped",
"category": "misc",
"key": {
"#": {
"tag": "advancednetherite:netherite_ingots"
},
"S": {
"item": "minecraft:chiseled_stone_bricks"
}
"#": "#advancednetherite:netherite_ingots",
"S": "minecraft:chiseled_stone_bricks"
},
"pattern": [
"SSS",
Expand Down
Loading

0 comments on commit 3bf25a1

Please sign in to comment.