From db81fd3455a9ad1d176ceaa6831734827ff07600 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Sat, 14 Dec 2024 10:07:36 -0800 Subject: [PATCH] net.minecraft.world.item.crafting --- .../item/crafting/BlastingRecipe.java.patch | 20 ++++ .../crafting/CampfireCookingRecipe.java.patch | 20 ++++ .../item/crafting/CustomRecipe.java.patch | 22 ++++ .../world/item/crafting/Ingredient.java.patch | 55 +++++++++ .../world/item/crafting/Recipe.java.patch | 2 +- .../item/crafting/RecipeHolder.java.patch | 15 +++ .../item/crafting/RecipeManager.java.patch | 64 ++++++++++ .../world/item/crafting/RecipeMap.java.patch | 32 ++--- .../item/crafting/ShapedRecipe.java.patch | 39 ++---- .../item/crafting/ShapelessRecipe.java.patch | 24 ++++ .../item/crafting/SmeltingRecipe.java.patch | 20 ++++ .../SmithingTransformRecipe.java.patch | 46 ++++++++ .../crafting/SmithingTrimRecipe.java.patch | 58 +++++++++ .../item/crafting/SmokingRecipe.java.patch | 20 ++++ .../crafting/StonecutterRecipe.java.patch | 19 +++ .../item/crafting/TransmuteRecipe.java.patch | 16 +++ .../item/crafting/BlastingRecipe.java.patch | 35 ------ .../crafting/CampfireCookingRecipe.java.patch | 35 ------ .../item/crafting/CustomRecipe.java.patch | 54 --------- .../world/item/crafting/Ingredient.java.patch | 66 ----------- .../item/crafting/RecipeHolder.java.patch | 26 ---- .../item/crafting/RecipeManager.java.patch | 111 ------------------ .../item/crafting/ShapelessRecipe.java.patch | 39 ------ .../item/crafting/SmeltingRecipe.java.patch | 35 ------ .../SmithingTransformRecipe.java.patch | 61 ---------- .../crafting/SmithingTrimRecipe.java.patch | 69 ----------- .../item/crafting/SmokingRecipe.java.patch | 35 ------ .../crafting/StonecutterRecipe.java.patch | 34 ------ .../item/crafting/TransmuteRecipe.java.patch | 31 ----- 29 files changed, 421 insertions(+), 682 deletions(-) create mode 100644 paper-server/patches/sources/net/minecraft/world/item/crafting/BlastingRecipe.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/item/crafting/CampfireCookingRecipe.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/item/crafting/CustomRecipe.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/item/crafting/Ingredient.java.patch rename paper-server/patches/{unapplied => sources}/net/minecraft/world/item/crafting/Recipe.java.patch (93%) create mode 100644 paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeHolder.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeManager.java.patch rename paper-server/patches/{unapplied => sources}/net/minecraft/world/item/crafting/RecipeMap.java.patch (69%) rename paper-server/patches/{unapplied => sources}/net/minecraft/world/item/crafting/ShapedRecipe.java.patch (57%) create mode 100644 paper-server/patches/sources/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/item/crafting/SmeltingRecipe.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/item/crafting/SmokingRecipe.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/item/crafting/StonecutterRecipe.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/item/crafting/TransmuteRecipe.java.patch delete mode 100644 paper-server/patches/unapplied/net/minecraft/world/item/crafting/BlastingRecipe.java.patch delete mode 100644 paper-server/patches/unapplied/net/minecraft/world/item/crafting/CampfireCookingRecipe.java.patch delete mode 100644 paper-server/patches/unapplied/net/minecraft/world/item/crafting/CustomRecipe.java.patch delete mode 100644 paper-server/patches/unapplied/net/minecraft/world/item/crafting/Ingredient.java.patch delete mode 100644 paper-server/patches/unapplied/net/minecraft/world/item/crafting/RecipeHolder.java.patch delete mode 100644 paper-server/patches/unapplied/net/minecraft/world/item/crafting/RecipeManager.java.patch delete mode 100644 paper-server/patches/unapplied/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch delete mode 100644 paper-server/patches/unapplied/net/minecraft/world/item/crafting/SmeltingRecipe.java.patch delete mode 100644 paper-server/patches/unapplied/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch delete mode 100644 paper-server/patches/unapplied/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch delete mode 100644 paper-server/patches/unapplied/net/minecraft/world/item/crafting/SmokingRecipe.java.patch delete mode 100644 paper-server/patches/unapplied/net/minecraft/world/item/crafting/StonecutterRecipe.java.patch delete mode 100644 paper-server/patches/unapplied/net/minecraft/world/item/crafting/TransmuteRecipe.java.patch diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/BlastingRecipe.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/BlastingRecipe.java.patch new file mode 100644 index 0000000000..320c3c5413 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/BlastingRecipe.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/item/crafting/BlastingRecipe.java ++++ b/net/minecraft/world/item/crafting/BlastingRecipe.java +@@ -31,4 +_,17 @@ + case FOOD, MISC -> RecipeBookCategories.BLAST_FURNACE_MISC; + }; + } ++ ++ // CraftBukkit start ++ @Override ++ public org.bukkit.inventory.Recipe toBukkitRecipe(org.bukkit.NamespacedKey id) { ++ org.bukkit.craftbukkit.inventory.CraftItemStack result = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(this.result()); ++ ++ org.bukkit.craftbukkit.inventory.CraftBlastingRecipe recipe = new org.bukkit.craftbukkit.inventory.CraftBlastingRecipe(id, result, org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.input()), this.experience(), this.cookingTime()); ++ recipe.setGroup(this.group()); ++ recipe.setCategory(org.bukkit.craftbukkit.inventory.CraftRecipe.getCategory(this.category())); ++ ++ return recipe; ++ } ++ // CraftBukkit end + } diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/CampfireCookingRecipe.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/CampfireCookingRecipe.java.patch new file mode 100644 index 0000000000..876f5b6f1d --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/CampfireCookingRecipe.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/item/crafting/CampfireCookingRecipe.java ++++ b/net/minecraft/world/item/crafting/CampfireCookingRecipe.java +@@ -28,4 +_,17 @@ + public RecipeBookCategory recipeBookCategory() { + return RecipeBookCategories.CAMPFIRE; + } ++ ++ // CraftBukkit start ++ @Override ++ public org.bukkit.inventory.Recipe toBukkitRecipe(org.bukkit.NamespacedKey id) { ++ org.bukkit.craftbukkit.inventory.CraftItemStack result = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(this.result()); ++ ++ org.bukkit.craftbukkit.inventory.CraftCampfireRecipe recipe = new org.bukkit.craftbukkit.inventory.CraftCampfireRecipe(id, result, org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.input()), this.experience(), this.cookingTime()); ++ recipe.setGroup(this.group()); ++ recipe.setCategory(org.bukkit.craftbukkit.inventory.CraftRecipe.getCategory(this.category())); ++ ++ return recipe; ++ } ++ // CraftBukkit end + } diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/CustomRecipe.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/CustomRecipe.java.patch new file mode 100644 index 0000000000..bbf2d64506 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/CustomRecipe.java.patch @@ -0,0 +1,22 @@ +--- a/net/minecraft/world/item/crafting/CustomRecipe.java ++++ b/net/minecraft/world/item/crafting/CustomRecipe.java +@@ -30,6 +_,19 @@ + @Override + public abstract RecipeSerializer getSerializer(); + ++ // CraftBukkit start ++ @Override ++ public org.bukkit.inventory.Recipe toBukkitRecipe(org.bukkit.NamespacedKey id) { ++ org.bukkit.craftbukkit.inventory.CraftItemStack result = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(net.minecraft.world.item.ItemStack.EMPTY); ++ ++ org.bukkit.craftbukkit.inventory.CraftComplexRecipe recipe = new org.bukkit.craftbukkit.inventory.CraftComplexRecipe(id, result, this); ++ recipe.setGroup(this.group()); ++ recipe.setCategory(org.bukkit.craftbukkit.inventory.CraftRecipe.getCategory(this.category())); ++ ++ return recipe; ++ } ++ // CraftBukkit end ++ + public static class Serializer implements RecipeSerializer { + private final MapCodec codec; + private final StreamCodec streamCodec; diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/Ingredient.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/Ingredient.java.patch new file mode 100644 index 0000000000..6e0c1b88c1 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/Ingredient.java.patch @@ -0,0 +1,55 @@ +--- a/net/minecraft/world/item/crafting/Ingredient.java ++++ b/net/minecraft/world/item/crafting/Ingredient.java +@@ -33,6 +_,25 @@ + public static final Codec CODEC = ExtraCodecs.nonEmptyHolderSet(NON_AIR_HOLDER_SET_CODEC) + .xmap(Ingredient::new, ingredient -> ingredient.values); + private final HolderSet values; ++ // CraftBukkit start ++ @javax.annotation.Nullable ++ private java.util.List itemStacks; ++ ++ public boolean isExact() { ++ return this.itemStacks != null; ++ } ++ ++ @javax.annotation.Nullable ++ public java.util.List itemStacks() { ++ return this.itemStacks; ++ } ++ ++ public static Ingredient ofStacks(java.util.List stacks) { ++ Ingredient recipe = Ingredient.of(stacks.stream().map(ItemStack::getItem)); ++ recipe.itemStacks = stacks; ++ return recipe; ++ } ++ // CraftBukkit end + + private Ingredient(HolderSet values) { + values.unwrap().ifRight(list -> { +@@ -60,6 +_,17 @@ + + @Override + public boolean test(ItemStack stack) { ++ // CraftBukkit start ++ if (this.isExact()) { ++ for (ItemStack itemstack1 : this.itemStacks()) { ++ if (itemstack1.getItem() == stack.getItem() && ItemStack.isSameItemSameComponents(stack, itemstack1)) { ++ return true; ++ } ++ } ++ ++ return false; ++ } ++ // CraftBukkit end + return stack.is(this.values); + } + +@@ -70,7 +_,7 @@ + + @Override + public boolean equals(Object other) { +- return other instanceof Ingredient ingredient && Objects.equals(this.values, ingredient.values); ++ return other instanceof Ingredient ingredient && Objects.equals(this.values, ingredient.values) && Objects.equals(this.itemStacks, ingredient.itemStacks); // CraftBukkit + } + + public static Ingredient of(ItemLike item) { diff --git a/paper-server/patches/unapplied/net/minecraft/world/item/crafting/Recipe.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/Recipe.java.patch similarity index 93% rename from paper-server/patches/unapplied/net/minecraft/world/item/crafting/Recipe.java.patch rename to paper-server/patches/sources/net/minecraft/world/item/crafting/Recipe.java.patch index ad97a94316..4d54b2d585 100644 --- a/paper-server/patches/unapplied/net/minecraft/world/item/crafting/Recipe.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/Recipe.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/Recipe.java +++ b/net/minecraft/world/item/crafting/Recipe.java -@@ -44,4 +44,6 @@ +@@ -44,4 +_,6 @@ } RecipeBookCategory recipeBookCategory(); diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeHolder.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeHolder.java.patch new file mode 100644 index 0000000000..538297e2aa --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeHolder.java.patch @@ -0,0 +1,15 @@ +--- a/net/minecraft/world/item/crafting/RecipeHolder.java ++++ b/net/minecraft/world/item/crafting/RecipeHolder.java +@@ -10,6 +_,12 @@ + ResourceKey.streamCodec(Registries.RECIPE), RecipeHolder::id, Recipe.STREAM_CODEC, RecipeHolder::value, RecipeHolder::new + ); + ++ // CraftBukkit start ++ public final org.bukkit.inventory.Recipe toBukkitRecipe() { ++ return this.value.toBukkitRecipe(org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(this.id.location())); ++ } ++ // CraftBukkit end ++ + @Override + public boolean equals(Object other) { + return this == other || other instanceof RecipeHolder recipeHolder && this.id == recipeHolder.id; diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeManager.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeManager.java.patch new file mode 100644 index 0000000000..03dc6953c4 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeManager.java.patch @@ -0,0 +1,64 @@ +--- a/net/minecraft/world/item/crafting/RecipeManager.java ++++ b/net/minecraft/world/item/crafting/RecipeManager.java +@@ -87,7 +_,26 @@ + LOGGER.info("Loaded {} recipes", object.values().size()); + } + ++ // CraftBukkit start ++ public void addRecipe(RecipeHolder irecipe) { ++ org.spigotmc.AsyncCatcher.catchOp("Recipe Add"); // Spigot ++ this.recipes.addRecipe(irecipe); ++ this.finalizeRecipeLoading(); ++ } ++ ++ private FeatureFlagSet featureflagset; ++ ++ public void finalizeRecipeLoading() { ++ if (this.featureflagset != null) { ++ this.finalizeRecipeLoading(this.featureflagset); ++ ++ net.minecraft.server.MinecraftServer.getServer().getPlayerList().reloadRecipes(); ++ } ++ } ++ + public void finalizeRecipeLoading(FeatureFlagSet enabledFeatures) { ++ this.featureflagset = enabledFeatures; ++ // CraftBukkit end + List> list = new ArrayList<>(); + List list1 = RECIPE_PROPERTY_SETS.entrySet() + .stream() +@@ -147,7 +_,10 @@ + } + + public > Optional> getRecipeFor(RecipeType recipeType, I input, Level level) { +- return this.recipes.getRecipesFor(recipeType, input, level).findFirst(); ++ // CraftBukkit start ++ List> list = this.recipes.getRecipesFor(recipeType, input, level).toList(); ++ return (list.isEmpty()) ? Optional.empty() : Optional.of(list.getLast()); // CraftBukkit - SPIGOT-4638: last recipe gets priority ++ // CraftBukkit end + } + + public Optional> byKey(ResourceKey> key) { +@@ -199,6 +_,22 @@ + Recipe recipe1 = Recipe.CODEC.parse(registries.createSerializationContext(JsonOps.INSTANCE), json).getOrThrow(JsonParseException::new); + return new RecipeHolder<>(recipe, recipe1); + } ++ ++ // CraftBukkit start ++ public boolean removeRecipe(ResourceKey> mcKey) { ++ boolean removed = this.recipes.removeRecipe((ResourceKey>) (ResourceKey) mcKey); // Paper - generic fix ++ if (removed) { ++ this.finalizeRecipeLoading(); ++ } ++ ++ return removed; ++ } ++ ++ public void clearRecipes() { ++ this.recipes = RecipeMap.create(java.util.Collections.emptyList()); ++ this.finalizeRecipeLoading(); ++ } ++ // CraftBukkit end + + public static > RecipeManager.CachedCheck createCheck(final RecipeType recipeType) { + return new RecipeManager.CachedCheck() { diff --git a/paper-server/patches/unapplied/net/minecraft/world/item/crafting/RecipeMap.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeMap.java.patch similarity index 69% rename from paper-server/patches/unapplied/net/minecraft/world/item/crafting/RecipeMap.java.patch rename to paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeMap.java.patch index 171f3d8e88..ae4eba51bc 100644 --- a/paper-server/patches/unapplied/net/minecraft/world/item/crafting/RecipeMap.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeMap.java.patch @@ -1,25 +1,15 @@ --- a/net/minecraft/world/item/crafting/RecipeMap.java +++ b/net/minecraft/world/item/crafting/RecipeMap.java -@@ -11,6 +11,10 @@ - import javax.annotation.Nullable; - import net.minecraft.resources.ResourceKey; - import net.minecraft.world.level.Level; -+// CraftBukkit start -+import com.google.common.collect.LinkedHashMultimap; -+import com.google.common.collect.Maps; -+// CraftBukkit end - - public class RecipeMap { - -@@ -35,11 +39,56 @@ - com_google_common_collect_immutablemap_builder.put(recipeholder.id(), recipeholder); +@@ -30,8 +_,53 @@ + builder1.put(recipeHolder.id(), recipeHolder); } -- return new RecipeMap(builder.build(), com_google_common_collect_immutablemap_builder.build()); +- return new RecipeMap(builder.build(), builder1.build()); +- } + // CraftBukkit start - mutable -+ return new RecipeMap(LinkedHashMultimap.create(builder.build()), Maps.newHashMap(com_google_common_collect_immutablemap_builder.build())); - } - ++ return new RecipeMap(com.google.common.collect.LinkedHashMultimap.create(builder.build()), com.google.common.collect.Maps.newHashMap(builder1.build())); ++ } ++ + public void addRecipe(RecipeHolder irecipe) { + Collection> map = this.byType.get(irecipe.value().getType()); + @@ -63,10 +53,6 @@ + // Paper end - why are you using a loop??? + } + // Paper end - replace removeRecipe implementation -+ - public > Collection> byType(RecipeType type) { -- return this.byType.get(type); -+ return (Collection) this.byType.get(type); // CraftBukkit - decompile error - } - public Collection> values() { + public > Collection> byType(RecipeType type) { + return (Collection)this.byType.get(type); diff --git a/paper-server/patches/unapplied/net/minecraft/world/item/crafting/ShapedRecipe.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/ShapedRecipe.java.patch similarity index 57% rename from paper-server/patches/unapplied/net/minecraft/world/item/crafting/ShapedRecipe.java.patch rename to paper-server/patches/sources/net/minecraft/world/item/crafting/ShapedRecipe.java.patch index 05fee5cb09..18e1fb0718 100644 --- a/paper-server/patches/unapplied/net/minecraft/world/item/crafting/ShapedRecipe.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/ShapedRecipe.java.patch @@ -1,30 +1,16 @@ --- a/net/minecraft/world/item/crafting/ShapedRecipe.java +++ b/net/minecraft/world/item/crafting/ShapedRecipe.java -@@ -16,6 +16,13 @@ - import net.minecraft.world.item.crafting.display.ShapedCraftingRecipeDisplay; - import net.minecraft.world.item.crafting.display.SlotDisplay; - import net.minecraft.world.level.Level; -+// CraftBukkit start -+import org.bukkit.NamespacedKey; -+import org.bukkit.craftbukkit.inventory.CraftItemStack; -+import org.bukkit.craftbukkit.inventory.CraftRecipe; -+import org.bukkit.craftbukkit.inventory.CraftShapedRecipe; -+import org.bukkit.inventory.RecipeChoice; -+// CraftBukkit end - - public class ShapedRecipe implements CraftingRecipe { - -@@ -39,7 +46,69 @@ - this(group, category, raw, result, true); +@@ -103,6 +_,68 @@ + ); } + // CraftBukkit start - @Override -+ public org.bukkit.inventory.ShapedRecipe toBukkitRecipe(NamespacedKey id) { -+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result); -+ CraftShapedRecipe recipe = new CraftShapedRecipe(id, result, this); ++ @Override ++ public org.bukkit.inventory.ShapedRecipe toBukkitRecipe(org.bukkit.NamespacedKey id) { ++ org.bukkit.craftbukkit.inventory.CraftItemStack result = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(this.result); ++ org.bukkit.craftbukkit.inventory.CraftShapedRecipe recipe = new org.bukkit.craftbukkit.inventory.CraftShapedRecipe(id, result, this); + recipe.setGroup(this.group); -+ recipe.setCategory(CraftRecipe.getCategory(this.category())); ++ recipe.setCategory(org.bukkit.craftbukkit.inventory.CraftRecipe.getCategory(this.category())); + + switch (this.pattern.height()) { + case 1: @@ -69,8 +55,8 @@ + } + char c = 'a'; + for (Optional list : this.pattern.ingredients()) { -+ RecipeChoice choice = CraftRecipe.toBukkit(list); -+ if (choice != RecipeChoice.empty()) { // Paper ++ org.bukkit.inventory.RecipeChoice choice = org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(list); ++ if (choice != org.bukkit.inventory.RecipeChoice.empty()) { // Paper + recipe.setIngredient(c, choice); + } + @@ -80,7 +66,6 @@ + } + // CraftBukkit end + -+ @Override - public RecipeSerializer getSerializer() { - return RecipeSerializer.SHAPED_RECIPE; - } + public static class Serializer implements RecipeSerializer { + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec( + instance -> instance.group( diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch new file mode 100644 index 0000000000..e13cbaac8e --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch @@ -0,0 +1,24 @@ +--- a/net/minecraft/world/item/crafting/ShapelessRecipe.java ++++ b/net/minecraft/world/item/crafting/ShapelessRecipe.java +@@ -31,6 +_,21 @@ + this.ingredients = ingredients; + } + ++ // CraftBukkit start ++ @Override ++ public org.bukkit.inventory.ShapelessRecipe toBukkitRecipe(org.bukkit.NamespacedKey id) { ++ org.bukkit.craftbukkit.inventory.CraftItemStack result = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(this.result); ++ org.bukkit.craftbukkit.inventory.CraftShapelessRecipe recipe = new org.bukkit.craftbukkit.inventory.CraftShapelessRecipe(id, result, this); ++ recipe.setGroup(this.group); ++ recipe.setCategory(org.bukkit.craftbukkit.inventory.CraftRecipe.getCategory(this.category())); ++ ++ for (Ingredient list : this.ingredients) { ++ recipe.addIngredient(org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(list)); ++ } ++ return recipe; ++ } ++ // CraftBukkit end ++ + @Override + public RecipeSerializer getSerializer() { + return RecipeSerializer.SHAPELESS_RECIPE; diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/SmeltingRecipe.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/SmeltingRecipe.java.patch new file mode 100644 index 0000000000..c174cfdcf8 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/SmeltingRecipe.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/item/crafting/SmeltingRecipe.java ++++ b/net/minecraft/world/item/crafting/SmeltingRecipe.java +@@ -32,4 +_,17 @@ + case MISC -> RecipeBookCategories.FURNACE_MISC; + }; + } ++ ++ // CraftBukkit start ++ @Override ++ public org.bukkit.inventory.Recipe toBukkitRecipe(org.bukkit.NamespacedKey id) { ++ org.bukkit.craftbukkit.inventory.CraftItemStack result = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(this.result()); ++ ++ org.bukkit.craftbukkit.inventory.CraftFurnaceRecipe recipe = new org.bukkit.craftbukkit.inventory.CraftFurnaceRecipe(id, result, org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.input()), this.experience(), this.cookingTime()); ++ recipe.setGroup(this.group()); ++ recipe.setCategory(org.bukkit.craftbukkit.inventory.CraftRecipe.getCategory(this.category())); ++ ++ return recipe; ++ } ++ // CraftBukkit end + } diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch new file mode 100644 index 0000000000..5e4907953d --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch @@ -0,0 +1,46 @@ +--- a/net/minecraft/world/item/crafting/SmithingTransformRecipe.java ++++ b/net/minecraft/world/item/crafting/SmithingTransformRecipe.java +@@ -21,8 +_,15 @@ + final ItemStack result; + @Nullable + private PlacementInfo placementInfo; ++ final boolean copyDataComponents; // Paper - Option to prevent data components copy + + public SmithingTransformRecipe(Optional template, Optional base, Optional addition, ItemStack result) { ++ // Paper start - Option to prevent data components copy ++ this(template, base, addition, result, true); ++ } ++ public SmithingTransformRecipe(Optional template, Optional base, Optional 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; +@@ -32,7 +_,9 @@ + @Override + public ItemStack assemble(SmithingRecipeInput input, HolderLookup.Provider registries) { + ItemStack itemStack = input.base().transmuteCopy(this.result.getItem(), this.result.getCount()); ++ if (this.copyDataComponents) { // Paper - Option to prevent data components copy + itemStack.applyComponents(this.result.getComponentsPatch()); ++ } // Paper - Option to prevent data components copy + return itemStack; + } + +@@ -77,6 +_,17 @@ + ) + ); + } ++ ++ // CraftBukkit start ++ @Override ++ public org.bukkit.inventory.Recipe toBukkitRecipe(org.bukkit.NamespacedKey id) { ++ org.bukkit.craftbukkit.inventory.CraftItemStack result = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(this.result); ++ ++ org.bukkit.craftbukkit.inventory.CraftSmithingTransformRecipe recipe = new org.bukkit.craftbukkit.inventory.CraftSmithingTransformRecipe(id, result, org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.template), org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.base), org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.addition), this.copyDataComponents); // Paper - Option to prevent data components copy ++ ++ return recipe; ++ } ++ // CraftBukkit end + + public static class Serializer implements RecipeSerializer { + private static final MapCodec CODEC = RecordCodecBuilder.mapCodec( diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch new file mode 100644 index 0000000000..09cb0b71fe --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch @@ -0,0 +1,58 @@ +--- a/net/minecraft/world/item/crafting/SmithingTrimRecipe.java ++++ b/net/minecraft/world/item/crafting/SmithingTrimRecipe.java +@@ -27,8 +_,15 @@ + final Optional addition; + @Nullable + private PlacementInfo placementInfo; ++ final boolean copyDataComponents; // Paper - Option to prevent data components copy + + public SmithingTrimRecipe(Optional template, Optional base, Optional addition) { ++ // Paper start - Option to prevent data components copy ++ this(template, base, addition, true); ++ } ++ public SmithingTrimRecipe(Optional template, Optional base, Optional addition, boolean copyDataComponents) { ++ this.copyDataComponents = copyDataComponents; ++ // Paper end - Option to prevent data components copy + this.template = template; + this.base = base; + this.addition = addition; +@@ -36,10 +_,15 @@ + + @Override + public ItemStack assemble(SmithingRecipeInput input, HolderLookup.Provider registries) { +- return applyTrim(registries, input.base(), input.addition(), input.template()); ++ return applyTrim(registries, input.base(), input.addition(), input.template(), this.copyDataComponents); // Paper - Option to prevent data components copy + } + + public static ItemStack applyTrim(HolderLookup.Provider registries, ItemStack base, ItemStack addition, ItemStack template) { ++ // Paper start - Option to prevent data components copy ++ return applyTrim(registries, base, addition, template, true); ++ } ++ public static ItemStack applyTrim(HolderLookup.Provider registries, ItemStack base, ItemStack addition, ItemStack template, boolean copyDataComponents) { ++ // Paper end - Option to prevent data components copy + Optional> fromIngredient = TrimMaterials.getFromIngredient(registries, addition); + Optional> fromTemplate = TrimPatterns.getFromTemplate(registries, template); + if (fromIngredient.isPresent() && fromTemplate.isPresent()) { +@@ -47,7 +_,7 @@ + if (armorTrim != null && armorTrim.hasPatternAndMaterial(fromTemplate.get(), fromIngredient.get())) { + return ItemStack.EMPTY; + } else { +- ItemStack itemStack = base.copyWithCount(1); ++ ItemStack itemStack = copyDataComponents ? base.copyWithCount(1) : new ItemStack(base.getItem(), 1); // Paper - Option to prevent data components copy + itemStack.set(DataComponents.TRIM, new ArmorTrim(fromIngredient.get(), fromTemplate.get())); + return itemStack; + } +@@ -100,6 +_,13 @@ + ) + ); + } ++ ++ // CraftBukkit start ++ @Override ++ public org.bukkit.inventory.Recipe toBukkitRecipe(org.bukkit.NamespacedKey id) { ++ return new org.bukkit.craftbukkit.inventory.CraftSmithingTrimRecipe(id, org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.template), org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.base), org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.addition), this.copyDataComponents); // Paper - Option to prevent data components copy ++ } ++ // CraftBukkit end + + public static class Serializer implements RecipeSerializer { + private static final MapCodec CODEC = RecordCodecBuilder.mapCodec( diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/SmokingRecipe.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/SmokingRecipe.java.patch new file mode 100644 index 0000000000..e952bdf1b6 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/SmokingRecipe.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/item/crafting/SmokingRecipe.java ++++ b/net/minecraft/world/item/crafting/SmokingRecipe.java +@@ -28,4 +_,17 @@ + public RecipeBookCategory recipeBookCategory() { + return RecipeBookCategories.SMOKER_FOOD; + } ++ ++ // CraftBukkit start ++ @Override ++ public org.bukkit.inventory.Recipe toBukkitRecipe(org.bukkit.NamespacedKey id) { ++ org.bukkit.craftbukkit.inventory.CraftItemStack result = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(this.result()); ++ ++ org.bukkit.craftbukkit.inventory.CraftSmokingRecipe recipe = new org.bukkit.craftbukkit.inventory.CraftSmokingRecipe(id, result, org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.input()), this.experience(), this.cookingTime()); ++ recipe.setGroup(this.group()); ++ recipe.setCategory(org.bukkit.craftbukkit.inventory.CraftRecipe.getCategory(this.category())); ++ ++ return recipe; ++ } ++ // CraftBukkit end + } diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/StonecutterRecipe.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/StonecutterRecipe.java.patch new file mode 100644 index 0000000000..daa51ba292 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/StonecutterRecipe.java.patch @@ -0,0 +1,19 @@ +--- a/net/minecraft/world/item/crafting/StonecutterRecipe.java ++++ b/net/minecraft/world/item/crafting/StonecutterRecipe.java +@@ -35,4 +_,16 @@ + public RecipeBookCategory recipeBookCategory() { + return RecipeBookCategories.STONECUTTER; + } ++ ++ // CraftBukkit start ++ @Override ++ public org.bukkit.inventory.Recipe toBukkitRecipe(org.bukkit.NamespacedKey id) { ++ org.bukkit.craftbukkit.inventory.CraftItemStack result = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(this.result()); ++ ++ org.bukkit.craftbukkit.inventory.CraftStonecuttingRecipe recipe = new org.bukkit.craftbukkit.inventory.CraftStonecuttingRecipe(id, result, org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.input())); ++ recipe.setGroup(this.group()); ++ ++ return recipe; ++ } ++ // CraftBukkit end + } diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/TransmuteRecipe.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/TransmuteRecipe.java.patch new file mode 100644 index 0000000000..bdfba17d6a --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/TransmuteRecipe.java.patch @@ -0,0 +1,16 @@ +--- a/net/minecraft/world/item/crafting/TransmuteRecipe.java ++++ b/net/minecraft/world/item/crafting/TransmuteRecipe.java +@@ -88,6 +_,13 @@ + ); + } + ++ // CraftBukkit start ++ @Override ++ public org.bukkit.inventory.Recipe toBukkitRecipe(org.bukkit.NamespacedKey id) { ++ return new org.bukkit.craftbukkit.inventory.CraftTransmuteRecipe(id, org.bukkit.craftbukkit.inventory.CraftItemType.minecraftToBukkit(this.result.value()), org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.input), org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.material)); ++ } ++ // CraftBukkit end ++ + @Override + public RecipeSerializer getSerializer() { + return RecipeSerializer.TRANSMUTE; diff --git a/paper-server/patches/unapplied/net/minecraft/world/item/crafting/BlastingRecipe.java.patch b/paper-server/patches/unapplied/net/minecraft/world/item/crafting/BlastingRecipe.java.patch deleted file mode 100644 index 26a37bbc25..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/world/item/crafting/BlastingRecipe.java.patch +++ /dev/null @@ -1,35 +0,0 @@ ---- a/net/minecraft/world/item/crafting/BlastingRecipe.java -+++ b/net/minecraft/world/item/crafting/BlastingRecipe.java -@@ -4,6 +4,14 @@ - import net.minecraft.world.item.ItemStack; - import net.minecraft.world.item.Items; - -+// CraftBukkit start -+import org.bukkit.NamespacedKey; -+import org.bukkit.craftbukkit.inventory.CraftBlastingRecipe; -+import org.bukkit.craftbukkit.inventory.CraftItemStack; -+import org.bukkit.craftbukkit.inventory.CraftRecipe; -+import org.bukkit.inventory.Recipe; -+// CraftBukkit end -+ - public class BlastingRecipe extends AbstractCookingRecipe { - - public BlastingRecipe(String group, CookingBookCategory category, Ingredient ingredient, ItemStack result, float experience, int cookingTime) { -@@ -43,4 +51,17 @@ - - return recipebookcategory; - } -+ -+ // CraftBukkit start -+ @Override -+ public Recipe toBukkitRecipe(NamespacedKey id) { -+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result()); -+ -+ CraftBlastingRecipe recipe = new CraftBlastingRecipe(id, result, CraftRecipe.toBukkit(this.input()), this.experience(), this.cookingTime()); -+ recipe.setGroup(this.group()); -+ recipe.setCategory(CraftRecipe.getCategory(this.category())); -+ -+ return recipe; -+ } -+ // CraftBukkit end - } diff --git a/paper-server/patches/unapplied/net/minecraft/world/item/crafting/CampfireCookingRecipe.java.patch b/paper-server/patches/unapplied/net/minecraft/world/item/crafting/CampfireCookingRecipe.java.patch deleted file mode 100644 index 039e214990..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/world/item/crafting/CampfireCookingRecipe.java.patch +++ /dev/null @@ -1,35 +0,0 @@ ---- a/net/minecraft/world/item/crafting/CampfireCookingRecipe.java -+++ b/net/minecraft/world/item/crafting/CampfireCookingRecipe.java -@@ -4,6 +4,14 @@ - import net.minecraft.world.item.ItemStack; - import net.minecraft.world.item.Items; - -+// CraftBukkit start -+import org.bukkit.NamespacedKey; -+import org.bukkit.craftbukkit.inventory.CraftCampfireRecipe; -+import org.bukkit.craftbukkit.inventory.CraftItemStack; -+import org.bukkit.craftbukkit.inventory.CraftRecipe; -+import org.bukkit.inventory.Recipe; -+// CraftBukkit end -+ - public class CampfireCookingRecipe extends AbstractCookingRecipe { - - public CampfireCookingRecipe(String group, CookingBookCategory category, Ingredient ingredient, ItemStack result, float experience, int cookingTime) { -@@ -29,4 +37,17 @@ - public RecipeBookCategory recipeBookCategory() { - return RecipeBookCategories.CAMPFIRE; - } -+ -+ // CraftBukkit start -+ @Override -+ public Recipe toBukkitRecipe(NamespacedKey id) { -+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result()); -+ -+ CraftCampfireRecipe recipe = new CraftCampfireRecipe(id, result, CraftRecipe.toBukkit(this.input()), this.experience(), this.cookingTime()); -+ recipe.setGroup(this.group()); -+ recipe.setCategory(CraftRecipe.getCategory(this.category())); -+ -+ return recipe; -+ } -+ // CraftBukkit end - } diff --git a/paper-server/patches/unapplied/net/minecraft/world/item/crafting/CustomRecipe.java.patch b/paper-server/patches/unapplied/net/minecraft/world/item/crafting/CustomRecipe.java.patch deleted file mode 100644 index 773c84fb8b..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/world/item/crafting/CustomRecipe.java.patch +++ /dev/null @@ -1,54 +0,0 @@ ---- a/net/minecraft/world/item/crafting/CustomRecipe.java -+++ b/net/minecraft/world/item/crafting/CustomRecipe.java -@@ -8,6 +8,15 @@ - import net.minecraft.network.RegistryFriendlyByteBuf; - import net.minecraft.network.codec.StreamCodec; - -+// CraftBukkit start -+import net.minecraft.world.item.ItemStack; -+import org.bukkit.NamespacedKey; -+import org.bukkit.craftbukkit.inventory.CraftComplexRecipe; -+import org.bukkit.craftbukkit.inventory.CraftItemStack; -+import org.bukkit.craftbukkit.inventory.CraftRecipe; -+import org.bukkit.inventory.Recipe; -+// CraftBukkit end -+ - public abstract class CustomRecipe implements CraftingRecipe { - - private final CraftingBookCategory category; -@@ -34,6 +43,19 @@ - @Override - public abstract RecipeSerializer getSerializer(); - -+ // CraftBukkit start -+ @Override -+ public Recipe toBukkitRecipe(NamespacedKey id) { -+ CraftItemStack result = CraftItemStack.asCraftMirror(ItemStack.EMPTY); -+ -+ CraftComplexRecipe recipe = new CraftComplexRecipe(id, result, this); -+ recipe.setGroup(this.group()); -+ recipe.setCategory(CraftRecipe.getCategory(this.category())); -+ -+ return recipe; -+ } -+ // CraftBukkit end -+ - public static class Serializer implements RecipeSerializer { - - private final MapCodec codec; -@@ -41,13 +63,13 @@ - - public Serializer(CustomRecipe.Serializer.Factory factory) { - this.codec = RecordCodecBuilder.mapCodec((instance) -> { -- P1 p1 = instance.group(CraftingBookCategory.CODEC.fieldOf("category").orElse(CraftingBookCategory.MISC).forGetter(CraftingRecipe::category)); -+ P1, CraftingBookCategory> p1 = instance.group(CraftingBookCategory.CODEC.fieldOf("category").orElse(CraftingBookCategory.MISC).forGetter(CraftingRecipe::category)); // CraftBukkit - decompile error - - Objects.requireNonNull(factory); - return p1.apply(instance, factory::create); - }); - StreamCodec streamcodec = CraftingBookCategory.STREAM_CODEC; -- Function function = CraftingRecipe::category; -+ Function function = CraftingRecipe::category; // CraftBukkit - decompile error - - Objects.requireNonNull(factory); - this.streamCodec = StreamCodec.composite(streamcodec, function, factory::create); diff --git a/paper-server/patches/unapplied/net/minecraft/world/item/crafting/Ingredient.java.patch b/paper-server/patches/unapplied/net/minecraft/world/item/crafting/Ingredient.java.patch deleted file mode 100644 index 1d00386837..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/world/item/crafting/Ingredient.java.patch +++ /dev/null @@ -1,66 +0,0 @@ ---- a/net/minecraft/world/item/crafting/Ingredient.java -+++ b/net/minecraft/world/item/crafting/Ingredient.java -@@ -20,6 +20,10 @@ - import net.minecraft.world.item.Items; - import net.minecraft.world.item.crafting.display.SlotDisplay; - import net.minecraft.world.level.ItemLike; -+// CraftBukkit start -+import java.util.List; -+import javax.annotation.Nullable; -+// CraftBukkit end - - public final class Ingredient implements StackedContents.IngredientInfo>, Predicate { - -@@ -38,7 +42,25 @@ - return recipeitemstack.values; - }); - private final HolderSet values; -+ // CraftBukkit start -+ @Nullable -+ private List itemStacks; - -+ public boolean isExact() { -+ return this.itemStacks != null; -+ } -+ -+ public List itemStacks() { -+ return this.itemStacks; -+ } -+ -+ public static Ingredient ofStacks(List stacks) { -+ Ingredient recipe = Ingredient.of(stacks.stream().map(ItemStack::getItem)); -+ recipe.itemStacks = stacks; -+ return recipe; -+ } -+ // CraftBukkit end -+ - private Ingredient(HolderSet entries) { - entries.unwrap().ifRight((list) -> { - if (list.isEmpty()) { -@@ -70,6 +92,17 @@ - } - - public boolean test(ItemStack itemstack) { -+ // CraftBukkit start -+ if (this.isExact()) { -+ for (ItemStack itemstack1 : this.itemStacks()) { -+ if (itemstack1.getItem() == itemstack.getItem() && ItemStack.isSameItemSameComponents(itemstack, itemstack1)) { -+ return true; -+ } -+ } -+ -+ return false; -+ } -+ // CraftBukkit end - return itemstack.is(this.values); - } - -@@ -79,7 +112,7 @@ - - public boolean equals(Object object) { - if (object instanceof Ingredient recipeitemstack) { -- return Objects.equals(this.values, recipeitemstack.values); -+ return Objects.equals(this.values, recipeitemstack.values) && Objects.equals(this.itemStacks, recipeitemstack.itemStacks); // CraftBukkit - } else { - return false; - } diff --git a/paper-server/patches/unapplied/net/minecraft/world/item/crafting/RecipeHolder.java.patch b/paper-server/patches/unapplied/net/minecraft/world/item/crafting/RecipeHolder.java.patch deleted file mode 100644 index 818a4d266e..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/world/item/crafting/RecipeHolder.java.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/net/minecraft/world/item/crafting/RecipeHolder.java -+++ b/net/minecraft/world/item/crafting/RecipeHolder.java -@@ -5,10 +5,21 @@ - import net.minecraft.network.codec.StreamCodec; - import net.minecraft.resources.ResourceKey; - --public record RecipeHolder>(ResourceKey> id, T value) { -+// CraftBukkit start -+import org.bukkit.craftbukkit.util.CraftNamespacedKey; -+import org.bukkit.inventory.Recipe; -+// CraftBukkit end - -- public static final StreamCodec> STREAM_CODEC = StreamCodec.composite(ResourceKey.streamCodec(Registries.RECIPE), RecipeHolder::id, Recipe.STREAM_CODEC, RecipeHolder::value, RecipeHolder::new); -+public record RecipeHolder>(ResourceKey> id, T value) { - -+ // CraftBukkit start -+ public final Recipe toBukkitRecipe() { -+ return this.value.toBukkitRecipe(CraftNamespacedKey.fromMinecraft(this.id.location())); -+ } -+ // CraftBukkit end -+ -+ public static final StreamCodec> STREAM_CODEC = StreamCodec.composite(ResourceKey.streamCodec(Registries.RECIPE), RecipeHolder::id, net.minecraft.world.item.crafting.Recipe.STREAM_CODEC, RecipeHolder::value, RecipeHolder::new); -+ - public boolean equals(Object object) { - if (this == object) { - return true; diff --git a/paper-server/patches/unapplied/net/minecraft/world/item/crafting/RecipeManager.java.patch b/paper-server/patches/unapplied/net/minecraft/world/item/crafting/RecipeManager.java.patch deleted file mode 100644 index 83a2caa10c..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/world/item/crafting/RecipeManager.java.patch +++ /dev/null @@ -1,111 +0,0 @@ ---- a/net/minecraft/world/item/crafting/RecipeManager.java -+++ b/net/minecraft/world/item/crafting/RecipeManager.java -@@ -26,11 +26,6 @@ - import net.minecraft.resources.FileToIdConverter; - import net.minecraft.resources.ResourceKey; - import net.minecraft.resources.ResourceLocation; --import net.minecraft.server.level.ServerLevel; --import net.minecraft.server.packs.resources.ResourceManager; --import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener; --import net.minecraft.server.packs.resources.SimplePreparableReloadListener; --import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.world.flag.FeatureFlagSet; - import net.minecraft.world.item.Item; - import net.minecraft.world.item.crafting.display.RecipeDisplay; -@@ -39,6 +34,16 @@ - import net.minecraft.world.level.Level; - import org.slf4j.Logger; - -+// CraftBukkit start -+import java.util.Collections; -+import net.minecraft.server.MinecraftServer; -+// CraftBukkit end -+import net.minecraft.server.level.ServerLevel; -+import net.minecraft.server.packs.resources.ResourceManager; -+import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener; -+import net.minecraft.server.packs.resources.SimplePreparableReloadListener; -+import net.minecraft.util.profiling.ProfilerFiller; -+ - public class RecipeManager extends SimplePreparableReloadListener implements RecipeAccess { - - private static final Logger LOGGER = LogUtils.getLogger(); -@@ -111,7 +116,26 @@ - RecipeManager.LOGGER.info("Loaded {} recipes", prepared.values().size()); - } - -+ // CraftBukkit start -+ public void addRecipe(RecipeHolder irecipe) { -+ org.spigotmc.AsyncCatcher.catchOp("Recipe Add"); // Spigot -+ this.recipes.addRecipe(irecipe); -+ this.finalizeRecipeLoading(); -+ } -+ -+ private FeatureFlagSet featureflagset; -+ -+ public void finalizeRecipeLoading() { -+ if (this.featureflagset != null) { -+ this.finalizeRecipeLoading(this.featureflagset); -+ -+ MinecraftServer.getServer().getPlayerList().reloadRecipes(); -+ } -+ } -+ - public void finalizeRecipeLoading(FeatureFlagSet features) { -+ this.featureflagset = features; -+ // CraftBukkit end - List> list = new ArrayList(); - List list1 = RecipeManager.RECIPE_PROPERTY_SETS.entrySet().stream().map((entry) -> { - return new RecipeManager.IngredientCollector((ResourceKey) entry.getKey(), (RecipeManager.IngredientExtractor) entry.getValue()); -@@ -130,7 +154,7 @@ - StonecutterRecipe recipestonecutting = (StonecutterRecipe) irecipe; - - if (RecipeManager.isIngredientEnabled(features, recipestonecutting.input()) && recipestonecutting.resultDisplay().isEnabled(features)) { -- list.add(new SelectableRecipe.SingleInputEntry<>(recipestonecutting.input(), new SelectableRecipe<>(recipestonecutting.resultDisplay(), Optional.of(recipeholder)))); -+ list.add(new SelectableRecipe.SingleInputEntry(recipestonecutting.input(), new SelectableRecipe<>(recipestonecutting.resultDisplay(), Optional.of((RecipeHolder) recipeholder)))); // CraftBukkit - decompile error - } - } - -@@ -172,7 +196,10 @@ - } - - public > Optional> getRecipeFor(RecipeType type, I input, Level world) { -- return this.recipes.getRecipesFor(type, input, world).findFirst(); -+ // CraftBukkit start -+ List> list = this.recipes.getRecipesFor(type, input, world).toList(); -+ return (list.isEmpty()) ? Optional.empty() : Optional.of(list.getLast()); // CraftBukkit - SPIGOT-4638: last recipe gets priority -+ // CraftBukkit end - } - - public Optional> byKey(ResourceKey> key) { -@@ -183,7 +210,7 @@ - private > RecipeHolder byKeyTyped(RecipeType type, ResourceKey> key) { - RecipeHolder recipeholder = this.recipes.byKey(key); - -- return recipeholder != null && recipeholder.value().getType().equals(type) ? recipeholder : null; -+ return recipeholder != null && recipeholder.value().getType().equals(type) ? (RecipeHolder) recipeholder : null; // CraftBukkit - decompile error - } - - public Map, RecipePropertySet> getSynchronizedItemProperties() { -@@ -231,6 +258,22 @@ - return new RecipeHolder<>(key, irecipe); - } - -+ // CraftBukkit start -+ public boolean removeRecipe(ResourceKey> mcKey) { -+ boolean removed = this.recipes.removeRecipe((ResourceKey>) (ResourceKey) mcKey); // Paper - generic fix -+ if (removed) { -+ this.finalizeRecipeLoading(); -+ } -+ -+ return removed; -+ } -+ -+ public void clearRecipes() { -+ this.recipes = RecipeMap.create(Collections.emptyList()); -+ this.finalizeRecipeLoading(); -+ } -+ // CraftBukkit end -+ - public static > RecipeManager.CachedCheck createCheck(final RecipeType type) { - return new RecipeManager.CachedCheck() { - @Nullable diff --git a/paper-server/patches/unapplied/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch b/paper-server/patches/unapplied/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch deleted file mode 100644 index 167de63903..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch +++ /dev/null @@ -1,39 +0,0 @@ ---- a/net/minecraft/world/item/crafting/ShapelessRecipe.java -+++ b/net/minecraft/world/item/crafting/ShapelessRecipe.java -@@ -16,6 +16,12 @@ - import net.minecraft.world.item.crafting.display.ShapelessCraftingRecipeDisplay; - import net.minecraft.world.item.crafting.display.SlotDisplay; - import net.minecraft.world.level.Level; -+// CraftBukkit start -+import org.bukkit.NamespacedKey; -+import org.bukkit.craftbukkit.inventory.CraftItemStack; -+import org.bukkit.craftbukkit.inventory.CraftRecipe; -+import org.bukkit.craftbukkit.inventory.CraftShapelessRecipe; -+// CraftBukkit end - - public class ShapelessRecipe implements CraftingRecipe { - -@@ -33,7 +39,23 @@ - this.ingredients = ingredients; - } - -+ // CraftBukkit start -+ @SuppressWarnings("unchecked") - @Override -+ public org.bukkit.inventory.ShapelessRecipe toBukkitRecipe(NamespacedKey id) { -+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result); -+ CraftShapelessRecipe recipe = new CraftShapelessRecipe(id, result, this); -+ recipe.setGroup(this.group); -+ recipe.setCategory(CraftRecipe.getCategory(this.category())); -+ -+ for (Ingredient list : this.ingredients) { -+ recipe.addIngredient(CraftRecipe.toBukkit(list)); -+ } -+ return recipe; -+ } -+ // CraftBukkit end -+ -+ @Override - public RecipeSerializer getSerializer() { - return RecipeSerializer.SHAPELESS_RECIPE; - } diff --git a/paper-server/patches/unapplied/net/minecraft/world/item/crafting/SmeltingRecipe.java.patch b/paper-server/patches/unapplied/net/minecraft/world/item/crafting/SmeltingRecipe.java.patch deleted file mode 100644 index 4b26fa911a..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/world/item/crafting/SmeltingRecipe.java.patch +++ /dev/null @@ -1,35 +0,0 @@ ---- a/net/minecraft/world/item/crafting/SmeltingRecipe.java -+++ b/net/minecraft/world/item/crafting/SmeltingRecipe.java -@@ -4,6 +4,14 @@ - import net.minecraft.world.item.ItemStack; - import net.minecraft.world.item.Items; - -+// CraftBukkit start -+import org.bukkit.NamespacedKey; -+import org.bukkit.craftbukkit.inventory.CraftFurnaceRecipe; -+import org.bukkit.craftbukkit.inventory.CraftItemStack; -+import org.bukkit.craftbukkit.inventory.CraftRecipe; -+import org.bukkit.inventory.Recipe; -+// CraftBukkit end -+ - public class SmeltingRecipe extends AbstractCookingRecipe { - - public SmeltingRecipe(String group, CookingBookCategory category, Ingredient ingredient, ItemStack result, float experience, int cookingTime) { -@@ -45,4 +53,17 @@ - - return recipebookcategory; - } -+ -+ // CraftBukkit start -+ @Override -+ public Recipe toBukkitRecipe(NamespacedKey id) { -+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result()); -+ -+ CraftFurnaceRecipe recipe = new CraftFurnaceRecipe(id, result, CraftRecipe.toBukkit(this.input()), this.experience(), this.cookingTime()); -+ recipe.setGroup(this.group()); -+ recipe.setCategory(CraftRecipe.getCategory(this.category())); -+ -+ return recipe; -+ } -+ // CraftBukkit end - } diff --git a/paper-server/patches/unapplied/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch b/paper-server/patches/unapplied/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch deleted file mode 100644 index 173f836106..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch +++ /dev/null @@ -1,61 +0,0 @@ ---- a/net/minecraft/world/item/crafting/SmithingTransformRecipe.java -+++ b/net/minecraft/world/item/crafting/SmithingTransformRecipe.java -@@ -14,6 +14,14 @@ - import net.minecraft.world.item.crafting.display.SlotDisplay; - import net.minecraft.world.item.crafting.display.SmithingRecipeDisplay; - -+// CraftBukkit start -+import org.bukkit.NamespacedKey; -+import org.bukkit.craftbukkit.inventory.CraftItemStack; -+import org.bukkit.craftbukkit.inventory.CraftRecipe; -+import org.bukkit.craftbukkit.inventory.CraftSmithingTransformRecipe; -+import org.bukkit.inventory.Recipe; -+// CraftBukkit end -+ - public class SmithingTransformRecipe implements SmithingRecipe { - - final Optional template; -@@ -22,8 +30,15 @@ - final ItemStack result; - @Nullable - private PlacementInfo placementInfo; -+ final boolean copyDataComponents; // Paper - Option to prevent data components copy - - public SmithingTransformRecipe(Optional template, Optional base, Optional addition, ItemStack result) { -+ // Paper start - Option to prevent data components copy -+ this(template, base, addition, result, true); -+ } -+ public SmithingTransformRecipe(Optional template, Optional base, Optional 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; -@@ -33,7 +48,9 @@ - public ItemStack assemble(SmithingRecipeInput input, HolderLookup.Provider registries) { - ItemStack itemstack = input.base().transmuteCopy(this.result.getItem(), this.result.getCount()); - -+ if (this.copyDataComponents) { // Paper - Option to prevent data components copy - itemstack.applyComponents(this.result.getComponentsPatch()); -+ } // Paper - Option to prevent data components copy - return itemstack; - } - -@@ -71,6 +88,17 @@ - return List.of(new SmithingRecipeDisplay(Ingredient.optionalIngredientToDisplay(this.template), Ingredient.optionalIngredientToDisplay(this.base), Ingredient.optionalIngredientToDisplay(this.addition), new SlotDisplay.ItemStackSlotDisplay(this.result), new SlotDisplay.ItemSlotDisplay(Items.SMITHING_TABLE))); - } - -+ // CraftBukkit start -+ @Override -+ public Recipe toBukkitRecipe(NamespacedKey id) { -+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result); -+ -+ 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; -+ } -+ // CraftBukkit end -+ - public static class Serializer implements RecipeSerializer { - - private static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { diff --git a/paper-server/patches/unapplied/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch b/paper-server/patches/unapplied/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch deleted file mode 100644 index a5e660382a..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch +++ /dev/null @@ -1,69 +0,0 @@ ---- a/net/minecraft/world/item/crafting/SmithingTrimRecipe.java -+++ b/net/minecraft/world/item/crafting/SmithingTrimRecipe.java -@@ -21,6 +21,13 @@ - import net.minecraft.world.item.equipment.trim.TrimPattern; - import net.minecraft.world.item.equipment.trim.TrimPatterns; - -+// CraftBukkit start -+import org.bukkit.NamespacedKey; -+import org.bukkit.craftbukkit.inventory.CraftRecipe; -+import org.bukkit.craftbukkit.inventory.CraftSmithingTrimRecipe; -+import org.bukkit.inventory.Recipe; -+// CraftBukkit end -+ - public class SmithingTrimRecipe implements SmithingRecipe { - - final Optional template; -@@ -28,18 +35,28 @@ - final Optional addition; - @Nullable - private PlacementInfo placementInfo; -+ final boolean copyDataComponents; // Paper - Option to prevent data components copy - - public SmithingTrimRecipe(Optional template, Optional base, Optional addition) { -+ // Paper start - Option to prevent data components copy -+ this(template, base, addition, true); -+ } -+ public SmithingTrimRecipe(Optional template, Optional base, Optional addition, boolean copyDataComponents) { -+ this.copyDataComponents = copyDataComponents; -+ // Paper end - Option to prevent data components copy - this.template = template; - this.base = base; - this.addition = addition; - } - - public ItemStack assemble(SmithingRecipeInput input, HolderLookup.Provider registries) { -- return SmithingTrimRecipe.applyTrim(registries, input.base(), input.addition(), input.template()); -+ return SmithingTrimRecipe.applyTrim(registries, input.base(), input.addition(), input.template(), this.copyDataComponents); - } - - public static ItemStack applyTrim(HolderLookup.Provider registries, ItemStack base, ItemStack addition, ItemStack template) { -+ return applyTrim(registries, base, addition, template, true); -+ } -+ public static ItemStack applyTrim(HolderLookup.Provider registries, ItemStack base, ItemStack addition, ItemStack template, boolean copyDataComponents) { - Optional> optional = TrimMaterials.getFromIngredient(registries, addition); - Optional> optional1 = TrimPatterns.getFromTemplate(registries, template); - -@@ -49,7 +66,7 @@ - if (armortrim != null && armortrim.hasPatternAndMaterial((Holder) optional1.get(), (Holder) optional.get())) { - return ItemStack.EMPTY; - } else { -- ItemStack itemstack3 = base.copyWithCount(1); -+ ItemStack itemstack3 = copyDataComponents ? base.copyWithCount(1) : new ItemStack(base.getItem(), 1); // Paper - Option to prevent data components copy - - itemstack3.set(DataComponents.TRIM, new ArmorTrim((Holder) optional.get(), (Holder) optional1.get())); - return itemstack3; -@@ -97,6 +114,13 @@ - return List.of(new SmithingRecipeDisplay(slotdisplay2, slotdisplay, slotdisplay1, new SlotDisplay.SmithingTrimDemoSlotDisplay(slotdisplay, slotdisplay1, slotdisplay2), new SlotDisplay.ItemSlotDisplay(Items.SMITHING_TABLE))); - } - -+ // 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.copyDataComponents); // Paper - Option to prevent data components copy -+ } -+ // CraftBukkit end -+ - public static class Serializer implements RecipeSerializer { - - private static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { diff --git a/paper-server/patches/unapplied/net/minecraft/world/item/crafting/SmokingRecipe.java.patch b/paper-server/patches/unapplied/net/minecraft/world/item/crafting/SmokingRecipe.java.patch deleted file mode 100644 index 7c099a0fca..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/world/item/crafting/SmokingRecipe.java.patch +++ /dev/null @@ -1,35 +0,0 @@ ---- a/net/minecraft/world/item/crafting/SmokingRecipe.java -+++ b/net/minecraft/world/item/crafting/SmokingRecipe.java -@@ -4,6 +4,14 @@ - import net.minecraft.world.item.ItemStack; - import net.minecraft.world.item.Items; - -+// CraftBukkit start -+import org.bukkit.NamespacedKey; -+import org.bukkit.craftbukkit.inventory.CraftItemStack; -+import org.bukkit.craftbukkit.inventory.CraftRecipe; -+import org.bukkit.craftbukkit.inventory.CraftSmokingRecipe; -+import org.bukkit.inventory.Recipe; -+// CraftBukkit end -+ - public class SmokingRecipe extends AbstractCookingRecipe { - - public SmokingRecipe(String group, CookingBookCategory category, Ingredient ingredient, ItemStack result, float experience, int cookingTime) { -@@ -29,4 +37,17 @@ - public RecipeBookCategory recipeBookCategory() { - return RecipeBookCategories.SMOKER_FOOD; - } -+ -+ // CraftBukkit start -+ @Override -+ public Recipe toBukkitRecipe(NamespacedKey id) { -+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result()); -+ -+ CraftSmokingRecipe recipe = new CraftSmokingRecipe(id, result, CraftRecipe.toBukkit(this.input()), this.experience(), this.cookingTime()); -+ recipe.setGroup(this.group()); -+ recipe.setCategory(CraftRecipe.getCategory(this.category())); -+ -+ return recipe; -+ } -+ // CraftBukkit end - } diff --git a/paper-server/patches/unapplied/net/minecraft/world/item/crafting/StonecutterRecipe.java.patch b/paper-server/patches/unapplied/net/minecraft/world/item/crafting/StonecutterRecipe.java.patch deleted file mode 100644 index fd7dc9145c..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/world/item/crafting/StonecutterRecipe.java.patch +++ /dev/null @@ -1,34 +0,0 @@ ---- a/net/minecraft/world/item/crafting/StonecutterRecipe.java -+++ b/net/minecraft/world/item/crafting/StonecutterRecipe.java -@@ -7,6 +7,14 @@ - import net.minecraft.world.item.crafting.display.SlotDisplay; - import net.minecraft.world.item.crafting.display.StonecutterRecipeDisplay; - -+// CraftBukkit start -+import org.bukkit.NamespacedKey; -+import org.bukkit.craftbukkit.inventory.CraftItemStack; -+import org.bukkit.craftbukkit.inventory.CraftRecipe; -+import org.bukkit.craftbukkit.inventory.CraftStonecuttingRecipe; -+import org.bukkit.inventory.Recipe; -+// CraftBukkit end -+ - public class StonecutterRecipe extends SingleItemRecipe { - - public StonecutterRecipe(String group, Ingredient ingredient, ItemStack result) { -@@ -36,4 +44,16 @@ - public RecipeBookCategory recipeBookCategory() { - return RecipeBookCategories.STONECUTTER; - } -+ -+ // CraftBukkit start -+ @Override -+ public Recipe toBukkitRecipe(NamespacedKey id) { -+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result()); -+ -+ CraftStonecuttingRecipe recipe = new CraftStonecuttingRecipe(id, result, CraftRecipe.toBukkit(this.input())); -+ recipe.setGroup(this.group()); -+ -+ return recipe; -+ } -+ // CraftBukkit end - } diff --git a/paper-server/patches/unapplied/net/minecraft/world/item/crafting/TransmuteRecipe.java.patch b/paper-server/patches/unapplied/net/minecraft/world/item/crafting/TransmuteRecipe.java.patch deleted file mode 100644 index 7cc6f6f6d9..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/world/item/crafting/TransmuteRecipe.java.patch +++ /dev/null @@ -1,31 +0,0 @@ ---- a/net/minecraft/world/item/crafting/TransmuteRecipe.java -+++ b/net/minecraft/world/item/crafting/TransmuteRecipe.java -@@ -19,6 +19,13 @@ - import net.minecraft.world.item.crafting.display.SlotDisplay; - import net.minecraft.world.level.ItemLike; - import net.minecraft.world.level.Level; -+// CraftBukkit start -+import org.bukkit.NamespacedKey; -+import org.bukkit.craftbukkit.inventory.CraftItemType; -+import org.bukkit.craftbukkit.inventory.CraftRecipe; -+import org.bukkit.craftbukkit.inventory.CraftTransmuteRecipe; -+import org.bukkit.inventory.Recipe; -+// CraftBukkit end - - public class TransmuteRecipe implements CraftingRecipe { - -@@ -84,7 +91,14 @@ - return List.of(new ShapelessCraftingRecipeDisplay(List.of(this.input.display(), this.material.display()), new SlotDisplay.ItemSlotDisplay(this.result), new SlotDisplay.ItemSlotDisplay(Items.CRAFTING_TABLE))); - } - -+ // CraftBukkit start - @Override -+ public Recipe toBukkitRecipe(NamespacedKey id) { -+ return new CraftTransmuteRecipe(id, CraftItemType.minecraftToBukkit(this.result.value()), CraftRecipe.toBukkit(this.input), CraftRecipe.toBukkit(this.material)); -+ } -+ // CraftBukkit end -+ -+ @Override - public RecipeSerializer getSerializer() { - return RecipeSerializer.TRANSMUTE; - }