package net.minecraft.world.item.equipment.trim; import java.util.Optional; import net.minecraft.Util; import net.minecraft.core.Holder; import net.minecraft.core.HolderLookup; import net.minecraft.core.component.DataComponents; import net.minecraft.core.registries.Registries; import net.minecraft.data.worldgen.BootstrapContext; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Style; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.component.ProvidesTrimMaterial; public class TrimMaterials { public static final ResourceKey QUARTZ = registryKey("quartz"); public static final ResourceKey IRON = registryKey("iron"); public static final ResourceKey NETHERITE = registryKey("netherite"); public static final ResourceKey REDSTONE = registryKey("redstone"); public static final ResourceKey COPPER = registryKey("copper"); public static final ResourceKey GOLD = registryKey("gold"); public static final ResourceKey EMERALD = registryKey("emerald"); public static final ResourceKey DIAMOND = registryKey("diamond"); public static final ResourceKey LAPIS = registryKey("lapis"); public static final ResourceKey AMETHYST = registryKey("amethyst"); public static final ResourceKey RESIN = registryKey("resin"); public static void bootstrap(BootstrapContext context) { register(context, QUARTZ, Style.EMPTY.withColor(14931140), MaterialAssetGroup.QUARTZ); register(context, IRON, Style.EMPTY.withColor(15527148), MaterialAssetGroup.IRON); register(context, NETHERITE, Style.EMPTY.withColor(6445145), MaterialAssetGroup.NETHERITE); register(context, REDSTONE, Style.EMPTY.withColor(9901575), MaterialAssetGroup.REDSTONE); register(context, COPPER, Style.EMPTY.withColor(11823181), MaterialAssetGroup.COPPER); register(context, GOLD, Style.EMPTY.withColor(14594349), MaterialAssetGroup.GOLD); register(context, EMERALD, Style.EMPTY.withColor(1155126), MaterialAssetGroup.EMERALD); register(context, DIAMOND, Style.EMPTY.withColor(7269586), MaterialAssetGroup.DIAMOND); register(context, LAPIS, Style.EMPTY.withColor(4288151), MaterialAssetGroup.LAPIS); register(context, AMETHYST, Style.EMPTY.withColor(10116294), MaterialAssetGroup.AMETHYST); register(context, RESIN, Style.EMPTY.withColor(16545810), MaterialAssetGroup.RESIN); } public static Optional> getFromIngredient(HolderLookup.Provider registries, ItemStack ingredient) { ProvidesTrimMaterial providesTrimMaterial = ingredient.get(DataComponents.PROVIDES_TRIM_MATERIAL); return providesTrimMaterial != null ? providesTrimMaterial.unwrap(registries) : Optional.empty(); } private static void register(BootstrapContext context, ResourceKey key, Style style, MaterialAssetGroup assets) { Component component = Component.translatable(Util.makeDescriptionId("trim_material", key.location())).withStyle(style); context.register(key, new TrimMaterial(assets, component)); } private static ResourceKey registryKey(String name) { return ResourceKey.create(Registries.TRIM_MATERIAL, ResourceLocation.withDefaultNamespace(name)); } }