From 409693477478b51a319e814fe98ab14f270d4793 Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Fri, 19 Jul 2024 17:38:25 +0200 Subject: [PATCH 1/5] Make CraftComplexRecipe extend CraftingRecipe --- ...mplexRecipe-to-extend-CraftingRecipe.patch | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 patches/server/1042-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch diff --git a/patches/server/1042-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch b/patches/server/1042-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch new file mode 100644 index 000000000000..115ee05a4733 --- /dev/null +++ b/patches/server/1042-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch @@ -0,0 +1,43 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Bjarne Koll +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/org/bukkit/craftbukkit/inventory/CraftComplexRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftComplexRecipe.java +index dcaeaa3367351eb54e2cf8e62be19ecc125a4bb4..93426b40b9ce2c70f95a2cf81b0c15cc63abcb6a 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftComplexRecipe.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftComplexRecipe.java +@@ -9,13 +9,13 @@ import org.bukkit.craftbukkit.util.CraftNamespacedKey; + import org.bukkit.inventory.ComplexRecipe; + import org.bukkit.inventory.ItemStack; + +-public class CraftComplexRecipe implements CraftRecipe, ComplexRecipe { +- +- private final NamespacedKey key; ++public class CraftComplexRecipe extends org.bukkit.inventory.CraftingRecipe implements CraftRecipe, ComplexRecipe { // Paper - make CraftComplexRecipe extend CraftingRecipe ++ // Paper - make CraftComplexRecipe extend CraftingRecipe - move to parent + private final CustomRecipe recipe; + + public CraftComplexRecipe(NamespacedKey key, CustomRecipe recipe) { +- this.key = key; ++ super(key, ItemStack.empty()); // Paper - make CraftComplexRecipe extend CraftingRecipe - super ++ // Paper - make CraftComplexRecipe extend CraftingRecipe - move to parent + this.recipe = recipe; + } + +@@ -24,10 +24,7 @@ public class CraftComplexRecipe implements CraftRecipe, ComplexRecipe { + return CraftItemStack.asCraftMirror(this.recipe.getResultItem(RegistryAccess.EMPTY)); + } + +- @Override +- public NamespacedKey getKey() { +- return this.key; +- } ++ // Paper - make CraftComplexRecipe extend CraftingRecipe - move to parent + + @Override + public void addToCraftingManager() { From 6232383a2a8f3652426d179972c84c08ab0a744f Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Fri, 19 Jul 2024 18:11:58 +0200 Subject: [PATCH 2/5] Cleanup, set group/category --- ...mplexRecipe-to-extend-CraftingRecipe.patch | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/patches/server/1042-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch b/patches/server/1042-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch index 115ee05a4733..5a3d76e59966 100644 --- a/patches/server/1042-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch +++ b/patches/server/1042-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch @@ -7,37 +7,40 @@ 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 b57a2ba09f160409b5df9a2ae7ec159af3e4bf93..50aefbaf4da7f9c6b158c67a6eecfa7b1fabf3cb 100644 +--- a/src/main/java/net/minecraft/world/item/crafting/CustomRecipe.java ++++ b/src/main/java/net/minecraft/world/item/crafting/CustomRecipe.java +@@ -34,7 +34,12 @@ 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 inventory = new org.bukkit.craftbukkit.inventory.CraftComplexRecipe(id, this); ++ inventory.setGroup(this.getGroup()); ++ inventory.setCategory(org.bukkit.craftbukkit.inventory.CraftRecipe.getCategory(this.category())); ++ return inventory; ++ // 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 dcaeaa3367351eb54e2cf8e62be19ecc125a4bb4..93426b40b9ce2c70f95a2cf81b0c15cc63abcb6a 100644 +index dcaeaa3367351eb54e2cf8e62be19ecc125a4bb4..81669c389e0eaaae9187fd02c9d151598cdf2c61 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftComplexRecipe.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftComplexRecipe.java -@@ -9,13 +9,13 @@ import org.bukkit.craftbukkit.util.CraftNamespacedKey; +@@ -9,12 +9,13 @@ import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.inventory.ComplexRecipe; import org.bukkit.inventory.ItemStack; -public class CraftComplexRecipe implements CraftRecipe, ComplexRecipe { -- -- private final NamespacedKey key; +public class CraftComplexRecipe extends org.bukkit.inventory.CraftingRecipe implements CraftRecipe, ComplexRecipe { // Paper - make CraftComplexRecipe extend CraftingRecipe -+ // Paper - make CraftComplexRecipe extend CraftingRecipe - move to parent + + private final NamespacedKey key; private final CustomRecipe recipe; public CraftComplexRecipe(NamespacedKey key, CustomRecipe recipe) { -- this.key = key; + super(key, ItemStack.empty()); // Paper - make CraftComplexRecipe extend CraftingRecipe - super -+ // Paper - make CraftComplexRecipe extend CraftingRecipe - move to parent + this.key = key; this.recipe = recipe; } - -@@ -24,10 +24,7 @@ public class CraftComplexRecipe implements CraftRecipe, ComplexRecipe { - return CraftItemStack.asCraftMirror(this.recipe.getResultItem(RegistryAccess.EMPTY)); - } - -- @Override -- public NamespacedKey getKey() { -- return this.key; -- } -+ // Paper - make CraftComplexRecipe extend CraftingRecipe - move to parent - - @Override - public void addToCraftingManager() { From d90a343deb02998a2473906d6a1149dae5ea257f Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Fri, 19 Jul 2024 18:42:09 +0200 Subject: [PATCH 3/5] Constructor bypass --- ...mplexRecipe-to-extend-CraftingRecipe.patch | 27 +++++++++++++++++++ ...mplexRecipe-to-extend-CraftingRecipe.patch | 10 ++++--- 2 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 patches/api/0482-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch diff --git a/patches/api/0482-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch b/patches/api/0482-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch new file mode 100644 index 000000000000..7bf99722cc26 --- /dev/null +++ b/patches/api/0482-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch @@ -0,0 +1,27 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Bjarne Koll +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 37024b4736dd3897490ca51d08cf07901b01d59f..afa3de9ab78d01c448d450d8afbc7b1e7e62754c 100644 +--- a/src/main/java/org/bukkit/inventory/CraftingRecipe.java ++++ b/src/main/java/org/bukkit/inventory/CraftingRecipe.java +@@ -11,8 +11,11 @@ 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/1042-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch b/patches/server/1042-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch index 5a3d76e59966..637bc35de561 100644 --- a/patches/server/1042-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch +++ b/patches/server/1042-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch @@ -26,10 +26,10 @@ index b57a2ba09f160409b5df9a2ae7ec159af3e4bf93..50aefbaf4da7f9c6b158c67a6eecfa7b // 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 dcaeaa3367351eb54e2cf8e62be19ecc125a4bb4..81669c389e0eaaae9187fd02c9d151598cdf2c61 100644 +index dcaeaa3367351eb54e2cf8e62be19ecc125a4bb4..05f42ec6177218960b22dc2c224f63cbf37d696f 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftComplexRecipe.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftComplexRecipe.java -@@ -9,12 +9,13 @@ import org.bukkit.craftbukkit.util.CraftNamespacedKey; +@@ -9,12 +9,17 @@ import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.inventory.ComplexRecipe; import org.bukkit.inventory.ItemStack; @@ -40,7 +40,11 @@ index dcaeaa3367351eb54e2cf8e62be19ecc125a4bb4..81669c389e0eaaae9187fd02c9d15159 private final CustomRecipe recipe; public CraftComplexRecipe(NamespacedKey key, CustomRecipe recipe) { -+ super(key, ItemStack.empty()); // Paper - make CraftComplexRecipe extend CraftingRecipe - super ++ // 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; } From dc5fac936ce94bc712109537049b862321ec9e9f Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Fri, 19 Jul 2024 19:17:55 +0200 Subject: [PATCH 4/5] Swap patch order --- ...> 0481-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch} | 0 ...d-CrafterCraftEvent.patch => 0482-Add-CrafterCraftEvent.patch} | 0 ...> 1041-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch} | 0 ...d-CrafterCraftEvent.patch => 1042-Add-CrafterCraftEvent.patch} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename patches/api/{0482-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch => 0481-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch} (100%) rename patches/api/{0481-Add-CrafterCraftEvent.patch => 0482-Add-CrafterCraftEvent.patch} (100%) rename patches/server/{1042-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch => 1041-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch} (100%) rename patches/server/{1041-Add-CrafterCraftEvent.patch => 1042-Add-CrafterCraftEvent.patch} (100%) diff --git a/patches/api/0482-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch b/patches/api/0481-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch similarity index 100% rename from patches/api/0482-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch rename to patches/api/0481-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch diff --git a/patches/api/0481-Add-CrafterCraftEvent.patch b/patches/api/0482-Add-CrafterCraftEvent.patch similarity index 100% rename from patches/api/0481-Add-CrafterCraftEvent.patch rename to patches/api/0482-Add-CrafterCraftEvent.patch diff --git a/patches/server/1042-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch b/patches/server/1041-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch similarity index 100% rename from patches/server/1042-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch rename to patches/server/1041-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch diff --git a/patches/server/1041-Add-CrafterCraftEvent.patch b/patches/server/1042-Add-CrafterCraftEvent.patch similarity index 100% rename from patches/server/1041-Add-CrafterCraftEvent.patch rename to patches/server/1042-Add-CrafterCraftEvent.patch From a3f28c6070ae406ceba2746e72cb2ed326fb3484 Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Fri, 19 Jul 2024 19:24:06 +0200 Subject: [PATCH 5/5] Rename var --- ...e-CraftComplexRecipe-to-extend-CraftingRecipe.patch | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/patches/server/1041-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch b/patches/server/1041-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch index 637bc35de561..3e85c7f98707 100644 --- a/patches/server/1041-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch +++ b/patches/server/1041-Move-CraftComplexRecipe-to-extend-CraftingRecipe.patch @@ -8,7 +8,7 @@ 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 b57a2ba09f160409b5df9a2ae7ec159af3e4bf93..50aefbaf4da7f9c6b158c67a6eecfa7b1fabf3cb 100644 +index b57a2ba09f160409b5df9a2ae7ec159af3e4bf93..69a7e500c725e9da950df30f2cc4ff5f72e527d0 100644 --- a/src/main/java/net/minecraft/world/item/crafting/CustomRecipe.java +++ b/src/main/java/net/minecraft/world/item/crafting/CustomRecipe.java @@ -34,7 +34,12 @@ public abstract class CustomRecipe implements CraftingRecipe { @@ -17,10 +17,10 @@ index b57a2ba09f160409b5df9a2ae7ec159af3e4bf93..50aefbaf4da7f9c6b158c67a6eecfa7b 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 inventory = new org.bukkit.craftbukkit.inventory.CraftComplexRecipe(id, this); -+ inventory.setGroup(this.getGroup()); -+ inventory.setCategory(org.bukkit.craftbukkit.inventory.CraftRecipe.getCategory(this.category())); -+ return inventory; ++ 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