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 p_368813_) { register(p_368813_, QUARTZ, Style.EMPTY.withColor(14931140), MaterialAssetGroup.QUARTZ); register(p_368813_, IRON, Style.EMPTY.withColor(15527148), MaterialAssetGroup.IRON); register(p_368813_, NETHERITE, Style.EMPTY.withColor(6445145), MaterialAssetGroup.NETHERITE); register(p_368813_, REDSTONE, Style.EMPTY.withColor(9901575), MaterialAssetGroup.REDSTONE); register(p_368813_, COPPER, Style.EMPTY.withColor(11823181), MaterialAssetGroup.COPPER); register(p_368813_, GOLD, Style.EMPTY.withColor(14594349), MaterialAssetGroup.GOLD); register(p_368813_, EMERALD, Style.EMPTY.withColor(1155126), MaterialAssetGroup.EMERALD); register(p_368813_, DIAMOND, Style.EMPTY.withColor(7269586), MaterialAssetGroup.DIAMOND); register(p_368813_, LAPIS, Style.EMPTY.withColor(4288151), MaterialAssetGroup.LAPIS); register(p_368813_, AMETHYST, Style.EMPTY.withColor(10116294), MaterialAssetGroup.AMETHYST); register(p_368813_, RESIN, Style.EMPTY.withColor(16545810), MaterialAssetGroup.RESIN); } public static Optional> getFromIngredient(HolderLookup.Provider p_363557_, ItemStack p_369735_) { ProvidesTrimMaterial providestrimmaterial = p_369735_.get(DataComponents.PROVIDES_TRIM_MATERIAL); return providestrimmaterial != null ? providestrimmaterial.unwrap(p_363557_) : Optional.empty(); } private static void register(BootstrapContext p_369807_, ResourceKey p_365636_, Style p_361695_, MaterialAssetGroup p_391878_) { Component component = Component.translatable(Util.makeDescriptionId("trim_material", p_365636_.location())).withStyle(p_361695_); p_369807_.register(p_365636_, new TrimMaterial(p_391878_, component)); } private static ResourceKey registryKey(String p_360778_) { return ResourceKey.create(Registries.TRIM_MATERIAL, ResourceLocation.withDefaultNamespace(p_360778_)); } }