update smithing recipe copy data components API

This commit is contained in:
Jake Potrebic 2024-04-25 08:13:36 -07:00
parent b8da9ac51a
commit ccf158a817
No known key found for this signature in database
GPG key ID: 27CC63F7CBC866C7
2 changed files with 60 additions and 49 deletions

View file

@ -1,18 +1,18 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com> From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Sun, 26 Sep 2021 12:57:35 -0700 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 diff --git a/src/main/java/org/bukkit/inventory/SmithingRecipe.java b/src/main/java/org/bukkit/inventory/SmithingRecipe.java
index 0235f4aa50eb69f87068005c669bd486899025d6..92f6285d87cabde3c1f1690ee4747217c4d098b2 100644 index 0235f4aa50eb69f87068005c669bd486899025d6..1ef9a715a2736e88a16083c6873803a8bd6bcf29 100644
--- a/src/main/java/org/bukkit/inventory/SmithingRecipe.java --- a/src/main/java/org/bukkit/inventory/SmithingRecipe.java
+++ b/src/main/java/org/bukkit/inventory/SmithingRecipe.java +++ b/src/main/java/org/bukkit/inventory/SmithingRecipe.java
@@ -13,6 +13,7 @@ public class SmithingRecipe implements Recipe, Keyed { @@ -13,6 +13,7 @@ public class SmithingRecipe implements Recipe, Keyed {
private final ItemStack result; private final ItemStack result;
private final RecipeChoice base; private final RecipeChoice base;
private final RecipeChoice addition; private final RecipeChoice addition;
+ private final boolean copyNbt; // Paper + private final boolean copyDataComponents; // Paper
/** /**
* Create a smithing recipe to produce the specified result ItemStack. * Create a smithing recipe to produce the specified result ItemStack.
@ -30,34 +30,45 @@ index 0235f4aa50eb69f87068005c669bd486899025d6..92f6285d87cabde3c1f1690ee4747217
+ * @param result The item you want the recipe to create. + * @param result The item you want the recipe to create.
+ * @param base The base ingredient + * @param base The base ingredient
+ * @param addition The addition 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 use {@link SmithingTrimRecipe} or {@link SmithingTransformRecipe}
+ */ + */
+ @Deprecated + @Deprecated
+ public SmithingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice base, @NotNull RecipeChoice addition, boolean copyNbt) { + public SmithingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice base, @NotNull RecipeChoice addition, boolean copyDataComponents) {
+ this.copyNbt = copyNbt; + this.copyDataComponents = copyDataComponents;
+ // Paper end + // Paper end
this.key = key; this.key = key;
this.result = result; this.result = result;
this.base = base; this.base = base;
@@ -65,4 +83,15 @@ public class SmithingRecipe implements Recipe, Keyed { @@ -65,4 +83,26 @@ public class SmithingRecipe implements Recipe, Keyed {
public NamespacedKey getKey() { public NamespacedKey getKey() {
return this.key; return this.key;
} }
+ +
+ // Paper start + // 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) + * @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() { + 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 + // Paper end
} }
diff --git a/src/main/java/org/bukkit/inventory/SmithingTransformRecipe.java b/src/main/java/org/bukkit/inventory/SmithingTransformRecipe.java diff --git a/src/main/java/org/bukkit/inventory/SmithingTransformRecipe.java b/src/main/java/org/bukkit/inventory/SmithingTransformRecipe.java
index 08fd3eca8383cdc2d06c3ce973e8c402d279077e..ad2fc850819c9784d477b59adcc5f5ab32ed4fac 100644 index 08fd3eca8383cdc2d06c3ce973e8c402d279077e..68e7132d77151b7b8312638d8bb79ea59e2fa5a6 100644
--- a/src/main/java/org/bukkit/inventory/SmithingTransformRecipe.java --- a/src/main/java/org/bukkit/inventory/SmithingTransformRecipe.java
+++ b/src/main/java/org/bukkit/inventory/SmithingTransformRecipe.java +++ b/src/main/java/org/bukkit/inventory/SmithingTransformRecipe.java
@@ -23,6 +23,22 @@ public class SmithingTransformRecipe extends SmithingRecipe { @@ -23,6 +23,22 @@ public class SmithingTransformRecipe extends SmithingRecipe {
@ -73,10 +84,10 @@ index 08fd3eca8383cdc2d06c3ce973e8c402d279077e..ad2fc850819c9784d477b59adcc5f5ab
+ * @param template The template item. + * @param template The template item.
+ * @param base The base ingredient + * @param base The base ingredient
+ * @param addition The addition 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) { + public SmithingTransformRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice template, @NotNull RecipeChoice base, @NotNull RecipeChoice addition, boolean copyDataComponents) {
+ super(key, result, base, addition, copyNbt); + super(key, result, base, addition, copyDataComponents);
+ this.template = template; + this.template = template;
+ } + }
+ // Paper end + // Paper end
@ -84,7 +95,7 @@ index 08fd3eca8383cdc2d06c3ce973e8c402d279077e..ad2fc850819c9784d477b59adcc5f5ab
/** /**
* Get the template recipe item. * Get the template recipe item.
diff --git a/src/main/java/org/bukkit/inventory/SmithingTrimRecipe.java b/src/main/java/org/bukkit/inventory/SmithingTrimRecipe.java diff --git a/src/main/java/org/bukkit/inventory/SmithingTrimRecipe.java b/src/main/java/org/bukkit/inventory/SmithingTrimRecipe.java
index 32cbdc342615e76ff7a896e67cb0736b0bdf1978..9e84114528507848a4c1947d677ba02d06f9dc14 100644 index 32cbdc342615e76ff7a896e67cb0736b0bdf1978..ce36bb5b030f17e11f74e987235be143c1925aa7 100644
--- a/src/main/java/org/bukkit/inventory/SmithingTrimRecipe.java --- a/src/main/java/org/bukkit/inventory/SmithingTrimRecipe.java
+++ b/src/main/java/org/bukkit/inventory/SmithingTrimRecipe.java +++ b/src/main/java/org/bukkit/inventory/SmithingTrimRecipe.java
@@ -23,6 +23,21 @@ public class SmithingTrimRecipe extends SmithingRecipe implements ComplexRecipe @@ -23,6 +23,21 @@ public class SmithingTrimRecipe extends SmithingRecipe implements ComplexRecipe
@ -99,10 +110,10 @@ index 32cbdc342615e76ff7a896e67cb0736b0bdf1978..9e84114528507848a4c1947d677ba02d
+ * @param template The template item. + * @param template The template item.
+ * @param base The base ingredient + * @param base The base ingredient
+ * @param addition The addition 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) { + public SmithingTrimRecipe(@NotNull NamespacedKey key, @NotNull RecipeChoice template, @NotNull RecipeChoice base, @NotNull RecipeChoice addition, boolean copyDataComponents) {
+ super(key, new ItemStack(Material.AIR), base, addition, copyNbt); + super(key, new ItemStack(Material.AIR), base, addition, copyDataComponents);
+ this.template = template; + this.template = template;
+ } + }
+ // Paper end + // Paper end

View file

@ -1,26 +1,26 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com> From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Sun, 26 Sep 2021 12:57:28 -0700 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 diff --git a/src/main/java/net/minecraft/world/item/crafting/SmithingTransformRecipe.java b/src/main/java/net/minecraft/world/item/crafting/SmithingTransformRecipe.java
index c6c6d54f35dd75e14a6e040d730d5ae9c1406059..3448bd7882edde4ba76ba8b592b6003009aa5f02 100644 index c6c6d54f35dd75e14a6e040d730d5ae9c1406059..a39a2b2b1a4294cb68cdbc3e67ad3e29552eeec8 100644
--- a/src/main/java/net/minecraft/world/item/crafting/SmithingTransformRecipe.java --- a/src/main/java/net/minecraft/world/item/crafting/SmithingTransformRecipe.java
+++ b/src/main/java/net/minecraft/world/item/crafting/SmithingTransformRecipe.java +++ b/src/main/java/net/minecraft/world/item/crafting/SmithingTransformRecipe.java
@@ -23,8 +23,15 @@ public class SmithingTransformRecipe implements SmithingRecipe { @@ -23,8 +23,15 @@ public class SmithingTransformRecipe implements SmithingRecipe {
final Ingredient base; final Ingredient base;
final Ingredient addition; final Ingredient addition;
final ItemStack result; 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) { 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); + this(template, base, addition, result, true);
+ } + }
+ public SmithingTransformRecipe(Ingredient template, Ingredient base, Ingredient addition, ItemStack result, boolean copyNBT) { + public SmithingTransformRecipe(Ingredient template, Ingredient base, Ingredient addition, ItemStack result, boolean copyDataComponents) {
+ this.copyNBT = copyNBT; + this.copyDataComponents = copyDataComponents;
+ // Paper end - Option to prevent NBT copy + // Paper end - Option to prevent data components copy
this.template = template; this.template = template;
this.base = base; this.base = base;
this.addition = addition; this.addition = addition;
@ -28,9 +28,9 @@ index c6c6d54f35dd75e14a6e040d730d5ae9c1406059..3448bd7882edde4ba76ba8b592b60030
public ItemStack assemble(Container inventory, HolderLookup.Provider lookup) { public ItemStack assemble(Container inventory, HolderLookup.Provider lookup) {
ItemStack itemstack = inventory.getItem(1).transmuteCopy(this.result.getItem(), this.result.getCount()); 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()); itemstack.applyComponents(this.result.getComponentsPatch());
+ } // Paper - Option to prevent NBT copy + } // Paper - Option to prevent data components copy
return itemstack; return itemstack;
} }
@ -39,27 +39,27 @@ index c6c6d54f35dd75e14a6e040d730d5ae9c1406059..3448bd7882edde4ba76ba8b592b60030
CraftItemStack result = CraftItemStack.asCraftMirror(this.result); 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));
+ 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; return recipe;
} }
diff --git a/src/main/java/net/minecraft/world/item/crafting/SmithingTrimRecipe.java b/src/main/java/net/minecraft/world/item/crafting/SmithingTrimRecipe.java diff --git a/src/main/java/net/minecraft/world/item/crafting/SmithingTrimRecipe.java b/src/main/java/net/minecraft/world/item/crafting/SmithingTrimRecipe.java
index f1207df56718ad2a62fb7d567b397ceaa668e1e7..1206a581b5b10ee67411551be359a90b1078c9b8 100644 index f1207df56718ad2a62fb7d567b397ceaa668e1e7..45a7ad173b7025305ce83b51f94e2af47644b829 100644
--- a/src/main/java/net/minecraft/world/item/crafting/SmithingTrimRecipe.java --- a/src/main/java/net/minecraft/world/item/crafting/SmithingTrimRecipe.java
+++ b/src/main/java/net/minecraft/world/item/crafting/SmithingTrimRecipe.java +++ b/src/main/java/net/minecraft/world/item/crafting/SmithingTrimRecipe.java
@@ -31,8 +31,15 @@ public class SmithingTrimRecipe implements SmithingRecipe { @@ -31,8 +31,15 @@ public class SmithingTrimRecipe implements SmithingRecipe {
final Ingredient template; final Ingredient template;
final Ingredient base; final Ingredient base;
final Ingredient addition; 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) { 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); + this(template, base, addition, true);
+ } + }
+ public SmithingTrimRecipe(Ingredient template, Ingredient base, Ingredient addition, boolean copyNbt) { + public SmithingTrimRecipe(Ingredient template, Ingredient base, Ingredient addition, boolean copyDataComponents) {
+ this.copyNbt = copyNbt; + this.copyDataComponents = copyDataComponents;
+ // Paper end - Option to prevent NBT copy + // Paper end - Option to prevent data components copy
this.template = template; this.template = template;
this.base = base; this.base = base;
this.addition = addition; this.addition = addition;
@ -68,7 +68,7 @@ index f1207df56718ad2a62fb7d567b397ceaa668e1e7..1206a581b5b10ee67411551be359a90b
} }
- ItemStack itemstack1 = itemstack.copyWithCount(1); - 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())); itemstack1.set(DataComponents.TRIM, new ArmorTrim((Holder) optional.get(), (Holder) optional1.get()));
return itemstack1; return itemstack1;
@ -77,30 +77,30 @@ index f1207df56718ad2a62fb7d567b397ceaa668e1e7..1206a581b5b10ee67411551be359a90b
@Override @Override
public Recipe toBukkitRecipe(NamespacedKey id) { 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));
+ 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 // CraftBukkit end
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTransformRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTransformRecipe.java diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTransformRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTransformRecipe.java
index 8c381e2745e7d5b63e72a60c5541b549f0d1b9bf..3301711afbcf39a5db15d9a7b37bbd95a63dd375 100644 index 8c381e2745e7d5b63e72a60c5541b549f0d1b9bf..38690b28b6f67624d68877c1e89ebe30b402b233 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTransformRecipe.java --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTransformRecipe.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTransformRecipe.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTransformRecipe.java
@@ -12,12 +12,17 @@ public class CraftSmithingTransformRecipe extends SmithingTransformRecipe implem @@ -12,12 +12,17 @@ public class CraftSmithingTransformRecipe extends SmithingTransformRecipe implem
public CraftSmithingTransformRecipe(NamespacedKey key, ItemStack result, RecipeChoice template, RecipeChoice base, RecipeChoice addition) { public CraftSmithingTransformRecipe(NamespacedKey key, ItemStack result, RecipeChoice template, RecipeChoice base, RecipeChoice addition) {
super(key, result, template, base, addition); super(key, result, template, base, addition);
} }
+ // Paper start - Option to prevent NBT copy + // Paper start - Option to prevent data components copy
+ public CraftSmithingTransformRecipe(NamespacedKey key, ItemStack result, RecipeChoice template, RecipeChoice base, RecipeChoice addition, boolean copyNbt) { + public CraftSmithingTransformRecipe(NamespacedKey key, ItemStack result, RecipeChoice template, RecipeChoice base, RecipeChoice addition, boolean copyDataComponents) {
+ super(key, result, template, base, addition, copyNbt); + 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) { public static CraftSmithingTransformRecipe fromBukkitRecipe(SmithingTransformRecipe recipe) {
if (recipe instanceof CraftSmithingTransformRecipe) { if (recipe instanceof CraftSmithingTransformRecipe) {
return (CraftSmithingTransformRecipe) recipe; 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());
+ 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; return ret;
} }
@ -109,35 +109,35 @@ index 8c381e2745e7d5b63e72a60c5541b549f0d1b9bf..3301711afbcf39a5db15d9a7b37bbd95
ItemStack result = this.getResult(); 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))));
+ 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 diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java
index 87f20a4811d082f217638768417c1c0feb84f741..2217e7ed9533c52a3b7d27d4dfff23ada6f2cef1 100644 index 87f20a4811d082f217638768417c1c0feb84f741..5d7782b168138383c606a2c52fbdebe1732364ac 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java
@@ -12,17 +12,22 @@ public class CraftSmithingTrimRecipe extends SmithingTrimRecipe implements Craft @@ -12,17 +12,22 @@ public class CraftSmithingTrimRecipe extends SmithingTrimRecipe implements Craft
public CraftSmithingTrimRecipe(NamespacedKey key, RecipeChoice template, RecipeChoice base, RecipeChoice addition) { public CraftSmithingTrimRecipe(NamespacedKey key, RecipeChoice template, RecipeChoice base, RecipeChoice addition) {
super(key, template, base, addition); super(key, template, base, addition);
} }
+ // Paper start - Option to prevent NBT copy + // Paper start - Option to prevent data components copy
+ public CraftSmithingTrimRecipe(NamespacedKey key, RecipeChoice template, RecipeChoice base, RecipeChoice addition, boolean copyNbt) { + public CraftSmithingTrimRecipe(NamespacedKey key, RecipeChoice template, RecipeChoice base, RecipeChoice addition, boolean copyDataComponents) {
+ super(key, template, base, addition, copyNbt); + 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) { public static CraftSmithingTrimRecipe fromBukkitRecipe(SmithingTrimRecipe recipe) {
if (recipe instanceof CraftSmithingTrimRecipe) { if (recipe instanceof CraftSmithingTrimRecipe) {
return (CraftSmithingTrimRecipe) recipe; 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());
+ 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; return ret;
} }
@Override @Override
public void addToCraftingManager() { 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))));
+ 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
} }
} }