--- a/net/minecraft/world/item/crafting/SmithingTrimRecipe.java
+++ b/net/minecraft/world/item/crafting/SmithingTrimRecipe.java
@@ -17,13 +17,27 @@
 import net.minecraft.world.item.armortrim.TrimPattern;
 import net.minecraft.world.item.armortrim.TrimPatterns;
 import net.minecraft.world.level.Level;
+// CraftBukkit start
+import org.bukkit.NamespacedKey;
+import org.bukkit.craftbukkit.v1_20_R2.inventory.CraftRecipe;
+import org.bukkit.craftbukkit.v1_20_R2.inventory.CraftSmithingTrimRecipe;
+import org.bukkit.inventory.Recipe;
+// CraftBukkit end
 
 public class SmithingTrimRecipe implements SmithingRecipe {
+
     final Ingredient template;
     final Ingredient base;
     final Ingredient addition;
+    final boolean copyNbt; // Paper
 
     public SmithingTrimRecipe(Ingredient template, Ingredient base, Ingredient addition) {
+        // Paper start
+        this(template, base, addition, true);
+    }
+    public SmithingTrimRecipe(Ingredient template, Ingredient base, Ingredient addition, boolean copyNbt) {
+        this.copyNbt = copyNbt;
+        // Paper end
         this.template = template;
         this.base = base;
         this.addition = addition;
@@ -36,21 +50,26 @@
 
     @Override
     public ItemStack assemble(Container inventory, RegistryAccess registryManager) {
-        ItemStack itemStack = inventory.getItem(1);
-        if (this.base.test(itemStack)) {
+        ItemStack itemstack = inventory.getItem(1);
+
+        if (this.base.test(itemstack)) {
             Optional<Holder.Reference<TrimMaterial>> optional = TrimMaterials.getFromIngredient(registryManager, inventory.getItem(2));
-            Optional<Holder.Reference<TrimPattern>> optional2 = TrimPatterns.getFromTemplate(registryManager, inventory.getItem(0));
-            if (optional.isPresent() && optional2.isPresent()) {
-                Optional<ArmorTrim> optional3 = ArmorTrim.getTrim(registryManager, itemStack, false);
-                if (optional3.isPresent() && optional3.get().hasPatternAndMaterial(optional2.get(), optional.get())) {
+            Optional<Holder.Reference<TrimPattern>> optional1 = TrimPatterns.getFromTemplate(registryManager, inventory.getItem(0));
+
+            if (optional.isPresent() && optional1.isPresent()) {
+                Optional<ArmorTrim> optional2 = ArmorTrim.getTrim(registryManager, itemstack, false);
+
+                if (optional2.isPresent() && ((ArmorTrim) optional2.get()).hasPatternAndMaterial((Holder) optional1.get(), (Holder) optional.get())) {
                     return ItemStack.EMPTY;
                 }
 
-                ItemStack itemStack2 = itemStack.copy();
-                itemStack2.setCount(1);
-                ArmorTrim armorTrim = new ArmorTrim(optional.get(), optional2.get());
-                if (ArmorTrim.setTrim(registryManager, itemStack2, armorTrim)) {
-                    return itemStack2;
+                ItemStack itemstack1 = this.copyNbt ? itemstack.copy() : new ItemStack(itemstack.getItem(), itemstack.getCount()); // Paper
+
+                itemstack1.setCount(1);
+                ArmorTrim armortrim = new ArmorTrim((Holder) optional.get(), (Holder) optional1.get());
+
+                if (ArmorTrim.setTrim(registryManager, itemstack1, armortrim)) {
+                    return itemstack1;
                 }
             }
         }
@@ -60,17 +79,20 @@
 
     @Override
     public ItemStack getResultItem(RegistryAccess registryManager) {
-        ItemStack itemStack = new ItemStack(Items.IRON_CHESTPLATE);
+        ItemStack itemstack = new ItemStack(Items.IRON_CHESTPLATE);
         Optional<Holder.Reference<TrimPattern>> optional = registryManager.registryOrThrow(Registries.TRIM_PATTERN).holders().findFirst();
+
         if (optional.isPresent()) {
-            Optional<Holder.Reference<TrimMaterial>> optional2 = registryManager.registryOrThrow(Registries.TRIM_MATERIAL).getHolder(TrimMaterials.REDSTONE);
-            if (optional2.isPresent()) {
-                ArmorTrim armorTrim = new ArmorTrim(optional2.get(), optional.get());
-                ArmorTrim.setTrim(registryManager, itemStack, armorTrim);
+            Optional<Holder.Reference<TrimMaterial>> optional1 = registryManager.registryOrThrow(Registries.TRIM_MATERIAL).getHolder(TrimMaterials.REDSTONE);
+
+            if (optional1.isPresent()) {
+                ArmorTrim armortrim = new ArmorTrim((Holder) optional1.get(), (Holder) optional.get());
+
+                ArmorTrim.setTrim(registryManager, itemstack, armortrim);
             }
         }
 
-        return itemStack;
+        return itemstack;
     }
 
     @Override
@@ -98,31 +120,41 @@
         return Stream.of(this.template, this.base, this.addition).anyMatch(Ingredient::isEmpty);
     }
 
+    // CraftBukkit start
+    @Override
+    public Recipe toBukkitRecipe(NamespacedKey id) {
+        return new CraftSmithingTrimRecipe(id, CraftRecipe.toBukkit(this.template), CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition), this.copyNbt); // Paper
+    }
+    // CraftBukkit end
+
     public static class Serializer implements RecipeSerializer<SmithingTrimRecipe> {
+
         private static final Codec<SmithingTrimRecipe> CODEC = RecordCodecBuilder.create((instance) -> {
-            return instance.group(Ingredient.CODEC.fieldOf("template").forGetter((recipe) -> {
-                return recipe.template;
-            }), Ingredient.CODEC.fieldOf("base").forGetter((recipe) -> {
-                return recipe.base;
-            }), Ingredient.CODEC.fieldOf("addition").forGetter((recipe) -> {
-                return recipe.addition;
+            return instance.group(Ingredient.CODEC.fieldOf("template").forGetter((smithingtrimrecipe) -> {
+                return smithingtrimrecipe.template;
+            }), Ingredient.CODEC.fieldOf("base").forGetter((smithingtrimrecipe) -> {
+                return smithingtrimrecipe.base;
+            }), Ingredient.CODEC.fieldOf("addition").forGetter((smithingtrimrecipe) -> {
+                return smithingtrimrecipe.addition;
             })).apply(instance, SmithingTrimRecipe::new);
         });
 
+        public Serializer() {}
+
         @Override
         public Codec<SmithingTrimRecipe> codec() {
-            return CODEC;
+            return SmithingTrimRecipe.Serializer.CODEC;
         }
 
         @Override
-        public SmithingTrimRecipe fromNetwork(FriendlyByteBuf friendlyByteBuf) {
-            Ingredient ingredient = Ingredient.fromNetwork(friendlyByteBuf);
-            Ingredient ingredient2 = Ingredient.fromNetwork(friendlyByteBuf);
-            Ingredient ingredient3 = Ingredient.fromNetwork(friendlyByteBuf);
-            return new SmithingTrimRecipe(ingredient, ingredient2, ingredient3);
+        public SmithingTrimRecipe fromNetwork(FriendlyByteBuf buf) {
+            Ingredient recipeitemstack = Ingredient.fromNetwork(buf);
+            Ingredient recipeitemstack1 = Ingredient.fromNetwork(buf);
+            Ingredient recipeitemstack2 = Ingredient.fromNetwork(buf);
+
+            return new SmithingTrimRecipe(recipeitemstack, recipeitemstack1, recipeitemstack2);
         }
 
-        @Override
         public void toNetwork(FriendlyByteBuf buf, SmithingTrimRecipe recipe) {
             recipe.template.toNetwork(buf);
             recipe.base.toNetwork(buf);
