Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow datagen to use vanilla armor trim textures #146

Merged
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.armortrim.TrimMaterial;
import net.minecraft.world.item.armortrim.TrimMaterials;
import net.neoforged.neoforge.common.data.ExistingFileHelper;

/**
Expand All @@ -21,10 +24,18 @@
*/
public class ItemModelBuilder extends ModelBuilder<ItemModelBuilder> {

private static final List<ResourceKey<TrimMaterial>> VANILLA_TRIM_MATERIALS = List.of(TrimMaterials.QUARTZ, TrimMaterials.IRON, TrimMaterials.NETHERITE, TrimMaterials.REDSTONE, TrimMaterials.COPPER, TrimMaterials.GOLD, TrimMaterials.EMERALD, TrimMaterials.DIAMOND, TrimMaterials.LAPIS, TrimMaterials.AMETHYST);
protected List<OverrideBuilder> overrides = new ArrayList<>();

public ItemModelBuilder(ResourceLocation outputLocation, ExistingFileHelper existingFileHelper) {
super(outputLocation, existingFileHelper);
//add vanilla armor trims to the existing file helper
for (ResourceKey<TrimMaterial> trim : VANILLA_TRIM_MATERIALS) {
this.existingFileHelper.trackGenerated(new ResourceLocation("trims/items/boots_trim_" + trim.location().getPath()), ModelProvider.TEXTURE);
this.existingFileHelper.trackGenerated(new ResourceLocation("trims/items/chestplate_trim_" + trim.location().getPath()), ModelProvider.TEXTURE);
this.existingFileHelper.trackGenerated(new ResourceLocation("trims/items/helmet_trim_" + trim.location().getPath()), ModelProvider.TEXTURE);
this.existingFileHelper.trackGenerated(new ResourceLocation("trims/items/leggings_trim_" + trim.location().getPath()), ModelProvider.TEXTURE);
}
}

public OverrideBuilder override() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public abstract class ModelProvider<T extends ModelBuilder<T>> implements DataPr
public static final String BLOCK_FOLDER = "block";
public static final String ITEM_FOLDER = "item";

protected static final ResourceType TEXTURE = new ResourceType(PackType.CLIENT_RESOURCES, ".png", "textures");
public static final ResourceType TEXTURE = new ResourceType(PackType.CLIENT_RESOURCES, ".png", "textures");
protected static final ResourceType MODEL = new ResourceType(PackType.CLIENT_RESOURCES, ".json", "models");
protected static final ResourceType MODEL_WITH_EXTENSION = new ResourceType(PackType.CLIENT_RESOURCES, "", "models");

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "minecraft:item/netherite_boots",
"layer1": "minecraft:trims/items/boots_trim_amethyst"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,11 @@ protected void registerModels() {
.parent(new UncheckedModelFile("item/generated"))
.texture("layer0", mcLoc("block/stone"));

getBuilder("test_runtime_texture_model")
.parent(new UncheckedModelFile("item/generated"))
.texture("layer0", mcLoc("item/netherite_boots"))
.texture("layer1", mcLoc("trims/items/boots_trim_amethyst"));

getBuilder("test_block_model")
.parent(getExistingFile(mcLoc("block/block")))
.texture("all", mcLoc("block/dirt"))
Expand Down Expand Up @@ -549,7 +554,7 @@ protected void registerModels() {
.texture("layer0", mcLoc("item/fishing_rod_cast"));
}

private static final Set<String> IGNORED_MODELS = ImmutableSet.of("test_generated_model", "test_block_model",
private static final Set<String> IGNORED_MODELS = ImmutableSet.of("test_generated_model", "test_runtime_texture_model", "test_block_model",
"fishing_rod", "fishing_rod_cast" // Vanilla doesn't generate these yet, so they don't match due to having the minecraft domain
);

Expand Down
Loading