From c712f2c0533e00ff62793f3df14be9afb45f84c7 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Tue, 27 Oct 2020 15:04:32 +0000 Subject: [PATCH] [1.16] Improve performance of matching ingredients for shapeless recipes (#4694) --- ...0326-Fix-Custom-Shapeless-Custom-Crafting-Recipes.patch | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Spigot-Server-Patches/0326-Fix-Custom-Shapeless-Custom-Crafting-Recipes.patch b/Spigot-Server-Patches/0326-Fix-Custom-Shapeless-Custom-Crafting-Recipes.patch index 1518fcffe0..f7e2d37f1c 100644 --- a/Spigot-Server-Patches/0326-Fix-Custom-Shapeless-Custom-Crafting-Recipes.patch +++ b/Spigot-Server-Patches/0326-Fix-Custom-Shapeless-Custom-Crafting-Recipes.patch @@ -10,10 +10,10 @@ This made the Bukkit RecipeChoice API not work for Shapeless. This reimplements vanilla logic using the same test logic as Shaped diff --git a/src/main/java/net/minecraft/server/ShapelessRecipes.java b/src/main/java/net/minecraft/server/ShapelessRecipes.java -index 7ba4196a9e71085c35e732b5440db3109121b195..213e8cf55c3e1aeefc77729b872763bbff891578 100644 +index 7ba4196a9e71085c35e732b5440db3109121b195..61d88dbaa1f5c543be610ce0914b2c89d8ad40ee 100644 --- a/src/main/java/net/minecraft/server/ShapelessRecipes.java +++ b/src/main/java/net/minecraft/server/ShapelessRecipes.java -@@ -63,16 +63,46 @@ public class ShapelessRecipes implements RecipeCrafting { +@@ -63,16 +63,49 @@ public class ShapelessRecipes implements RecipeCrafting { AutoRecipeStackManager autorecipestackmanager = new AutoRecipeStackManager(); int i = 0; @@ -43,6 +43,9 @@ index 7ba4196a9e71085c35e732b5440db3109121b195..213e8cf55c3e1aeefc77729b872763bb - return i == this.ingredients.size() && autorecipestackmanager.a(this, (IntList) null); + // Paper start ++ if (matchedProvided.isEmpty() || matchedIngredients.isEmpty()) { ++ return false; ++ } + java.util.List ingredients = new java.util.ArrayList<>(this.ingredients); + providedItems.sort(java.util.Comparator.comparingInt((ItemStack c) -> (int) matchedProvided.getCount(c)).reversed()); + ingredients.sort(java.util.Comparator.comparingInt((RecipeItemStack c) -> (int) matchedIngredients.getCount(c)));