From 71e3c51538521c8925ce5557b7a4b22ec7e87a1f Mon Sep 17 00:00:00 2001
From: Bjarne Koll <LynxPlay101@gmail.com>
Date: Fri, 19 Jul 2024 19:29:31 +0200
Subject: [PATCH] Make CraftComplexRecipe extend CraftingRecipe (#11114)

---
 ...mplexRecipe-to-extend-CraftingRecipe.patch | 27 ++++++++++
 ...mplexRecipe-to-extend-CraftingRecipe.patch | 50 +++++++++++++++++++
 2 files changed, 77 insertions(+)
 create mode 100644 patches/api/Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch
 create mode 100644 patches/server/Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch

diff --git a/patches/api/Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch b/patches/api/Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch
new file mode 100644
index 0000000000..5b6af06df3
--- /dev/null
+++ b/patches/api/Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch
@@ -0,0 +1,27 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Bjarne Koll <git@lynxplay.dev>
+Date: Fri, 19 Jul 2024 19:09:21 +0200
+Subject: [PATCH] Move CraftComplexRecipe to extend CraftingRecipe
+
+A craft complex recipe wraps a CustomRecipe, which itself is a
+CraftingRecipe.
+As such, this complex recipe should also be a crafting recipe.
+
+diff --git a/src/main/java/org/bukkit/inventory/CraftingRecipe.java b/src/main/java/org/bukkit/inventory/CraftingRecipe.java
+index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
+--- a/src/main/java/org/bukkit/inventory/CraftingRecipe.java
++++ b/src/main/java/org/bukkit/inventory/CraftingRecipe.java
+@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull;
+  * Represents a shaped or shapeless crafting recipe.
+  */
+ public abstract class CraftingRecipe implements Recipe, Keyed {
+-    private final NamespacedKey key;
+-    private final ItemStack output;
++    // Paper - make CraftComplexRecipe extend CraftingRecipe - start
++    protected NamespacedKey key;
++    protected ItemStack output;
++    protected CraftingRecipe() {}
++    // Paper - make CraftComplexRecipe extend CraftingRecipe - end
+     private String group = "";
+     private CraftingBookCategory category = CraftingBookCategory.MISC;
+ 
diff --git a/patches/server/Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch b/patches/server/Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch
new file mode 100644
index 0000000000..1d7770b84b
--- /dev/null
+++ b/patches/server/Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch
@@ -0,0 +1,50 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Bjarne Koll <git@lynxplay.dev>
+Date: Fri, 19 Jul 2024 17:27:38 +0200
+Subject: [PATCH] Move CraftComplexRecipe to extend CraftingRecipe
+
+A craft complex recipe wraps a CustomRecipe, which itself is a
+CraftingRecipe.
+As such, this complex recipe should also be a crafting recipe.
+
+diff --git a/src/main/java/net/minecraft/world/item/crafting/CustomRecipe.java b/src/main/java/net/minecraft/world/item/crafting/CustomRecipe.java
+index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
+--- a/src/main/java/net/minecraft/world/item/crafting/CustomRecipe.java
++++ b/src/main/java/net/minecraft/world/item/crafting/CustomRecipe.java
+@@ -0,0 +0,0 @@ public abstract class CustomRecipe implements CraftingRecipe {
+     // CraftBukkit start
+     @Override
+     public Recipe toBukkitRecipe(NamespacedKey id) {
+-        return new org.bukkit.craftbukkit.inventory.CraftComplexRecipe(id, this);
++        // Paper - make CraftComplexRecipe extend CraftingRecipe - start
++        final org.bukkit.craftbukkit.inventory.CraftComplexRecipe recipe = new org.bukkit.craftbukkit.inventory.CraftComplexRecipe(id, this);
++        recipe.setGroup(this.getGroup());
++        recipe.setCategory(org.bukkit.craftbukkit.inventory.CraftRecipe.getCategory(this.category()));
++        return recipe;
++        // Paper - make CraftComplexRecipe extend CraftingRecipe - end
+     }
+     // CraftBukkit end
+ }
+diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftComplexRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftComplexRecipe.java
+index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
+--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftComplexRecipe.java
++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftComplexRecipe.java
+@@ -0,0 +0,0 @@ import org.bukkit.craftbukkit.util.CraftNamespacedKey;
+ import org.bukkit.inventory.ComplexRecipe;
+ import org.bukkit.inventory.ItemStack;
+ 
+-public class CraftComplexRecipe implements CraftRecipe, ComplexRecipe {
++public class CraftComplexRecipe extends org.bukkit.inventory.CraftingRecipe implements CraftRecipe, ComplexRecipe { // Paper - make CraftComplexRecipe extend CraftingRecipe
+ 
+     private final NamespacedKey key;
+     private final CustomRecipe recipe;
+ 
+     public CraftComplexRecipe(NamespacedKey key, CustomRecipe recipe) {
++        // Paper - make CraftComplexRecipe extend CraftingRecipe - start
++        super();
++        super.key = key;
++        super.output = ItemStack.empty();
++        // Paper - make CraftComplexRecipe extend CraftingRecipe - end
+         this.key = key;
+         this.recipe = recipe;
+     }