diff --git a/patches/api/Option-to-prevent-NBT-copy-in-smithing-recipes.patch b/patches/api/Option-to-prevent-data-components-copy-in-smithing-r.patch similarity index 77% rename from patches/api/Option-to-prevent-NBT-copy-in-smithing-recipes.patch rename to patches/api/Option-to-prevent-data-components-copy-in-smithing-r.patch index 9fd924ec24..40ad864f46 100644 --- a/patches/api/Option-to-prevent-NBT-copy-in-smithing-recipes.patch +++ b/patches/api/Option-to-prevent-data-components-copy-in-smithing-r.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Jake Potrebic <jake.m.potrebic@gmail.com> Date: Sun, 26 Sep 2021 12:57:35 -0700 -Subject: [PATCH] Option to prevent NBT copy in smithing recipes +Subject: [PATCH] Option to prevent data components copy in smithing recipes diff --git a/src/main/java/org/bukkit/inventory/SmithingRecipe.java b/src/main/java/org/bukkit/inventory/SmithingRecipe.java @@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 private final ItemStack result; private final RecipeChoice base; private final RecipeChoice addition; -+ private final boolean copyNbt; // Paper ++ private final boolean copyDataComponents; // Paper /** * Create a smithing recipe to produce the specified result ItemStack. @@ -30,12 +30,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param result The item you want the recipe to create. + * @param base The base ingredient + * @param addition The addition ingredient -+ * @param copyNbt whether to copy the nbt from the input base item to the output ++ * @param copyDataComponents whether to copy the data components from the input base item to the output + * @deprecated use {@link SmithingTrimRecipe} or {@link SmithingTransformRecipe} + */ + @Deprecated -+ public SmithingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice base, @NotNull RecipeChoice addition, boolean copyNbt) { -+ this.copyNbt = copyNbt; ++ public SmithingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice base, @NotNull RecipeChoice addition, boolean copyDataComponents) { ++ this.copyDataComponents = copyDataComponents; + // Paper end this.key = key; this.result = result; @@ -47,12 +47,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + // Paper start + /** -+ * Whether or not to copy the NBT of the input base item to the output. ++ * Whether to copy the NBT of the input base item to the output. + * + * @return true to copy the NBT (default for vanilla smithing recipes) ++ * @apiNote use {@link #willCopyDataComponents()} + */ ++ @org.jetbrains.annotations.ApiStatus.Obsolete(since = "1.20.5") + public boolean willCopyNbt() { -+ return copyNbt; ++ return this.willCopyDataComponents(); ++ } ++ ++ /** ++ * Whether to copy the data components of the input base item to the output. ++ * ++ * @return true to copy the data components (default for vanilla smithing recipes) ++ */ ++ public boolean willCopyDataComponents() { ++ return this.copyDataComponents; + } + // Paper end } @@ -73,10 +84,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param template The template item. + * @param base The base ingredient + * @param addition The addition ingredient -+ * @param copyNbt whether to copy the nbt from the input base item to the output ++ * @param copyDataComponents whether to copy the data components from the input base item to the output + */ -+ public SmithingTransformRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice template, @NotNull RecipeChoice base, @NotNull RecipeChoice addition, boolean copyNbt) { -+ super(key, result, base, addition, copyNbt); ++ public SmithingTransformRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice template, @NotNull RecipeChoice base, @NotNull RecipeChoice addition, boolean copyDataComponents) { ++ super(key, result, base, addition, copyDataComponents); + this.template = template; + } + // Paper end @@ -99,10 +110,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param template The template item. + * @param base The base ingredient + * @param addition The addition ingredient -+ * @param copyNbt whether to copy the nbt from the input base item to the output ++ * @param copyDataComponents whether to copy the data components from the input base item to the output + */ -+ public SmithingTrimRecipe(@NotNull NamespacedKey key, @NotNull RecipeChoice template, @NotNull RecipeChoice base, @NotNull RecipeChoice addition, boolean copyNbt) { -+ super(key, new ItemStack(Material.AIR), base, addition, copyNbt); ++ public SmithingTrimRecipe(@NotNull NamespacedKey key, @NotNull RecipeChoice template, @NotNull RecipeChoice base, @NotNull RecipeChoice addition, boolean copyDataComponents) { ++ super(key, new ItemStack(Material.AIR), base, addition, copyDataComponents); + this.template = template; + } + // Paper end diff --git a/patches/server/Option-to-prevent-NBT-copy-in-smithing-recipes.patch b/patches/server/Option-to-prevent-data-components-copy-in-smithing-r.patch similarity index 78% rename from patches/server/Option-to-prevent-NBT-copy-in-smithing-recipes.patch rename to patches/server/Option-to-prevent-data-components-copy-in-smithing-r.patch index a6d25dfd60..dd95527fed 100644 --- a/patches/server/Option-to-prevent-NBT-copy-in-smithing-recipes.patch +++ b/patches/server/Option-to-prevent-data-components-copy-in-smithing-r.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Jake Potrebic <jake.m.potrebic@gmail.com> Date: Sun, 26 Sep 2021 12:57:28 -0700 -Subject: [PATCH] Option to prevent NBT copy in smithing recipes +Subject: [PATCH] Option to prevent data components copy in smithing recipes diff --git a/src/main/java/net/minecraft/world/item/crafting/SmithingTransformRecipe.java b/src/main/java/net/minecraft/world/item/crafting/SmithingTransformRecipe.java @@ -12,15 +12,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 final Ingredient base; final Ingredient addition; final ItemStack result; -+ final boolean copyNBT; // Paper - Option to prevent NBT copy ++ final boolean copyDataComponents; // Paper - Option to prevent data components copy public SmithingTransformRecipe(Ingredient template, Ingredient base, Ingredient addition, ItemStack result) { -+ // Paper start - Option to prevent NBT copy ++ // Paper start - Option to prevent data components copy + this(template, base, addition, result, true); + } -+ public SmithingTransformRecipe(Ingredient template, Ingredient base, Ingredient addition, ItemStack result, boolean copyNBT) { -+ this.copyNBT = copyNBT; -+ // Paper end - Option to prevent NBT copy ++ public SmithingTransformRecipe(Ingredient template, Ingredient base, Ingredient addition, ItemStack result, boolean copyDataComponents) { ++ this.copyDataComponents = copyDataComponents; ++ // Paper end - Option to prevent data components copy this.template = template; this.base = base; this.addition = addition; @@ -28,9 +28,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public ItemStack assemble(Container inventory, HolderLookup.Provider lookup) { ItemStack itemstack = inventory.getItem(1).transmuteCopy(this.result.getItem(), this.result.getCount()); -+ if (this.copyNBT) { // Paper - Option to prevent NBT copy ++ if (this.copyDataComponents) { // Paper - Option to prevent data components copy itemstack.applyComponents(this.result.getComponentsPatch()); -+ } // Paper - Option to prevent NBT copy ++ } // Paper - Option to prevent data components copy return itemstack; } @@ -39,7 +39,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 CraftItemStack result = CraftItemStack.asCraftMirror(this.result); - CraftSmithingTransformRecipe recipe = new CraftSmithingTransformRecipe(id, result, CraftRecipe.toBukkit(this.template), CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition)); -+ CraftSmithingTransformRecipe recipe = new CraftSmithingTransformRecipe(id, result, CraftRecipe.toBukkit(this.template), CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition), this.copyNBT); // Paper - Option to prevent NBT copy ++ CraftSmithingTransformRecipe recipe = new CraftSmithingTransformRecipe(id, result, CraftRecipe.toBukkit(this.template), CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition), this.copyDataComponents); // Paper - Option to prevent data components copy return recipe; } @@ -51,15 +51,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 final Ingredient template; final Ingredient base; final Ingredient addition; -+ final boolean copyNbt; // Paper - Option to prevent NBT copy ++ final boolean copyDataComponents; // Paper - Option to prevent data components copy public SmithingTrimRecipe(Ingredient template, Ingredient base, Ingredient addition) { -+ // Paper start - Option to prevent NBT copy ++ // Paper start - Option to prevent data components copy + this(template, base, addition, true); + } -+ public SmithingTrimRecipe(Ingredient template, Ingredient base, Ingredient addition, boolean copyNbt) { -+ this.copyNbt = copyNbt; -+ // Paper end - Option to prevent NBT copy ++ public SmithingTrimRecipe(Ingredient template, Ingredient base, Ingredient addition, boolean copyDataComponents) { ++ this.copyDataComponents = copyDataComponents; ++ // Paper end - Option to prevent data components copy this.template = template; this.base = base; this.addition = addition; @@ -68,7 +68,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } - ItemStack itemstack1 = itemstack.copyWithCount(1); -+ ItemStack itemstack1 = this.copyNbt ? itemstack.copyWithCount(1) : new ItemStack(itemstack.getItem(), 1); // Paper - Option to prevent NBT copy ++ ItemStack itemstack1 = this.copyDataComponents ? itemstack.copyWithCount(1) : new ItemStack(itemstack.getItem(), 1); // Paper - Option to prevent data components copy itemstack1.set(DataComponents.TRIM, new ArmorTrim((Holder) optional.get(), (Holder) optional1.get())); return itemstack1; @@ -77,7 +77,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public Recipe toBukkitRecipe(NamespacedKey id) { - return new CraftSmithingTrimRecipe(id, CraftRecipe.toBukkit(this.template), CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition)); -+ return new CraftSmithingTrimRecipe(id, CraftRecipe.toBukkit(this.template), CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition), this.copyNbt); // Paper - Option to prevent NBT copy ++ return new CraftSmithingTrimRecipe(id, CraftRecipe.toBukkit(this.template), CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition), this.copyDataComponents); // Paper - Option to prevent data components copy } // CraftBukkit end @@ -89,18 +89,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public CraftSmithingTransformRecipe(NamespacedKey key, ItemStack result, RecipeChoice template, RecipeChoice base, RecipeChoice addition) { super(key, result, template, base, addition); } -+ // Paper start - Option to prevent NBT copy -+ public CraftSmithingTransformRecipe(NamespacedKey key, ItemStack result, RecipeChoice template, RecipeChoice base, RecipeChoice addition, boolean copyNbt) { -+ super(key, result, template, base, addition, copyNbt); ++ // Paper start - Option to prevent data components copy ++ public CraftSmithingTransformRecipe(NamespacedKey key, ItemStack result, RecipeChoice template, RecipeChoice base, RecipeChoice addition, boolean copyDataComponents) { ++ super(key, result, template, base, addition, copyDataComponents); + } -+ // Paper end - Option to prevent NBT copy ++ // Paper end - Option to prevent data components copy public static CraftSmithingTransformRecipe fromBukkitRecipe(SmithingTransformRecipe recipe) { if (recipe instanceof CraftSmithingTransformRecipe) { return (CraftSmithingTransformRecipe) recipe; } - CraftSmithingTransformRecipe ret = new CraftSmithingTransformRecipe(recipe.getKey(), recipe.getResult(), recipe.getTemplate(), recipe.getBase(), recipe.getAddition()); -+ CraftSmithingTransformRecipe ret = new CraftSmithingTransformRecipe(recipe.getKey(), recipe.getResult(), recipe.getTemplate(), recipe.getBase(), recipe.getAddition(), recipe.willCopyNbt()); // Paper - Option to prevent NBT copy ++ CraftSmithingTransformRecipe ret = new CraftSmithingTransformRecipe(recipe.getKey(), recipe.getResult(), recipe.getTemplate(), recipe.getBase(), recipe.getAddition(), recipe.willCopyDataComponents()); // Paper - Option to prevent data components copy return ret; } @@ -109,7 +109,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 ItemStack result = this.getResult(); - MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTransformRecipe(this.toNMS(this.getTemplate(), true), this.toNMS(this.getBase(), true), this.toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result)))); -+ MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTransformRecipe(this.toNMS(this.getTemplate(), true), this.toNMS(this.getBase(), true), this.toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result), this.willCopyNbt()))); // Paper - Option to prevent NBT copy ++ MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTransformRecipe(this.toNMS(this.getTemplate(), true), this.toNMS(this.getBase(), true), this.toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result), this.willCopyDataComponents()))); // Paper - Option to prevent data components copy } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java @@ -120,24 +120,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public CraftSmithingTrimRecipe(NamespacedKey key, RecipeChoice template, RecipeChoice base, RecipeChoice addition) { super(key, template, base, addition); } -+ // Paper start - Option to prevent NBT copy -+ public CraftSmithingTrimRecipe(NamespacedKey key, RecipeChoice template, RecipeChoice base, RecipeChoice addition, boolean copyNbt) { -+ super(key, template, base, addition, copyNbt); ++ // Paper start - Option to prevent data components copy ++ public CraftSmithingTrimRecipe(NamespacedKey key, RecipeChoice template, RecipeChoice base, RecipeChoice addition, boolean copyDataComponents) { ++ super(key, template, base, addition, copyDataComponents); + } -+ // Paper end - Option to prevent NBT copy ++ // Paper end - Option to prevent data components copy public static CraftSmithingTrimRecipe fromBukkitRecipe(SmithingTrimRecipe recipe) { if (recipe instanceof CraftSmithingTrimRecipe) { return (CraftSmithingTrimRecipe) recipe; } - CraftSmithingTrimRecipe ret = new CraftSmithingTrimRecipe(recipe.getKey(), recipe.getTemplate(), recipe.getBase(), recipe.getAddition()); -+ CraftSmithingTrimRecipe ret = new CraftSmithingTrimRecipe(recipe.getKey(), recipe.getTemplate(), recipe.getBase(), recipe.getAddition(), recipe.willCopyNbt()); // Paper - Option to prevent NBT copy ++ CraftSmithingTrimRecipe ret = new CraftSmithingTrimRecipe(recipe.getKey(), recipe.getTemplate(), recipe.getBase(), recipe.getAddition(), recipe.willCopyDataComponents()); // Paper - Option to prevent data components copy return ret; } @Override public void addToCraftingManager() { - MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTrimRecipe(this.toNMS(this.getTemplate(), true), this.toNMS(this.getBase(), true), this.toNMS(this.getAddition(), true)))); -+ MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTrimRecipe(this.toNMS(this.getTemplate(), true), this.toNMS(this.getBase(), true), this.toNMS(this.getAddition(), true), this.willCopyNbt()))); // Paper - Option to prevent NBT copy ++ MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTrimRecipe(this.toNMS(this.getTemplate(), true), this.toNMS(this.getBase(), true), this.toNMS(this.getAddition(), true), this.willCopyDataComponents()))); // Paper - Option to prevent data components copy } }